use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class CopyAction method runInSWT.
/**
* {@inheritDoc}
*/
@Override
public void runInSWT() {
m_nodeParts = getSelectedParts(NodeContainerEditPart.class);
m_annotationParts = getSelectedParts(AnnotationEditPart.class);
NodeID[] ids = new NodeID[m_nodeParts.length];
for (int i = 0; i < m_nodeParts.length; i++) {
NodeContainerEditPart nodeEP = m_nodeParts[i];
ids[i] = nodeEP.getNodeContainer().getID();
}
WorkflowAnnotation[] annotations = AnnotationEditPart.extractWorkflowAnnotations(m_annotationParts);
WorkflowCopyContent.Builder content = WorkflowCopyContent.builder();
content.setNodeIDs(ids);
content.setAnnotation(annotations);
WorkflowPersistor copyPersistor = getManager().copy(false, content.build());
// the information about the nodes is stored in the config XML format
// also used to store workflow information in the kflow files
getEditor().setClipboardContent(new ClipboardObject(copyPersistor));
// update the actions
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 DisconnectMetaNodeLinkAction 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 (model instanceof WorkflowManagerUI) {
WorkflowManagerUI wm = (WorkflowManagerUI) model;
MetaNodeTemplateInformation i = unwrapWFM(wm).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 DisconnectMetaNodeLinkAction 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 (model instanceof WorkflowManagerUI) {
WorkflowManagerUI wm = (WorkflowManagerUI) model;
MetaNodeTemplateInformation i = unwrapWFM(wm).getTemplateInformation();
if (Role.Link.equals(i.getRole())) {
idList.add(wm.getID());
}
}
}
NodeID[] ids = idList.toArray(new NodeID[idList.size()]);
DisconnectMetaNodeLinkCommand disCmd = new DisconnectMetaNodeLinkCommand(getManager(), ids);
execute(disCmd);
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class MetaNodeReconfigureAction method internalCalculateEnabled.
/**
* @return true, if underlying model instance of <code>WorkflowManager</code>, otherwise false
*/
@Override
protected boolean internalCalculateEnabled() {
NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
if (nodes.length != 1) {
return false;
}
NodeContainerUI nc = nodes[0].getNodeContainer();
if (nc instanceof WorkflowManagerUI) {
WorkflowManagerUI metaNode = (WorkflowManagerUI) nc;
return !metaNode.isWriteProtected();
}
return false;
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class NodeConnectionContainerDeleteAction method createDeleteCommand.
/**
* Create one command to remove the selected objects.
*
* @param objects The objects to be deleted.
* @return The command to remove the selected objects.
*/
@Override
public Command createDeleteCommand(final List objects) {
if (objects.isEmpty()) {
return null;
}
if (!(objects.get(0) instanceof EditPart)) {
return null;
}
VerifyingCompoundCommand compoundCmd = new VerifyingCompoundCommand(GEFMessages.DeleteAction_ActionDeleteCommandName);
// will contain nodes -- just used for marking
NodeContainerEditPart[] nodeParts = AbstractNodeAction.filterObjects(NodeContainerEditPart.class, objects);
Optional<WorkflowManager> manager = ((WorkflowEditor) getWorkbenchPart()).getWorkflowManager();
if (manager.isPresent()) {
DeleteCommand cmd = new DeleteCommand(objects, manager.get());
int nodeCount = cmd.getNodeCount();
int connCount = cmd.getConnectionCount();
int annoCount = cmd.getAnnotationCount();
StringBuilder dialogText = new StringBuilder("Do you really want to delete ");
if (nodeCount > 0) {
dialogText.append(nodeCount).append(" node");
dialogText.append(nodeCount > 1 ? "s" : "");
if (annoCount > 0 && connCount > 0) {
dialogText.append(" , ");
} else if (annoCount > 0 || connCount > 0) {
dialogText.append(" and ");
}
}
if (connCount > 0) {
dialogText.append(connCount).append(" connection");
dialogText.append(connCount > 1 ? "s" : "");
dialogText.append(annoCount > 0 ? " and " : "");
}
if (annoCount > 0) {
dialogText.append(annoCount).append(" annotation");
dialogText.append(annoCount > 1 ? "s" : "");
}
dialogText.append("?");
compoundCmd.setDialogDisplayText(dialogText.toString());
// set the parts into the compound command (for unmarking after cancel)
compoundCmd.setNodeParts(Arrays.asList(nodeParts));
compoundCmd.add(cmd);
}
return compoundCmd;
}
Aggregations