Search in sources :

Example 1 with NodeID

use of org.knime.core.node.workflow.NodeID in project knime-core by knime.

the class CheckUpdateMetaNodeLinkAction method runInSWT.

/**
 * {@inheritDoc}
 */
@Override
public void runInSWT() {
    List<NodeID> candidateList = getMetaNodesToCheck();
    final Shell shell = Display.getCurrent().getActiveShell();
    IWorkbench wb = PlatformUI.getWorkbench();
    IProgressService ps = wb.getProgressService();
    LOGGER.debug("Checking for updates for " + candidateList.size() + " node link(s)...");
    CheckUpdateRunnableWithProgress runner = new CheckUpdateRunnableWithProgress(getManager(), candidateList);
    try {
        ps.busyCursorWhile(runner);
    } catch (InvocationTargetException e) {
        LOGGER.warn("Failed to check for updates: " + e.getMessage(), e);
        return;
    } catch (InterruptedException e) {
        return;
    }
    List<NodeID> updateList = runner.getUpdateList();
    Status status = runner.getStatus();
    if (status.getSeverity() == IStatus.ERROR || status.getSeverity() == IStatus.WARNING) {
        ErrorDialog.openError(Display.getDefault().getActiveShell(), null, "Errors while checking for " + "updates on node links", status);
        if (candidateList.size() == 1) {
            /* As only one node is selected and its update failed,
                 * there is nothing else to do. */
            return;
        }
    }
    // find nodes that will be reset as part of the update
    int nodesToResetCount = 0;
    for (NodeID id : updateList) {
        NodeContainerTemplate templateNode = (NodeContainerTemplate) getManager().findNodeContainer(id);
        // TODO problematic with through-connections
        if (templateNode.containsExecutedNode()) {
            nodesToResetCount += 1;
        }
    }
    if (updateList.isEmpty()) {
        if (m_showInfoMsgIfNoUpdateAvail) {
            MessageDialog.openInformation(shell, "Node Update", "No updates available");
        } else {
            LOGGER.info("No updates available (" + candidateList.size() + " node link(s))");
        }
    } else {
        boolean isSingle = updateList.size() == 1;
        String title = "Update Node" + (isSingle ? "" : "s");
        StringBuilder messageBuilder = new StringBuilder();
        messageBuilder.append("Update available for ");
        if (isSingle && candidateList.size() == 1) {
            messageBuilder.append("node \"");
            messageBuilder.append(getManager().findNodeContainer(candidateList.get(0)).getNameWithID());
            messageBuilder.append("\".");
        } else if (isSingle) {
            messageBuilder.append("one node.");
        } else {
            messageBuilder.append(updateList.size());
            messageBuilder.append(" nodes.");
        }
        messageBuilder.append("\n\n");
        if (nodesToResetCount > 0) {
            messageBuilder.append("Reset nodes and update now?");
        } else {
            messageBuilder.append("Update now?");
        }
        String message = messageBuilder.toString();
        if (MessageDialog.openQuestion(shell, title, message)) {
            LOGGER.debug("Running update for " + updateList.size() + " node(s): " + updateList);
            execute(new UpdateMetaNodeLinkCommand(getManager(), updateList.toArray(new NodeID[updateList.size()])));
        }
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) UpdateMetaNodeLinkCommand(org.knime.workbench.editor2.commands.UpdateMetaNodeLinkCommand) InvocationTargetException(java.lang.reflect.InvocationTargetException) IWorkbench(org.eclipse.ui.IWorkbench) Shell(org.eclipse.swt.widgets.Shell) NodeContainerTemplate(org.knime.core.node.workflow.NodeContainerTemplate) IProgressService(org.eclipse.ui.progress.IProgressService) NodeID(org.knime.core.node.workflow.NodeID)

Example 2 with NodeID

use of org.knime.core.node.workflow.NodeID in project knime-core by knime.

the class CheckUpdateMetaNodeLinkAction method getMetaNodesToCheck.

protected List<NodeID> getMetaNodesToCheck() {
    List<NodeID> list = new ArrayList<NodeID>();
    for (NodeContainerEditPart p : getSelectedParts(NodeContainerEditPart.class)) {
        NodeContainerUI model = p.getNodeContainer();
        if (Wrapper.wraps(model, NodeContainerTemplate.class)) {
            NodeContainerTemplate tnc = Wrapper.unwrap(model, NodeContainerTemplate.class);
            if (tnc.getTemplateInformation().getRole().equals(Role.Link)) {
                if (!getManager().canUpdateMetaNodeLink(tnc.getID())) {
                    return Collections.emptyList();
                }
                list.add(tnc.getID());
            }
            list.addAll(getNCTemplatesToCheck(tnc));
        }
    }
    return list;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) NodeContainerTemplate(org.knime.core.node.workflow.NodeContainerTemplate) NodeID(org.knime.core.node.workflow.NodeID) ArrayList(java.util.ArrayList)

Example 3 with NodeID

use of org.knime.core.node.workflow.NodeID in project knime-core by knime.

the class MetaNodeCreationFactory method getNewObject.

/**
 * {@inheritDoc}
 */
@Override
public Object getNewObject() {
    NodeID id = m_template.getManager().getID();
    WorkflowManager sourceManager = WorkflowManager.META_NODE_ROOT;
    WorkflowCopyContent.Builder content = WorkflowCopyContent.builder();
    content.setNodeIDs(id);
    return sourceManager.copy(content.build());
}
Also used : WorkflowCopyContent(org.knime.core.node.workflow.WorkflowCopyContent) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID)

