int act = event.getAction();
if (act == LibraryEvent.ADD_TOOL) {
if (event.getData() instanceof AddTool) {
AddTool tool = (AddTool) event.getData();
if (tool.getFactory() instanceof SubcircuitFactory) {
SubcircuitFactory fact = (SubcircuitFactory) tool.getFactory();
fact.getSubcircuit().addCircuitListener(this);
}
}
} else if (act == LibraryEvent.REMOVE_TOOL) {
if (event.getData() instanceof AddTool) {
AddTool tool = (AddTool) event.getData();
if (tool.getFactory() instanceof SubcircuitFactory) {
SubcircuitFactory fact = (SubcircuitFactory) tool.getFactory();
fact.getSubcircuit().removeCircuitListener(this);
}
}
} else if (act == LibraryEvent.ADD_LIBRARY) {
if (event.getData() instanceof LibraryEventSource) {
((LibraryEventSource) event.getData()).addLibraryListener(subListener);