use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class PortGraphicalRoleEditPolicy method getConnectionCompleteCommand.
/**
* This tries to complete the command to create a connection.
*
* {@inheritDoc}
*/
@Override
protected Command getConnectionCompleteCommand(final CreateConnectionRequest request) {
// get the previously started command
CreateConnectionCommand cmd = (CreateConnectionCommand) request.getStartCommand();
if (cmd == null) {
return null;
}
EditPart target = request.getTargetEditPart();
if ((target instanceof NodeOutPortEditPart) || target instanceof WorkflowInPortEditPart) {
return null;
} else if (target instanceof NodeInPortEditPart || target instanceof WorkflowOutPortEditPart) {
cmd.setTargetPortID(((AbstractPortEditPart) target).getIndex());
cmd.setTargetNode((ConnectableEditPart) target.getParent());
} else if (target instanceof NodeContainerEditPart) {
if (cmd.wasStartedOnOutPort()) {
cmd.setTargetPortID(-1);
cmd.setTargetNode((NodeContainerEditPart) target);
} else {
cmd.setSourcePortID(-1);
cmd.setSourceNode((NodeContainerEditPart) target);
}
} else {
return null;
}
return cmd;
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart 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.workbench.editor2.editparts.NodeContainerEditPart 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.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class ExecuteAction method internalCalculateEnabled.
/**
* @return always <code>true</code>, as the WFM tries to execute as much
* as possible
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean internalCalculateEnabled() {
NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
// enable if we have at least one executable node in our selection
WorkflowManager wm = getEditor().getWorkflowManager().orElse(null);
if (wm == null) {
// fixes NPE when shutting down
return false;
}
for (int i = 0; i < parts.length; i++) {
NodeContainerUI nc = parts[i].getNodeContainer();
if (wm.canExecuteNode(nc.getID())) {
return true;
}
}
return false;
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class ExecuteAndOpenViewAction method getToolTipText.
/**
* {@inheritDoc}
*/
@Override
public String getToolTipText() {
String tooltip = "Execute the selected node";
NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
if (parts.length == 1) {
NodeContainer nc = Wrapper.unwrapNC(parts[0].getNodeContainer());
if (nc.hasInteractiveView() || nc.getInteractiveWebViews().size() > 0) {
return tooltip + " and open interactive view.";
}
} else {
tooltip += "s";
}
return tooltip + " and open first view.";
}
Aggregations