Search in sources :

Example 1 with ProjectExplorerToolNode

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

the class ToolboxManip method doubleClicked.

public void doubleClicked(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) {
                SubcircuitFactory circFact = (SubcircuitFactory) source;
                proj.setCurrentCircuit(circFact.getSubcircuit());
                proj.getFrame().setEditorView(Frame.EDIT_LAYOUT);
                if (lastSelected != null) {
                    proj.setTool(lastSelected);
                } else {
                    Library base = proj.getLogisimFile().getLibrary("Base");
                    if (base != null)
                        proj.setTool(base.getTool("Edit Tool"));
                }
            }
        }
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) AddTool(com.cburch.logisim.tools.AddTool) Library(com.cburch.logisim.tools.Library) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 2 with ProjectExplorerToolNode

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

the class ToolboxManip method selectionChanged.

public void selectionChanged(ProjectExplorerEvent event) {
    Object selected = event.getTarget();
    if (selected instanceof ProjectExplorerToolNode) {
        Tool tool = ((ProjectExplorerToolNode) selected).getValue();
        if (selected instanceof AddTool) {
            AddTool addTool = (AddTool) tool;
            ComponentFactory source = addTool.getFactory();
            if (source instanceof SubcircuitFactory) {
                SubcircuitFactory circFact = (SubcircuitFactory) source;
                Circuit circ = circFact.getSubcircuit();
                if (proj.getCurrentCircuit() == circ) {
                    AttrTableModel m = new AttrTableCircuitModel(proj, circ);
                    proj.getFrame().setAttrTableModel(m);
                    return;
                }
            }
        }
        // This was causing the selection to lag behind double-clicks,
        // commented-out
        // lastSelected = proj.getTool();
        proj.setTool(tool);
        proj.getFrame().viewAttributes(tool);
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) AttrTableModel(com.cburch.logisim.gui.generic.AttrTableModel) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit) AddTool(com.cburch.logisim.tools.AddTool) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 3 with ProjectExplorerToolNode

use of com.cburch.logisim.gui.generic.ProjectExplorerToolNode 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 4 with ProjectExplorerToolNode

use of com.cburch.logisim.gui.generic.ProjectExplorerToolNode 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)4 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)4 ProjectExplorerToolNode (com.cburch.logisim.gui.generic.ProjectExplorerToolNode)4 AddTool (com.cburch.logisim.tools.AddTool)4 Tool (com.cburch.logisim.tools.Tool)4 Library (com.cburch.logisim.tools.Library)3 Circuit (com.cburch.logisim.circuit.Circuit)2 ProjectExplorerLibraryNode (com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode)2 AttrTableModel (com.cburch.logisim.gui.generic.AttrTableModel)1