use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class CutAction method runInSWT.
/**
* Invokes the copy action followed by the delete command.
* {@inheritDoc}
*/
@Override
public void runInSWT() {
LOGGER.debug("Clipboard cut action invoked...");
// invoke copy action
CopyAction copy = new CopyAction(getEditor());
copy.runInSWT();
NodeContainerEditPart[] nodeParts = copy.getNodeParts();
AnnotationEditPart[] annotationParts = copy.getAnnotationParts();
Collection<EditPart> coll = new ArrayList<EditPart>();
coll.addAll(Arrays.asList(nodeParts));
coll.addAll(Arrays.asList(annotationParts));
DeleteCommand delete = new DeleteCommand(coll, getEditor().getWorkflowManager().get());
// enable undo
getCommandStack().execute(delete);
getEditor().updateActions();
// Give focus to the editor again. Otherwise the actions (selection)
// is not updated correctly.
getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class ExpandMetaNodeAction method runOnNodes.
/**
* Expand metanode!
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
LOGGER.debug("Creating 'Expand MetaNode' job for " + nodeParts.length + " node(s)...");
try {
WorkflowManager manager = getManager();
WorkflowManagerUI metaNode = (WorkflowManagerUI) nodeParts[0].getNodeContainer();
if (!Wrapper.unwrapWFM(metaNode).unlock(new GUIWorkflowCipherPrompt())) {
return;
}
// reset the metanode
if (manager.canResetNode(metaNode.getID())) {
// yes: ask if we can reset, otherwise bail
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK | SWT.CANCEL);
mb.setMessage("Executed Nodes inside Metanode will be reset" + " - are you sure?");
mb.setText("Reset Executed Nodes");
int dialogreturn = mb.open();
if (dialogreturn == SWT.CANCEL) {
return;
}
// perform reset
if (manager.canResetNode(metaNode.getID())) {
manager.resetAndConfigureNode(metaNode.getID());
}
}
String res = manager.canExpandMetaNode(metaNode.getID());
if (res != null) {
throw new IllegalArgumentException(res);
}
ExpandMetaNodeCommand emnc = new ExpandMetaNodeCommand(manager, metaNode.getID(), getEditor());
execute(emnc);
} catch (IllegalArgumentException e) {
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
mb.setMessage("Sorry, expanding Metanode failed: " + e.getMessage());
mb.setText("Expand failed");
mb.open();
}
try {
// Give focus to the editor again. Otherwise the actions (selection)
// is not updated correctly.
getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
} catch (Exception e) {
// ignore
}
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class HideNodeNamesAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public synchronized void runOnNodes(final NodeContainerEditPart[] parts) {
ScrollingGraphicalViewer provider = (ScrollingGraphicalViewer) getEditor().getEditorSite().getSelectionProvider();
if (provider == null) {
return;
}
// get parent of the node parts
WorkflowRootEditPart editorPart = (WorkflowRootEditPart) provider.getRootEditPart().getChildren().get(0);
editorPart.changeHideNodeNames();
for (NodeContainerEditPart edit : getAllParts(NodeContainerEditPart.class)) {
edit.callHideNodeName();
}
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class MetaNodeReconfigureAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
NodeContainerEditPart ep = nodeParts[0];
WorkflowManager metanode = Wrapper.unwrapWFM(ep.getNodeContainer());
if (!metanode.unlock(new GUIWorkflowCipherPrompt())) {
return;
}
ReconfigureMetaNodeWizard wizard = new ReconfigureMetaNodeWizard(ep.getViewer(), metanode);
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
dlg.create();
dlg.open();
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class NewWorkflowXYLayoutPolicy method createChangeConstraintCommand.
/**
* Creates command to move / resize <code>NodeContainer</code> components on
* the project's client area.
*
* {@inheritDoc}
*/
@Override
protected Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
// only rectangular constraints are supported
if (!(constraint instanceof Rectangle)) {
return null;
}
Command command = null;
Rectangle rect = ((Rectangle) constraint).getCopy();
if (child.getModel() instanceof NodeContainerUI) {
NodeContainerUI container = (NodeContainerUI) child.getModel();
if (!Wrapper.wraps(container, NodeContainer.class)) {
// not supported for others than ordinary NodeContainers
return null;
}
NodeContainerEditPart nodePart = (NodeContainerEditPart) child;
command = new ChangeNodeBoundsCommand(Wrapper.unwrapNC(container), (NodeContainerFigure) nodePart.getFigure(), rect);
} else if (child instanceof AbstractWorkflowPortBarEditPart) {
command = new ChangeWorkflowPortBarCommand((AbstractWorkflowPortBarEditPart) child, rect);
} else if (child instanceof AnnotationEditPart) {
AnnotationEditPart annoPart = (AnnotationEditPart) child;
// TODO the workflow annotation could know what its WFM is?
WorkflowRootEditPart root = (WorkflowRootEditPart) annoPart.getParent();
WorkflowManagerUI wm = root.getWorkflowManager();
if (!Wrapper.wraps(wm, WorkflowManager.class)) {
// not supported for others than an ordinary workflow manager
return null;
}
command = new ChangeAnnotationBoundsCommand(Wrapper.unwrapWFM(wm), annoPart, rect);
}
return command;
}
Aggregations