Search in sources :

Example 1 with ProjectExplorerLibraryNode

use of com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode in project logisim-evolution by reds-heig.

the class ToolboxManip method menuRequested.

public JPopupMenu menuRequested(ProjectExplorerEvent event) {
    Object clicked = event.getTarget();
    if (clicked instanceof ProjectExplorerToolNode) {
        Tool baseTool = ((ProjectExplorerToolNode) clicked).getValue();
        if (baseTool instanceof AddTool) {
            AddTool tool = (AddTool) baseTool;
            ComponentFactory source = tool.getFactory();
            if (source instanceof SubcircuitFactory) {
                Circuit circ = ((SubcircuitFactory) source).getSubcircuit();
                return Popups.forCircuit(proj, tool, circ);
            } else {
                return null;
            }
        } else {
            return null;
        }
    } else if (clicked instanceof ProjectExplorerLibraryNode) {
        Library lib = ((ProjectExplorerLibraryNode) clicked).getValue();
        if (lib == proj.getLogisimFile()) {
            return Popups.forProject(proj);
        } else {
            boolean is_top = event.getTreePath().getPathCount() <= 2;
            return Popups.forLibrary(proj, lib, is_top);
        }
    } else {
        return null;
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit) AddTool(com.cburch.logisim.tools.AddTool) ProjectExplorerLibraryNode(com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode) Library(com.cburch.logisim.tools.Library) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 2 with ProjectExplorerLibraryNode

use of com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode in project logisim-evolution by reds-heig.

the class ToolboxManip method deleteRequested.

public void deleteRequested(ProjectExplorerEvent event) {
    Object request = event.getTarget();
    if (request instanceof ProjectExplorerLibraryNode) {
        Library lib = ((ProjectExplorerLibraryNode) request).getValue();
        ProjectLibraryActions.doUnloadLibrary(proj, lib);
    } else if (request instanceof ProjectExplorerToolNode) {
        Tool tool = ((ProjectExplorerToolNode) request).getValue();
        if (tool instanceof AddTool) {
            ComponentFactory factory = ((AddTool) tool).getFactory();
            if (factory instanceof SubcircuitFactory) {
                SubcircuitFactory circFact = (SubcircuitFactory) factory;
                ProjectCircuitActions.doRemoveCircuit(proj, circFact.getSubcircuit());
            }
        }
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) ProjectExplorerLibraryNode(com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode) Library(com.cburch.logisim.tools.Library) AddTool(com.cburch.logisim.tools.AddTool) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Aggregations

SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)2 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)2 ProjectExplorerLibraryNode (com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode)2 ProjectExplorerToolNode (com.cburch.logisim.gui.generic.ProjectExplorerToolNode)2 AddTool (com.cburch.logisim.tools.AddTool)2 Library (com.cburch.logisim.tools.Library)2 Tool (com.cburch.logisim.tools.Tool)2 Circuit (com.cburch.logisim.circuit.Circuit)1