use of gov.sandia.n2a.ui.eq.PanelModel in project n2a by frothga.
the class ChangeDoc method rename.
public void rename(String A, String B) {
// Update database
AppData.models.move(A, B);
MNode doc = AppData.models.child(B);
String id = doc.get("$metadata", "id");
if (!id.isEmpty())
AppData.set(id, doc);
if (AppData.state.get("PanelModel", "lastUsed").equals(A))
AppData.state.set(B, "PanelModel", "lastUsed");
// Update GUI
PanelModel pm = PanelModel.instance;
PanelEquations container = pm.panelEquations;
if (wasShowing) {
// lazy; only loads if not already loaded
container.load(doc);
// If it was already loaded, then need to directly update doc name.
container.root.setUserObject();
}
// Because the change in document name does not directly notify the list model.
pm.panelMRU.renamed();
if (fromSearchPanel) {
selection.set(selection.size() - 1, B);
pm.panelSearch.forceSelection(selection);
} else if (wasShowing)
container.breadcrumbRenderer.requestFocusInWindow();
// else we don't care where focus is
}
use of gov.sandia.n2a.ui.eq.PanelModel in project n2a by frothga.
the class DeleteDoc method undo.
public void undo() {
super.undo();
PanelModel mep = PanelModel.instance;
mep.panelMRU.dontInsert = !wasInMRU;
AddDoc.create(saved.key(), saved, pathAfter, fromSearchPanel, wasShowing);
}
use of gov.sandia.n2a.ui.eq.PanelModel in project n2a by frothga.
the class AddAnnotations method create.
public static void create(List<String> path, int index, MNode saved, NodeFactory factory) {
NodeBase parent = NodeBase.locateNode(path);
if (parent == null)
throw new CannotRedoException();
String blockName = saved.key();
NodeBase n = parent.child(blockName);
if (n != null && !(n instanceof NodeContainer))
throw new CannotRedoException();
NodeContainer node = (NodeContainer) n;
MPart block = (MPart) parent.source.childOrCreate(blockName);
block.merge(saved);
PanelModel mep = PanelModel.instance;
JTree tree = mep.panelEquations.tree;
FilteredTreeModel model = (FilteredTreeModel) tree.getModel();
if (node == null) {
node = (NodeContainer) factory.create(block);
model.insertNodeIntoUnfiltered(node, parent, index);
}
// Replaces all nodes, so they are set to require tab initialization.
node.build();
node.filter(model.filterLevel);
mep.panelEquations.updateVisibility(node.getPath());
}
use of gov.sandia.n2a.ui.eq.PanelModel in project n2a by frothga.
the class AddAnnotations method destroy.
public static void destroy(List<String> path, String blockName) {
NodeBase parent = NodeBase.locateNode(path);
if (parent == null)
throw new CannotUndoException();
PanelModel mep = PanelModel.instance;
JTree tree = mep.panelEquations.tree;
FilteredTreeModel model = (FilteredTreeModel) tree.getModel();
NodeContainer node = (NodeContainer) parent.child(blockName);
TreeNode[] nodePath = node.getPath();
int index = parent.getIndexFiltered(node);
MPart mparent = parent.source;
mparent.clear(blockName);
if (mparent.child(blockName) == null) {
model.removeNodeFromParent(node);
} else // Just exposed an overridden node
{
// Necessary to remove all overridden nodes
node.build();
node.filter(model.filterLevel);
}
mep.panelEquations.updateVisibility(nodePath, index);
}
use of gov.sandia.n2a.ui.eq.PanelModel in project n2a by frothga.
the class AddDoc method create.
public static int create(String name, MNode saved, int index, boolean fromSearchPanel, boolean wasShowing) {
MDoc doc = (MDoc) AppData.models.set(name, "");
doc.merge(saved);
new MPart(doc).clearRedundantOverrides();
AppData.set(doc.get("$metadata", "id"), doc);
PanelModel mep = PanelModel.instance;
mep.panelMRU.insertDoc(doc);
int result = mep.panelSearch.insertDoc(doc, index);
if (wasShowing)
mep.panelEquations.loadRootFromDB(doc);
mep.panelSearch.lastSelection = index;
if (fromSearchPanel) {
if (wasShowing)
mep.panelEquations.tree.clearSelection();
mep.panelSearch.list.setSelectedIndex(result);
mep.panelSearch.list.requestFocusInWindow();
} else {
mep.panelEquations.tree.requestFocusInWindow();
}
return result;
}
Aggregations