use of gov.sandia.n2a.ui.eq.undo.Outsource in project n2a by frothga.
the class PanelEquationTree method outsource.
/**
* Does two things:
* 1) Creates a new top-level model with contents of the given part.
* 2) Modifies the part to inherit from the new model.
*/
public static void outsource(NodePart part) {
if (!part.source.isFromTopDocument())
return;
// Prepare data
MVolatile data = new MVolatile();
// This takes all data, not just visible nodes.
data.merge(part.source);
data.clear("$metadata", "gui", "bounds");
// Create transaction
UndoManager um = MainFrame.instance.undoManager;
um.addEdit(new CompoundEdit());
AddDoc a = new AddDoc(part.source.key(), data);
// Necessary so that focus stays on part. Outsource ctor examines focus.
a.setSilent();
um.apply(a);
um.apply(new Outsource(part, a.name));
um.endCompoundEdit();
}
Aggregations