Example 4 with NodeID

use of org.knime.core.node.workflow.NodeID in project knime-core by knime.

the class NodeUsageComposite method createNodeGrid.

private void createNodeGrid(final SubNodeContainer subNodeContainer, @SuppressWarnings("rawtypes") final Map<NodeIDSuffix, WizardNode> viewNodes) {
    ScrolledComposite scrollPane = new ScrolledComposite(this, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    scrollPane.setExpandHorizontal(true);
    scrollPane.setExpandVertical(true);
    Composite composite = new Composite(scrollPane, SWT.NONE);
    scrollPane.setContent(composite);
    scrollPane.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
    composite.setLayout(new GridLayout(3, false));
    composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
    // titles
    new Composite(composite, SWT.NONE);
    /* Placeholder */
    Label wizardLabel = new Label(composite, SWT.CENTER);
    FontData fontData = wizardLabel.getFont().getFontData()[0];
    Font boldFont = new Font(Display.getCurrent(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
    wizardLabel.setText("WebPortal /\nWrapped Metanode View");
    wizardLabel.setFont(boldFont);
    Label dialogLabel = new Label(composite, SWT.CENTER);
    dialogLabel.setText("\nWrapped Metanode Dialog");
    dialogLabel.setFont(boldFont);
    // select all checkboxes
    Label selectAllLabel = new Label(composite, SWT.LEFT);
    selectAllLabel.setText("Enable/Disable");
    Button selectAllWizard = createCheckbox(composite);
    Button selectAllDialog = createCheckbox(composite);
    // individual nodes
    for (@SuppressWarnings("rawtypes") Entry<NodeIDSuffix, WizardNode> entry : viewNodes.entrySet()) {
        NodeIDSuffix suffix = entry.getKey();
        NodeID id = suffix.prependParent(subNodeContainer.getWorkflowManager().getID());
        NodeContainer nodeContainer = viewNodes.containsKey(suffix) ? subNodeContainer.getWorkflowManager().getNodeContainer(id) : null;
        createNodeLabelComposite(composite, id, nodeContainer);
        @SuppressWarnings("rawtypes") WizardNode model = entry.getValue();
        Button wizardButton = createCheckbox(composite);
        wizardButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
                checkAllSelected(m_wizardUsageMap, selectAllWizard);
            }
        });
        wizardButton.setToolTipText("Enable/disable for usage in WebPortal and wizard execution.");
        wizardButton.setSelection(!((WizardNode<?, ?>) model).isHideInWizard());
        m_wizardUsageMap.put(id, wizardButton);
        if (model instanceof DialogNode) {
            Button dialogButton = createCheckbox(composite);
            dialogButton.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(final SelectionEvent e) {
                    checkAllSelected(m_dialogUsageMap, selectAllDialog);
                }
            });
            dialogButton.setToolTipText("Enable/disable for usage in wrapped metanode configure dialog.");
            dialogButton.setSelection(!((DialogNode<?, ?>) model).isHideInDialog());
            m_dialogUsageMap.put(id, dialogButton);
        } else {
            new Composite(composite, SWT.NONE);
        /* Placeholder */
        }
    }
    checkAllSelected(m_wizardUsageMap, selectAllWizard);
    checkAllSelected(m_dialogUsageMap, selectAllDialog);
    selectAllWizard.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            selectAllWizard.setGrayed(false);
            for (Button b : m_wizardUsageMap.values()) {
                b.setSelection(selectAllWizard.getSelection());
            }
        }
    });
    if (m_wizardUsageMap.size() < 1) {
        selectAllWizard.setEnabled(false);
    }
    selectAllDialog.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            selectAllDialog.setGrayed(false);
            for (Button b : m_dialogUsageMap.values()) {
                b.setSelection(selectAllDialog.getSelection());
            }
        }
    });
    if (m_dialogUsageMap.size() < 1) {
        selectAllDialog.setEnabled(false);
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FontData(org.eclipse.swt.graphics.FontData) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainer(org.knime.core.node.workflow.NodeContainer) DialogNode(org.knime.core.node.dialog.DialogNode) WizardNode(org.knime.core.node.wizard.WizardNode) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) NodeID(org.knime.core.node.workflow.NodeID) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 5 with NodeID

