Search in sources :

Example 31 with NodePart

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

the class CompoundEditView method selectLead.

public void selectLead() {
    if (leadPath == null)
        return;
    NodeBase n = NodeBase.locateNode(leadPath);
    if (n == null)
        return;
    if (clearSelection == CLEAR_GRAPH) {
        // CLEAR_GRAPH should only be used for compound operations on parts, so this should be a safe cast.
        NodePart p = (NodePart) n;
        if (p.graph != null) {
            p.graph.takeFocusOnTitle();
            return;
        }
    }
    // Otherwise, assume this is a compound operation on tree nodes.
    PanelEquationTree pet = n.getTree();
    if (pet != null)
        pet.tree.setLeadSelectionPath(new TreePath(n.getPath()));
}
Also used : NodeBase(gov.sandia.n2a.ui.eq.tree.NodeBase) TreePath(javax.swing.tree.TreePath) NodePart(gov.sandia.n2a.ui.eq.tree.NodePart) PanelEquationTree(gov.sandia.n2a.ui.eq.PanelEquationTree)

Example 32 with NodePart

use of gov.sandia.n2a.ui.eq.tree.NodePart 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();
    NodePart parent = (NodePart) node.getParent();
    NodePart grandparent = (NodePart) parent.getTrueParent();
    PanelEquations pe = PanelModel.instance.panelEquations;
    PanelEquationTree pet = node.getTree();
    FilteredTreeModel model = (FilteredTreeModel) pet.tree.getModel();
    PanelEquationGraph peg = pe.panelEquationGraph;
    // Complex restructuring happens here.
    node.source.set(value);
    parent.build();
    if (grandparent == null)
        parent.findConnections();
    else
        grandparent.findConnections();
    parent.rebuildPins();
    parent.filter();
    if (parent == pe.part) {
        peg.reloadPart();
        // Ensure that parts are not visible in parent panel.
        parent.filter();
    }
    model.nodeStructureChanged(parent);
    TreeNode[] nodePath = parent.child("$inherit").getPath();
    pet.updateOrder(nodePath);
    pet.updateVisibility(nodePath);
    pet.animate();
    if (parent != pe.part) {
        peg.updatePins();
        peg.reconnect();
        peg.repaint();
    }
    if (// root node, so update categories in search list
    parent.getTrueParent() == null) {
        PanelModel.instance.panelSearch.search();
    }
}
Also used : NodeBase(gov.sandia.n2a.ui.eq.tree.NodeBase) PanelEquationGraph(gov.sandia.n2a.ui.eq.PanelEquationGraph) TreeNode(javax.swing.tree.TreeNode) CannotRedoException(javax.swing.undo.CannotRedoException) PanelEquations(gov.sandia.n2a.ui.eq.PanelEquations) NodePart(gov.sandia.n2a.ui.eq.tree.NodePart) PanelEquationTree(gov.sandia.n2a.ui.eq.PanelEquationTree) FilteredTreeModel(gov.sandia.n2a.ui.eq.FilteredTreeModel)

Example 33 with NodePart

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

the class ChangeVariableToInherit method redo.

public void redo() {
    super.redo();
    NodePart parent = (NodePart) NodeBase.locateNode(path);
    if (parent == null)
        throw new CannotRedoException();
    NodePart grandparent = (NodePart) parent.getTrueParent();
    // Update database
    MPart mparent = parent.source;
    mparent.clear(treeBefore.key());
    mparent.set(valueAfter, "$inherit");
    // Update GUI
    PanelEquations pe = PanelModel.instance.panelEquations;
    PanelEquationTree pet = parent.getTree();
    FilteredTreeModel model = (FilteredTreeModel) pet.tree.getModel();
    PanelEquationGraph peg = pe.panelEquationGraph;
    parent.build();
    if (grandparent == null)
        parent.findConnections();
    else
        grandparent.findConnections();
    parent.rebuildPins();
    parent.filter();
    if (parent == pe.part) {
        peg.reloadPart();
        parent.filter();
    }
    model.nodeStructureChanged(parent);
    TreeNode[] nodePath = parent.child("$inherit").getPath();
    pet.updateOrder(nodePath);
    pet.updateVisibility(nodePath);
    pet.animate();
    if (parent != pe.part) {
        peg.updatePins();
        peg.reconnect();
        peg.repaint();
    }
    if (// root node, so update categories in search list
    parent.getTrueParent() == null) {
        PanelModel.instance.panelSearch.search();
    }
}
Also used : MPart(gov.sandia.n2a.eqset.MPart) PanelEquationGraph(gov.sandia.n2a.ui.eq.PanelEquationGraph) TreeNode(javax.swing.tree.TreeNode) CannotRedoException(javax.swing.undo.CannotRedoException) PanelEquations(gov.sandia.n2a.ui.eq.PanelEquations) NodePart(gov.sandia.n2a.ui.eq.tree.NodePart) PanelEquationTree(gov.sandia.n2a.ui.eq.PanelEquationTree) FilteredTreeModel(gov.sandia.n2a.ui.eq.FilteredTreeModel)

Aggregations

NodePart (gov.sandia.n2a.ui.eq.tree.NodePart)33 NodeBase (gov.sandia.n2a.ui.eq.tree.NodeBase)21 PanelEquationTree (gov.sandia.n2a.ui.eq.PanelEquationTree)19 FilteredTreeModel (gov.sandia.n2a.ui.eq.FilteredTreeModel)18 MPart (gov.sandia.n2a.eqset.MPart)17 TreeNode (javax.swing.tree.TreeNode)16 PanelEquations (gov.sandia.n2a.ui.eq.PanelEquations)12 TreePath (javax.swing.tree.TreePath)11 CannotRedoException (javax.swing.undo.CannotRedoException)11 PanelEquationGraph (gov.sandia.n2a.ui.eq.PanelEquationGraph)10 NodeVariable (gov.sandia.n2a.ui.eq.tree.NodeVariable)10 CannotUndoException (javax.swing.undo.CannotUndoException)8 MNode (gov.sandia.n2a.db.MNode)7 NodeAnnotation (gov.sandia.n2a.ui.eq.tree.NodeAnnotation)5 NodeAnnotations (gov.sandia.n2a.ui.eq.tree.NodeAnnotations)5 NodeContainer (gov.sandia.n2a.ui.eq.tree.NodeContainer)3 FontMetrics (java.awt.FontMetrics)3 Point (java.awt.Point)3 Rectangle (java.awt.Rectangle)3 ArrayList (java.util.ArrayList)3