Search in sources :

Example 1 with Outsource

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();
}
Also used : Outsource(gov.sandia.n2a.ui.eq.undo.Outsource) UndoManager(gov.sandia.n2a.ui.UndoManager) CompoundEdit(gov.sandia.n2a.ui.CompoundEdit) AddDoc(gov.sandia.n2a.ui.eq.undo.AddDoc) MVolatile(gov.sandia.n2a.db.MVolatile)

Aggregations

MVolatile (gov.sandia.n2a.db.MVolatile)1 CompoundEdit (gov.sandia.n2a.ui.CompoundEdit)1 UndoManager (gov.sandia.n2a.ui.UndoManager)1 AddDoc (gov.sandia.n2a.ui.eq.undo.AddDoc)1 Outsource (gov.sandia.n2a.ui.eq.undo.Outsource)1