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));
}
}
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++;
}
}
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;
}
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();
}
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));
}
}
Aggregations