Search in sources :

Example 1 with AttrTableModel

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

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

the class Frame method viewAttributes.

private void viewAttributes(Tool oldTool, Tool newTool, boolean force) {
    AttributeSet newAttrs;
    if (newTool == null) {
        newAttrs = null;
        if (!force) {
            return;
        }
    } else {
        newAttrs = newTool.getAttributeSet(layoutCanvas);
    }
    if (newAttrs == null) {
        AttrTableModel oldModel = attrTable.getAttrTableModel();
        boolean same = oldModel instanceof AttrTableToolModel && ((AttrTableToolModel) oldModel).getTool() == oldTool;
        if (!force && !same && !(oldModel instanceof AttrTableCircuitModel)) {
            return;
        }
    }
    if (newAttrs == null) {
        Circuit circ = proj.getCurrentCircuit();
        if (circ != null) {
            setAttrTableModel(new AttrTableCircuitModel(proj, circ));
        } else if (force) {
            setAttrTableModel(null);
        }
    } else if (newAttrs instanceof SelectionAttributes) {
        setAttrTableModel(attrTableSelectionModel);
    } else {
        setAttrTableModel(new AttrTableToolModel(proj, newTool));
    }
}
Also used : AttributeSet(com.cburch.logisim.data.AttributeSet) AttrTableModel(com.cburch.logisim.gui.generic.AttrTableModel) Circuit(com.cburch.logisim.circuit.Circuit)

Aggregations

Circuit (com.cburch.logisim.circuit.Circuit)2 AttrTableModel (com.cburch.logisim.gui.generic.AttrTableModel)2 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)1 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)1 AttributeSet (com.cburch.logisim.data.AttributeSet)1 ProjectExplorerToolNode (com.cburch.logisim.gui.generic.ProjectExplorerToolNode)1 AddTool (com.cburch.logisim.tools.AddTool)1 Tool (com.cburch.logisim.tools.Tool)1