Search in sources :

Example 61 with NodeContainerEditPart

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());
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AnnotationEditPart(org.knime.workbench.editor2.editparts.AnnotationEditPart) WorkflowCopyContent(org.knime.core.node.workflow.WorkflowCopyContent) ClipboardObject(org.knime.workbench.editor2.ClipboardObject) NodeID(org.knime.core.node.workflow.NodeID) WorkflowPersistor(org.knime.core.node.workflow.WorkflowPersistor) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Example 62 with NodeContainerEditPart

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;
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Example 63 with NodeContainerEditPart

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);
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) NodeID(org.knime.core.node.workflow.NodeID) ArrayList(java.util.ArrayList) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) DisconnectMetaNodeLinkCommand(org.knime.workbench.editor2.commands.DisconnectMetaNodeLinkCommand) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Example 64 with NodeContainerEditPart

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;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI)

Example 65 with NodeContainerEditPart

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;
}
Also used : VerifyingCompoundCommand(org.knime.workbench.editor2.commands.VerifyingCompoundCommand) WorkflowEditor(org.knime.workbench.editor2.WorkflowEditor) DeleteCommand(org.knime.workbench.editor2.commands.DeleteCommand) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart)

Aggregations

NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)77 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)28 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)24 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)16 EditPart (org.eclipse.gef.EditPart)15 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)14 Point (org.eclipse.draw2d.geometry.Point)11 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)11 NodeContainer (org.knime.core.node.workflow.NodeContainer)9 NodeID (org.knime.core.node.workflow.NodeID)9 AnnotationEditPart (org.knime.workbench.editor2.editparts.AnnotationEditPart)9 NodeAnnotationEditPart (org.knime.workbench.editor2.editparts.NodeAnnotationEditPart)9 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)9 ArrayList (java.util.ArrayList)8 GUIWorkflowCipherPrompt (org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt)8 MetaNodeTemplateInformation (org.knime.core.node.workflow.MetaNodeTemplateInformation)6 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)6 WorkflowInPortBarEditPart (org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart)6 Rectangle (org.eclipse.draw2d.geometry.Rectangle)5 MessageBox (org.eclipse.swt.widgets.MessageBox)5