Search in sources :

Example 1 with AutoLayoutCommand

use of org.knime.workbench.ui.layout.commands.AutoLayoutCommand in project knime-core by knime.

the class AutoLayoutAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public synchronized void runOnNodes(final NodeContainerEditPart[] parts) {
    ScrollingGraphicalViewer provider = (ScrollingGraphicalViewer) getEditor().getEditorSite().getSelectionProvider();
    if (provider == null) {
        return;
    }
    ArrayList<NodeContainerUI> nodes = null;
    if (parts != null && parts.length > 0) {
        nodes = new ArrayList<NodeContainerUI>(parts.length);
        for (NodeContainerEditPart p : parts) {
            nodes.add(p.getNodeContainer());
        }
    }
    AutoLayoutCommand alc = new AutoLayoutCommand(getManager(), nodes);
    // enables undo
    getCommandStack().execute(alc);
    // update the actions
    getEditor().updateActions();
    // Give focus to the editor again. Otherwise the actions (selection)
    // is not updated correctly.
    getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AutoLayoutCommand(org.knime.workbench.ui.layout.commands.AutoLayoutCommand)

Aggregations

ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)1 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)1 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)1 AutoLayoutCommand (org.knime.workbench.ui.layout.commands.AutoLayoutCommand)1