Search in sources :

Example 11 with MNode

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

the class NodeVariable method build.

@Override
public void build() {
    removeAllChildren();
    // but should do little harm.
    if (source.isFromTopDocument())
        enforceOneLine(source);
    setUserObject(source.key() + "=" + getValue());
    for (MNode n : source) {
        if (n.key().startsWith("@"))
            add(new NodeEquation((MPart) n));
    }
    MPart metadata = (MPart) source.child("$metadata");
    if (metadata != null) {
        for (MNode m : metadata) add(new NodeAnnotation((MPart) m));
    }
    MPart references = (MPart) source.child("$reference");
    if (references != null) {
        for (MNode r : references) add(new NodeReference((MPart) r));
    }
}
Also used : MPart(gov.sandia.n2a.eqset.MPart) MNode(gov.sandia.n2a.db.MNode)

Example 12 with MNode

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

the class AddDoc method uniqueName.

/**
 *        Determine unique name in database
 */
public static String uniqueName(String name) {
    MNode models = AppData.models;
    MNode existing = models.child(name);
    if (existing == null)
        return name;
    String result = name;
    name += " ";
    int suffix = 2;
    while (true) {
        // no children, so still a virgin
        if (existing.size() == 0)
            return result;
        result = name + suffix;
        existing = models.child(result);
        if (existing == null)
            return result;
        suffix++;
    }
}
Also used : MNode(gov.sandia.n2a.db.MNode)

Example 13 with MNode

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

the class AddDoc method destroy.

public static int destroy(String name, boolean fromSearchPanel) {
    MNode doc = AppData.models.child(name);
    PanelModel mep = PanelModel.instance;
    mep.panelEquations.recordDeleted(doc);
    mep.panelMRU.removeDoc(doc);
    int result = mep.panelSearch.removeDoc(doc);
    String id = doc.get("$metadata", "id");
    if (!id.isEmpty())
        AppData.set(id, null);
    ((MDoc) doc).delete();
    mep.panelSearch.lastSelection = Math.min(mep.panelSearch.model.size() - 1, result);
    if (fromSearchPanel) {
        mep.panelSearch.list.setSelectedIndex(mep.panelSearch.lastSelection);
        mep.panelSearch.list.requestFocusInWindow();
    } else {
        mep.panelEquations.tree.requestFocusInWindow();
    }
    return result;
}
Also used : PanelModel(gov.sandia.n2a.ui.eq.PanelModel) MNode(gov.sandia.n2a.db.MNode) MDoc(gov.sandia.n2a.db.MDoc)

Example 14 with MNode

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

the class ChangeDoc method rename.

public static void rename(String A, String B) {
    AppData.models.move(A, B);
    PanelModel mep = PanelModel.instance;
    MNode doc = AppData.models.child(B);
    String id = doc.get("$metadata", "id");
    if (!id.isEmpty())
        AppData.set(id, doc);
    // lazy; only loads if not already loaded
    mep.panelEquations.loadRootFromDB(doc);
    NodePart root = mep.panelEquations.root;
    root.setUserObject();
    // likewise, focus only moves if it is not already on equation tree
    mep.panelEquations.tree.requestFocusInWindow();
    mep.panelEquations.tree.setSelectionRow(0);
    mep.panelEquations.model.nodeChanged(root);
    // Because the change in document name does not directly notify the list model.
    mep.panelMRU.renamed();
    mep.panelSearch.list.repaint();
}
Also used : PanelModel(gov.sandia.n2a.ui.eq.PanelModel) NodePart(gov.sandia.n2a.ui.eq.tree.NodePart) MNode(gov.sandia.n2a.db.MNode)

Example 15 with MNode

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

the class PanelRun method saveScripts.

public void saveScripts() {
    MNode scripts = AppData.state.childOrCreate("PanelRun", "scripts");
    scripts.clear();
    for (int i = 0; i < comboScript.getItemCount(); i++) {
        scripts.set(String.valueOf(i), comboScript.getItemAt(i));
    }
}
Also used : 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