Search in sources :

Example 6 with AddTool

use of com.cburch.logisim.tools.AddTool 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 7 with AddTool

use of com.cburch.logisim.tools.AddTool 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 8 with AddTool

use of com.cburch.logisim.tools.AddTool 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 9 with AddTool

use of com.cburch.logisim.tools.AddTool 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)

Example 10 with AddTool

use of com.cburch.logisim.tools.AddTool in project logisim-evolution by reds-heig.

the class ProjectCircuitActions method doMoveCircuit.

public static void doMoveCircuit(Project proj, Circuit cur, int delta) {
    AddTool tool = proj.getLogisimFile().getAddTool(cur);
    if (tool != null) {
        int oldPos = proj.getLogisimFile().getCircuits().indexOf(cur);
        int newPos = oldPos + delta;
        int toolsCount = proj.getLogisimFile().getTools().size();
        if (newPos >= 0 && newPos < toolsCount) {
            proj.doAction(LogisimFileActions.moveCircuit(tool, newPos));
        }
    }
}
Also used : AddTool(com.cburch.logisim.tools.AddTool)

Aggregations

AddTool (com.cburch.logisim.tools.AddTool)16 Tool (com.cburch.logisim.tools.Tool)10 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)9 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)7 Library (com.cburch.logisim.tools.Library)6 Circuit (com.cburch.logisim.circuit.Circuit)5 ProjectExplorerToolNode (com.cburch.logisim.gui.generic.ProjectExplorerToolNode)4 ProjectExplorerLibraryNode (com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 CircuitException (com.cburch.logisim.circuit.CircuitException)1 CircuitMutation (com.cburch.logisim.circuit.CircuitMutation)1 Component (com.cburch.logisim.comp.Component)1 AttributeSet (com.cburch.logisim.data.AttributeSet)1 Location (com.cburch.logisim.data.Location)1 AttrTableModel (com.cburch.logisim.gui.generic.AttrTableModel)1 Action (com.cburch.logisim.proj.Action)1 SelectTool (com.cburch.logisim.tools.SelectTool)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1