Component comp;
switch (e.getAction()) {
case CircuitEvent.ACTION_ADD:
comp = (Component) e.getData();
if (comp.getFactory() instanceof SubcircuitFactory) {
SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
depends.addEdge(e.getCircuit(), factory.getSubcircuit());
}
break;
case CircuitEvent.ACTION_REMOVE:
comp = (Component) e.getData();
if (comp.getFactory() instanceof SubcircuitFactory) {
SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
boolean found = false;
for (Component o : e.getCircuit().getNonWires()) {
if (o.getFactory() == factory) {
found = true;
break;
}
}
if (!found) depends.removeEdge(e.getCircuit(), factory.getSubcircuit());
}
break;
case CircuitEvent.ACTION_CLEAR:
depends.removeNode(e.getCircuit());
break;