Search in sources :

Example 16 with AddTool

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

the class AttrTableToolModel method setValueRequested.

@Override
public void setValueRequested(Attribute<Object> attr, Object value) {
    if (tool instanceof AddTool) {
        AddTool mytool = (AddTool) tool;
        if (mytool.getFactory() instanceof SubcircuitFactory) {
            SubcircuitFactory fac = (SubcircuitFactory) mytool.getFactory();
            if (attr.equals(CircuitAttributes.NAMED_CIRCUIT_BOX) || attr.equals(CircuitAttributes.NAME_ATTR)) {
                try {
                    CircuitMutation mutation = new CircuitMutation(fac.getSubcircuit());
                    mutation.setForCircuit(attr, value);
                    Action action = mutation.toAction(null);
                    proj.doAction(action);
                } catch (CircuitException ex) {
                    JOptionPane.showMessageDialog(proj.getFrame(), ex.getMessage());
                }
                return;
            }
        }
    }
    proj.doAction(ToolAttributeAction.create(tool, attr, value));
}
Also used : Action(com.cburch.logisim.proj.Action) CircuitException(com.cburch.logisim.circuit.CircuitException) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) CircuitMutation(com.cburch.logisim.circuit.CircuitMutation) 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