Search in sources :

Example 26 with NodeBase

use of gov.sandia.n2a.ui.eq.tree.NodeBase in project n2a by frothga.

the class ChangeAnnotation method redo.

public void redo() {
    super.redo();
    apply(path, nameBefore, nameAfter, valueAfter, "$metadata", new NodeFactory() {

        public NodeBase create(MPart part) {
            return new NodeAnnotation(part);
        }
    });
}
Also used : NodeBase(gov.sandia.n2a.ui.eq.tree.NodeBase) MPart(gov.sandia.n2a.eqset.MPart) NodeAnnotation(gov.sandia.n2a.ui.eq.tree.NodeAnnotation)

Example 27 with NodeBase

use of gov.sandia.n2a.ui.eq.tree.NodeBase in project n2a by frothga.

the class ChangeInherit method apply.

public void apply(String value) {
    NodeBase node = NodeBase.locateNode(path);
    if (node == null)
        throw new CannotRedoException();
    PanelModel mep = PanelModel.instance;
    JTree tree = mep.panelEquations.tree;
    FilteredTreeModel model = (FilteredTreeModel) tree.getModel();
    // Complex restructuring happens here.
    node.source.set(value);
    NodePart parent = (NodePart) node.getParent();
    parent.build();
    parent.findConnections();
    parent.filter(model.filterLevel);
    if (parent.visible(model.filterLevel))
        model.nodeStructureChanged(parent);
    TreeNode[] nodePath = parent.child("$inherit").getPath();
    mep.panelEquations.updateOrder(nodePath);
    mep.panelEquations.updateVisibility(nodePath);
}
Also used : NodeBase(gov.sandia.n2a.ui.eq.tree.NodeBase) PanelModel(gov.sandia.n2a.ui.eq.PanelModel) JTree(javax.swing.JTree) TreeNode(javax.swing.tree.TreeNode) CannotRedoException(javax.swing.undo.CannotRedoException) NodePart(gov.sandia.n2a.ui.eq.tree.NodePart) FilteredTreeModel(gov.sandia.n2a.ui.eq.FilteredTreeModel)

Example 28 with NodeBase

use of gov.sandia.n2a.ui.eq.tree.NodeBase in project n2a by frothga.

the class ChangeLock method apply.

public static void apply(List<String> path, boolean value) {
    NodeBase parent = NodeBase.locateNode(path);
    if (parent == null)
        throw new CannotRedoException();
    NodeBase node = parent.child("lock");
    if (node == null)
        throw new CannotRedoException();
    PanelEquationTree pet = PanelModel.instance.panelEquations;
    // Since this function implements both do and undo, we need to toggle the current lock state.
    if (// Force entry to be local rather than inherited. Only a local entry causes the lock to take effect.
    value)
        // Force entry to be local rather than inherited. Only a local entry causes the lock to take effect.
        node.source.override();
    else
        node.source.clearPath();
    TreeNode[] nodePath = node.getPath();
    pet.updateVisibility(nodePath);
    pet.updateLock();
}
Also used : NodeBase(gov.sandia.n2a.ui.eq.tree.NodeBase) TreeNode(javax.swing.tree.TreeNode) CannotRedoException(javax.swing.undo.CannotRedoException) PanelEquationTree(gov.sandia.n2a.ui.eq.PanelEquationTree)

Example 29 with NodeBase

use of gov.sandia.n2a.ui.eq.tree.NodeBase in project n2a by frothga.

the class ChangeReference method undo.

public void undo() {
    super.undo();
    ChangeAnnotation.apply(path, nameAfter, nameBefore, valueBefore, "$reference", new NodeFactory() {

        public NodeBase create(MPart part) {
            return new NodeReference(part);
        }
    });
}
Also used : NodeBase(gov.sandia.n2a.ui.eq.tree.NodeBase) MPart(gov.sandia.n2a.eqset.MPart) NodeReference(gov.sandia.n2a.ui.eq.tree.NodeReference)

Example 30 with NodeBase

use of gov.sandia.n2a.ui.eq.tree.NodeBase in project n2a by frothga.

the class ChangeReference method redo.

public void redo() {
    super.redo();
    ChangeAnnotation.apply(path, nameBefore, nameAfter, valueAfter, "$reference", new NodeFactory() {

        public NodeBase create(MPart part) {
            return new NodeReference(part);
        }
    });
}
Also used : NodeBase(gov.sandia.n2a.ui.eq.tree.NodeBase) MPart(gov.sandia.n2a.eqset.MPart) NodeReference(gov.sandia.n2a.ui.eq.tree.NodeReference)

Aggregations

NodeBase (gov.sandia.n2a.ui.eq.tree.NodeBase)39 MPart (gov.sandia.n2a.eqset.MPart)20 JTree (javax.swing.JTree)19 FilteredTreeModel (gov.sandia.n2a.ui.eq.FilteredTreeModel)18 PanelModel (gov.sandia.n2a.ui.eq.PanelModel)15 TreeNode (javax.swing.tree.TreeNode)15 FontMetrics (java.awt.FontMetrics)12 CannotRedoException (javax.swing.undo.CannotRedoException)12 NodePart (gov.sandia.n2a.ui.eq.tree.NodePart)11 CannotUndoException (javax.swing.undo.CannotUndoException)8 TreePath (javax.swing.tree.TreePath)7 NodeVariable (gov.sandia.n2a.ui.eq.tree.NodeVariable)5 ExtensionPoint (gov.sandia.n2a.plugins.ExtensionPoint)4 PanelEquationTree (gov.sandia.n2a.ui.eq.PanelEquationTree)4 NodeAnnotation (gov.sandia.n2a.ui.eq.tree.NodeAnnotation)4 NodeEquation (gov.sandia.n2a.ui.eq.tree.NodeEquation)3 NodeAnnotations (gov.sandia.n2a.ui.eq.tree.NodeAnnotations)2 NodeContainer (gov.sandia.n2a.ui.eq.tree.NodeContainer)2 NodeReference (gov.sandia.n2a.ui.eq.tree.NodeReference)2 Font (java.awt.Font)2