Search in sources :

Example 16 with MNode

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

the class PanelRun method viewJob.

public void viewJob() {
    if (displayThread != null) {
        synchronized (displayText) {
            displayThread.stop = true;
            displayThread = null;
        }
    }
    NodeJob job = (NodeJob) displayNode;
    MNode doc = job.source;
    StringBuilder contents = new StringBuilder();
    contents.append("Status:");
    if (job.complete < 0)
        contents.append(" Waiting");
    else if (job.complete == 0)
        contents.append(" Started");
    else if (job.complete > 0 && job.complete < 1)
        contents.append(" " + Math.round(job.complete * 100) + "%");
    else if (job.complete == 1)
        contents.append(" Success");
    else if (job.complete == 3)
        contents.append(" Killed");
    else
        // complete==2, or any value not specified above
        contents.append(" Failed");
    contents.append("\n");
    if (job.dateStarted != null)
        contents.append("  started:  " + job.dateStarted + "\n");
    if (job.dateFinished != null)
        contents.append("  finished: " + job.dateFinished + "\n");
    MNode metadata = doc.child("$metadata");
    // TODO: filter out irrelevant items, like "gui.order"
    if (metadata != null)
        contents.append("\n" + metadata);
    synchronized (displayText) {
        displayText.setText(contents.toString());
        displayText.setCaretPosition(0);
    }
    if (displayPane.getViewport().getView() != displayText)
        displayPane.setViewportView(displayText);
    displayPane.paintImmediately(displayPane.getBounds());
}
Also used : MNode(gov.sandia.n2a.db.MNode)

Example 17 with MNode

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

the class ParserBibtex method parseTags.

public MNode parseTags(BufferedReader reader) throws IOException {
    MNode result = new MVolatile();
    // read to first ,
    String id = "";
    while (true) {
        int c = reader.read();
        if (c < 0 || c == '}') {
            result.set(id.trim());
            return result;
        }
        if (c == ',')
            break;
        id += (char) c;
    }
    // TODO: should this be lower-case as well?
    result.set(id.trim());
    while (parseTag(reader, result)) ;
    return result;
}
Also used : MNode(gov.sandia.n2a.db.MNode) MVolatile(gov.sandia.n2a.db.MVolatile)

Example 18 with MNode

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

the class AddEntry method destroy.

public static int destroy(String id, boolean fromSearchPanel) {
    MNode doc = AppData.references.child(id);
    PanelReference mep = PanelReference.instance;
    mep.panelEntry.recordDeleted(doc);
    mep.panelMRU.removeDoc(doc);
    int result = mep.panelSearch.removeDoc(doc);
    ((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.panelEntry.table.requestFocusInWindow();
    }
    return result;
}
Also used : PanelReference(gov.sandia.n2a.ui.ref.PanelReference) MNode(gov.sandia.n2a.db.MNode) MDoc(gov.sandia.n2a.db.MDoc)

Example 19 with MNode

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

the class ExportJob method standalone.

/**
 *        Process child elements common to all Standalone elements.
 */
public void standalone(MPart source, Element node, List<Element> elements) {
    MNode metadata = source.child("$metadata");
    if (metadata != null) {
        for (MNode m : metadata) {
            if (!((MPart) m).isFromTopDocument())
                continue;
            String key = m.key();
            if (key.startsWith("backend"))
                continue;
            if (key.startsWith("gui"))
                continue;
            // our internal id, not NeuroML id
            if (key.equals("id"))
                continue;
            switch(key) {
                case "description":
                    node.setAttribute("description", m.get());
                    break;
                case "note":
                case "notes":
                    Element notes = addElement("notes", elements);
                    notes.setTextContent(m.get());
                    break;
                default:
                    Element property = addElement("property", elements);
                    property.setAttribute("tag", key);
                    property.setAttribute("value", m.get());
            }
        }
    }
    MNode reference = source.child("$reference");
    if (reference != null) {
    // TODO: emit annotation elements
    }
}
Also used : Element(org.w3c.dom.Element) MNode(gov.sandia.n2a.db.MNode)

Example 20 with MNode

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

the class ImportJob method concentrationModel.

public void concentrationModel(Node node) {
    MNode part = genericPart(node, models.child(modelName));
    // According to comment in NeuroML.xsd, this field should be the same as id.
    part.clear("ion");
    String inherit = node.getNodeName();
    if (// Gets mapped into base concentration model. Here, we fix up the parameters so it will work.
    inherit.endsWith("Traub")) {
        String beta = part.get("beta");
        String phi = part.get("phi");
        part.clear("beta");
        part.clear("phi");
        part.set("tau", "1/" + beta);
        part.set("rho", phi + "*1e-9");
    }
}
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