use of org.knime.core.node.workflow.SubNodeContainer in project knime-core by knime.
the class DisconnectSubNodeLinkAction method internalCalculateEnabled.
/**
* @return true, if underlying model instance of
* <code>WorkflowManager</code>, otherwise false
*/
@Override
protected boolean internalCalculateEnabled() {
if (getManager().isWriteProtected()) {
return false;
}
NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
for (NodeContainerEditPart p : nodes) {
Object model = p.getModel();
if (Wrapper.wraps(model, SubNodeContainer.class)) {
SubNodeContainer snc = Wrapper.unwrap((UI) model, SubNodeContainer.class);
MetaNodeTemplateInformation i = snc.getTemplateInformation();
if (Role.Link.equals(i.getRole())) {
return true;
}
}
}
return false;
}
use of org.knime.core.node.workflow.SubNodeContainer in project knime-core by knime.
the class DisconnectSubNodeLinkAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
List<NodeID> idList = new ArrayList<NodeID>();
for (NodeContainerEditPart p : nodeParts) {
Object model = p.getModel();
if (Wrapper.wraps(model, SubNodeContainer.class)) {
SubNodeContainer snc = Wrapper.unwrap((UI) model, SubNodeContainer.class);
MetaNodeTemplateInformation i = snc.getTemplateInformation();
if (Role.Link.equals(i.getRole())) {
idList.add(snc.getID());
}
}
}
NodeID[] ids = idList.toArray(new NodeID[idList.size()]);
DisconnectSubNodeLinkCommand disCmd = new DisconnectSubNodeLinkCommand(getManager(), ids);
execute(disCmd);
}
use of org.knime.core.node.workflow.SubNodeContainer in project knime-core by knime.
the class ExecuteAndOpenViewAction method executeAndOpen.
private void executeAndOpen(final NodeContainer cont) {
boolean hasView = cont.getNrViews() > 0;
final InteractiveWebViewsResult interactiveWebViews = cont.getInteractiveWebViews();
hasView |= cont.hasInteractiveView() || interactiveWebViews.size() > 0;
hasView |= OpenSubnodeWebViewAction.hasContainerView(cont);
if (hasView) {
// another listener must be registered at the workflow manager to
// receive also those events from nodes that have just been queued
cont.addNodeStateChangeListener(new NodeStateChangeListener() {
@Override
public void stateChanged(final NodeStateEvent state) {
NodeContainerState ncState = cont.getNodeContainerState();
// removed from the queue)
if ((state.getSource() == cont.getID()) && ncState.isExecuted()) {
// if the node was successfully executed
// start the view
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
// run open view action
IAction viewAction;
if (cont.hasInteractiveView()) {
viewAction = new OpenInteractiveViewAction(cont);
} else if (cont instanceof SubNodeContainer) {
viewAction = new OpenSubnodeWebViewAction((SubNodeContainer) cont);
} else if (interactiveWebViews.size() > 0) {
viewAction = new OpenInteractiveWebViewAction(cont, interactiveWebViews.get(0));
} else {
viewAction = new OpenViewAction(cont, 0);
}
viewAction.run();
}
});
}
if (!ncState.isExecutionInProgress()) {
// in those cases remove the listener
cont.removeNodeStateChangeListener(this);
}
}
});
}
getManager().executeUpToHere(cont.getID());
}
use of org.knime.core.node.workflow.SubNodeContainer in project knime-core by knime.
the class ExpandSubNodeAction method runOnNodes.
/**
* Expand sub node!
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
LOGGER.debug("Creating 'Expand Wrapped Metanode' job for " + nodeParts.length + " node(s)...");
try {
WorkflowManager manager = getManager();
SubNodeContainer subNode = Wrapper.unwrap(nodeParts[0].getNodeContainer(), SubNodeContainer.class);
if (!subNode.getWorkflowManager().unlock(new GUIWorkflowCipherPrompt())) {
return;
}
// reset the metanode
if (manager.canResetNode(subNode.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 Wrapped 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(subNode.getID())) {
manager.resetAndConfigureNode(subNode.getID());
}
}
String res = manager.canExpandSubNode(subNode.getID());
if (res != null) {
throw new IllegalArgumentException(res);
}
ExpandSubNodeCommand emnc = new ExpandSubNodeCommand(manager, subNode.getID(), getEditor());
execute(emnc);
} catch (IllegalArgumentException e) {
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
mb.setMessage("Expanding Wrapped 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.core.node.workflow.SubNodeContainer in project knime-core by knime.
the class OpenSubnodeWebViewAction method hasContainerView.
static boolean hasContainerView(final NodeContainer cont) {
boolean hasView = false;
if (cont instanceof SubNodeContainer) {
SinglePageManager spm = SinglePageManager.of(cont.getParent());
hasView = spm.hasWizardPage(cont.getID());
}
return hasView;
}
Aggregations