Search in sources :

Example 36 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class PanelMRU method saveMRU.

public void saveMRU() {
    // roughly twice the length of the visible list, which could be zero
    int limit = (list.getLastVisibleIndex() + 1) * 2;
    MNode parts = AppData.state.childOrCreate("PanelModel", "MRU");
    parts.clear();
    for (int i = 0; i < model.size() && i < limit; i++) {
        parts.set(i, model.get(i).doc.key());
    }
}
Also used : MNode(gov.sandia.n2a.db.MNode)

Example 37 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class PanelSearch method selectCurrent.

public void selectCurrent() {
    int index = list.getSelectedIndex();
    if (index >= 0) {
        MNode doc = model.get(index).doc;
        PanelModel.instance.panelMRU.useDoc(doc);
        recordSelected(doc);
    }
}
Also used : MNode(gov.sandia.n2a.db.MNode)

Example 38 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class NodeBase method copy.

/**
 *        Assemble the visible subtree, starting at this node, and return it as a child of the given MNode.
 */
public void copy(MNode result) {
    MNode n = result.set(source.key(), source.get());
    Enumeration<?> cf = childrenFiltered();
    while (cf.hasMoreElements()) ((NodeBase) cf.nextElement()).copy(n);
}
Also used : MNode(gov.sandia.n2a.db.MNode)

Example 39 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class NodePart method setUserObject.

public void setUserObject() {
    // This won't actually be used in editing, but it does prevent editingCancelled() from getting a null object.
    setUserObject(source.key());
    parentName = "";
    if (!isRoot()) {
        MNode inherit = source.child("$inherit");
        if (inherit != null)
            parentName = inherit.get().split(",", 2)[0].replace("\"", "");
    }
}
Also used : MNode(gov.sandia.n2a.db.MNode)

Example 40 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class NodeVariable method enforceOneLine.

/**
 *        Ensures that a variable either has multiple equations or a one-line expression,
 *        but not both.
 *        This method is independent of any given NodeVariable so it can be used at
 *        various points in processing.
 */
public static void enforceOneLine(MNode source) {
    // Collect info
    int equationCount = 0;
    MNode equation = null;
    for (MNode n : source) {
        String key = n.key();
        if (key.startsWith("@")) {
            equation = n;
            equationCount++;
        }
    }
    String value = source.get();
    if (value.startsWith("$kill"))
        value = "";
    Variable.ParsedValue pieces = new Variable.ParsedValue(value);
    boolean empty = pieces.expression.isEmpty() && pieces.condition.isEmpty();
    // Collapse or expand
    if (equationCount > 0) {
        if (!empty) {
            // Expand
            source.set(pieces.combiner);
            // may override an existing equation
            source.set("@" + pieces.condition, pieces.expression);
        } else if (equationCount == 1) {
            // Collapse
            String key = equation.key();
            source.clear(key);
            if (key.equals("@"))
                source.set(pieces.combiner + equation.get());
            else
                source.set(pieces.combiner + equation.get() + key);
        }
    }
}
Also used : Variable(gov.sandia.n2a.eqset.Variable) ChangeVariable(gov.sandia.n2a.ui.eq.undo.ChangeVariable) DeleteVariable(gov.sandia.n2a.ui.eq.undo.DeleteVariable) MNode(gov.sandia.n2a.db.MNode)

Aggregations

MNode (gov.sandia.n2a.db.MNode)63 Node (org.w3c.dom.Node)11 NameMap (gov.sandia.n2a.backend.neuroml.PartMap.NameMap)9 MVolatile (gov.sandia.n2a.db.MVolatile)5 MPart (gov.sandia.n2a.eqset.MPart)5 ArrayList (java.util.ArrayList)5 PanelModel (gov.sandia.n2a.ui.eq.PanelModel)4 MPersistent (gov.sandia.n2a.db.MPersistent)3 EquationSet (gov.sandia.n2a.eqset.EquationSet)3 Variable (gov.sandia.n2a.eqset.Variable)3 AccessVariable (gov.sandia.n2a.language.AccessVariable)3 PanelReference (gov.sandia.n2a.ui.ref.PanelReference)3 Element (org.w3c.dom.Element)3 NamedNodeMap (org.w3c.dom.NamedNodeMap)3 MDoc (gov.sandia.n2a.db.MDoc)2 ParseException (gov.sandia.n2a.language.ParseException)2 AddDoc (gov.sandia.n2a.ui.eq.undo.AddDoc)2 IOException (java.io.IOException)2 TreeMap (java.util.TreeMap)2 IncommensurableException (javax.measure.IncommensurableException)2