use of gov.sandia.n2a.ui.eq.undo.AddDoc in project n2a by frothga.
the class ImportNeuroML method addModel.
public void addModel(MNode m, MNode models, UndoManager um) {
String key = m.key();
models.clear(key);
// model files frequently repeat equations that should be inherited.
for (MNode c : m) {
String inherit = "";
if (c.key().equals("$inherit")) {
inherit = c.get().replace("\"", "");
} else if (c.child("$inherit") != null) {
inherit = c.get("$inherit").replace("\"", "");
}
MNode d = models.child(inherit);
if (d != null)
addModel(d, models, um);
}
AddDoc add = new AddDoc(key, m);
add.wasShowing = false;
um.add(add);
}
use of gov.sandia.n2a.ui.eq.undo.AddDoc in project n2a by frothga.
the class ImportNative method process.
@Override
public void process(File source) {
try (BufferedReader reader = new BufferedReader(new FileReader(source))) {
// dispose of schema line
reader.readLine();
MVolatile doc = new MVolatile();
doc.read(reader);
PanelModel.instance.undoManager.add(new AddDoc(source.getName(), doc));
} catch (IOException e) {
}
}
use of gov.sandia.n2a.ui.eq.undo.AddDoc in project n2a by frothga.
the class PanelEquationTree method addAtSelected.
public void addAtSelected(String type) {
if (locked)
return;
NodeBase selected = getSelected();
if (// only happens when root is null
selected == null) {
PanelModel.instance.undoManager.add(new AddDoc());
// Since root is itself a Part, don't create another one. For anything else, fall through and add it to the newly-created model.
if (type.equals("Part"))
return;
selected = root;
}
NodeBase editMe = selected.add(type, tree, null);
if (editMe != null) {
TreePath path = new TreePath(editMe.getPath());
tree.scrollPathToVisible(path);
tree.setSelectionPath(path);
tree.startEditingAtPath(path);
}
}
use of gov.sandia.n2a.ui.eq.undo.AddDoc in project n2a by frothga.
the class ImportNeuroML method process.
@Override
public void process(File source) {
if (PluginNeuroML.partMap == null)
PluginNeuroML.partMap = new PartMap();
ImportJob job = new ImportJob(PluginNeuroML.partMap);
job.process(source);
job.postprocess();
MNode mainModel = job.models.child(job.modelName);
job.models.clear(job.modelName);
UndoManager um = PanelModel.instance.undoManager;
um.addEdit(new CompoundEdit());
while (job.models.size() > 0) addModel(job.models.iterator().next(), job.models, um);
// after all add operations are completed.
if (mainModel != null)
um.add(new AddDoc(job.modelName, mainModel));
um.endCompoundEdit();
}
Aggregations