use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.
the class OpenMultiDialogAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
NodeID[] nodes = new NodeID[nodeParts.length];
SplitType splitType = SplitType.USER;
for (int i = 0; i < nodeParts.length; i++) {
NodeContainerUI nc = nodeParts[i].getNodeContainer();
nodes[i] = nc.getID();
if (nc instanceof WorkflowManagerUI) {
// one metanode disables splitting
splitType = SplitType.DISALLOWED;
}
}
WrappedMultipleNodeDialog dlg = new WrappedMultipleNodeDialog(Display.getCurrent().getActiveShell(), getManager(), splitType, nodes);
// the dialog applies new settings on OK
dlg.open();
}
use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.
the class ResumeLoopAction method internalCalculateEnabled.
/**
* @return <code>true</code>, if just one loop end node part is selected
* which is executable and a loop is in progress.
*
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean internalCalculateEnabled() {
NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
if (parts.length != 1) {
return false;
}
// enabled if the one selected node is a configured and "in progress"
// LoopEndNode
NodeContainerUI nc = parts[0].getNodeContainer();
if (Wrapper.wraps(nc, NativeNodeContainer.class)) {
NativeNodeContainer nnc = Wrapper.unwrap(nc, NativeNodeContainer.class);
if (nnc.isModelCompatibleTo(LoopEndNode.class) && nnc.getLoopStatus().equals(LoopStatus.PAUSED)) {
return true;
}
}
return false;
}
use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.
the class SelectLoopAction method internalCalculateEnabled.
/**
* @return <code>true</code> if at we have a single node which has a
* dialog
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean internalCalculateEnabled() {
NodeContainerEditPart[] selected = getSelectedParts(NodeContainerEditPart.class);
if (selected.length != 1) {
return false;
}
NodeContainerUI node = selected[0].getNodeContainer();
if (!(node instanceof SingleNodeContainerUI)) {
return false;
}
if (((SingleNodeContainerUI) node).isMemberOfScope()) {
return true;
}
return false;
}
use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.
the class SetNodeDescriptionAction method runOnNodes.
/**
* Opens a dialog and collects the user name and description. After the
* dialog is closed the new name and description are set to the node
* container if applicable.
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
// if more than one node part is selected
if (nodeParts.length != 1) {
LOGGER.debug("Execution denied as more than one node is " + "selected. Not allowed in 'Set description' action.");
return;
}
final NodeContainerUI container = nodeParts[0].getNodeContainer();
try {
Shell parent = PlatformUI.getWorkbench().getDisplay().getActiveShell();
String initialDescr = "";
if (container.getCustomDescription() != null) {
initialDescr = container.getCustomDescription();
}
String dialogTitle = container.getDisplayLabel();
NodeDescriptionDialog dialog = new NodeDescriptionDialog(parent, dialogTitle, initialDescr, // (bugfix 1402)
container.getID());
Point relativeLocation = new Point(nodeParts[0].getFigure().getBounds().x, nodeParts[0].getFigure().getBounds().y);
relativeLocation = parent.toDisplay(relativeLocation);
dialog.create();
dialog.getShell().setLocation(relativeLocation);
int result = dialog.open();
// check if ok was pressed
if (result == Window.OK) {
String description = dialog.getDescription();
container.setCustomDescription(description);
}
} catch (Exception ex) {
LOGGER.error("Could not open node description editor: " + ex.getMessage(), ex);
}
}
use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.
the class StepLoopAction method runOnNodes.
/**
* Perform one step through the entire loop and pause again.
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
LOGGER.debug("Creating 'Step Loop Execution' job for " + nodeParts.length + " node(s)...");
WorkflowManager manager = getManager();
for (NodeContainerEditPart p : nodeParts) {
NodeContainerUI nc = p.getNodeContainer();
if (Wrapper.wraps(nc, NativeNodeContainer.class)) {
NativeNodeContainer nnc = Wrapper.unwrap(nc, NativeNodeContainer.class);
if (nnc.isModelCompatibleTo(LoopEndNode.class) && nnc.getLoopStatus().equals(LoopStatus.PAUSED)) {
manager.resumeLoopExecution(nnc, /*oneStep=*/
true);
} else if (manager.canExecuteNodeDirectly(nc.getID())) {
manager.executeUpToHere(nc.getID());
manager.pauseLoopExecution(nnc);
}
}
}
try {
// Give focus to the editor again. Otherwise the actions (selection)
// is not updated correctly.
getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
} catch (Exception e) {
// ignore
}
}
Aggregations