use of org.knime.core.node.workflow.NodeID in project knime-core by knime.

the class SubnodeLayoutWizard method addPages.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void addPages() {
    setWindowTitle("Node Usage and Layout");
    setDefaultPageImageDescriptor(ImageRepository.getImageDescriptor(KNIMEEditorPlugin.PLUGIN_ID, "icons/layout_55.png"));
    WorkflowManager wfManager = m_subNodeContainer.getWorkflowManager();
    // Map<NodeID, SubNodeContainer> nestedSubnodes = wfManager.findNodes(SubNodeContainer.class, false);
    Map<NodeID, WizardNode> viewNodes = wfManager.findNodes(WizardNode.class, false);
    LinkedHashMap<NodeIDSuffix, WizardNode> resultMap = new LinkedHashMap<>();
    for (Map.Entry<NodeID, WizardNode> entry : viewNodes.entrySet()) {
        NodeID.NodeIDSuffix idSuffix = NodeID.NodeIDSuffix.create(wfManager.getID(), entry.getKey());
        resultMap.put(idSuffix, entry.getValue());
    }
    List<NodeID> nodeIDs = new ArrayList<NodeID>();
    nodeIDs.addAll(viewNodes.keySet());
    /*for (NodeID subnodeID : nestedSubnodes.keySet()) {
            WorkflowManager nestedWFManager = nestedSubnodes.get(subnodeID).getWorkflowManager();
            if (!nestedWFManager.findNodes(WizardNode.class, true).isEmpty()) {
                nodeIDs.add(subnodeID);
            }
        }*/
    Collections.sort(nodeIDs);
    m_page = new SubnodeLayoutJSONEditorPage("Change the layout configuration");
    m_page.setNodes(wfManager, m_subNodeContainer, resultMap);
    addPage(m_page);
}
Also used : WorkflowManager(org.knime.core.node.workflow.WorkflowManager) ArrayList(java.util.ArrayList) WizardNode(org.knime.core.node.wizard.WizardNode) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) LinkedHashMap(java.util.LinkedHashMap) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) NodeID(org.knime.core.node.workflow.NodeID) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

NodeID (org.knime.core.node.workflow.NodeID)71 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)30 NodeContainer (org.knime.core.node.workflow.NodeContainer)17 ArrayList (java.util.ArrayList)12 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)11 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)11 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)10 MetaNodeTemplateInformation (org.knime.core.node.workflow.MetaNodeTemplateInformation)10 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)10 Map (java.util.Map)9 ConnectionID (org.knime.core.node.workflow.ConnectionID)9 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)9 ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)7 WorkflowCopyContent (org.knime.core.node.workflow.WorkflowCopyContent)6 MessageBox (org.eclipse.swt.widgets.MessageBox)5 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)5 File (java.io.File)4 IOException (java.io.IOException)4 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)4 NodeContainerTemplate (org.knime.core.node.workflow.NodeContainerTemplate)4