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"));
}
}
}
}
}
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);
}
}
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;
}
}
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());
}
}
}
}
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));
}
}
}
Aggregations