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());
}
}
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);
}
}
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);
}
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("\"", "");
}
}
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);
}
}
}
Aggregations