Search in sources :

Example 1 with NodeStateEvent

use of org.knime.core.node.workflow.NodeStateEvent 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());
}
Also used : IAction(org.eclipse.jface.action.IAction) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerState(org.knime.core.node.workflow.NodeContainerState) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult) NodeStateChangeListener(org.knime.core.node.workflow.NodeStateChangeListener) NodeStateEvent(org.knime.core.node.workflow.NodeStateEvent)

Example 2 with NodeStateEvent

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

the class ProjectWorkflowMap method replace.

/**
 * @param newPath the new path of the {@link IProject} after renaming
 * @param nc the {@link WorkflowManager} with a project new associated name
 * @param oldPath the old {@link IProject} path, under which the opened
 *  {@link WorkflowManager} is stored in the map
 */
public static void replace(final URI newPath, final WorkflowManagerUI nc, final URI oldPath) {
    if (oldPath == null) {
        throw new IllegalArgumentException("Old path must not be null (old is null, new is " + newPath + ")");
    }
    final MapWFKey oldKey = new MapWFKey(oldPath);
    NodeContainerUI removed = PROJECTS.remove(oldKey);
    if (removed == null) {
        throw new IllegalArgumentException("No project registered on URI " + oldPath);
    }
    Set<Object> clientList = WORKFLOW_CLIENTS.remove(oldKey);
    WF_LISTENER.workflowChanged(new WorkflowEvent(WorkflowEvent.Type.NODE_REMOVED, removed.getID(), Wrapper.unwrapNC(removed), null));
    putWorkflowUI(newPath, nc);
    if (clientList != null) {
        WORKFLOW_CLIENTS.put(new MapWFKey(newPath), clientList);
    }
    WF_LISTENER.workflowChanged(new WorkflowEvent(WorkflowEvent.Type.NODE_ADDED, nc.getID(), null, nc));
    NSC_LISTENER.stateChanged(new NodeStateEvent(nc.getID()));
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) WorkflowEvent(org.knime.core.node.workflow.WorkflowEvent) NodeStateEvent(org.knime.core.node.workflow.NodeStateEvent)

Example 3 with NodeStateEvent

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

the class VirtualSubNodeOutputNodeModel method loadValidatedSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
    VirtualSubNodeOutputConfiguration config = new VirtualSubNodeOutputConfiguration(m_numberOfPorts);
    config.loadConfigurationInModel(settings);
    String[] portNames = config.getPortNames();
    // (if sub node container has been set)
    if (m_subNodeContainer != null) {
        for (int i = 0; i < portNames.length; i++) {
            m_subNodeContainer.getOutPort(i + 1).setPortName(portNames[i]);
            m_subNodeContainer.getOutPort(i + 1).stateChanged(new NodeStateEvent(m_subNodeContainer));
        }
    }
    m_configuration = config;
}
Also used : NodeStateEvent(org.knime.core.node.workflow.NodeStateEvent)

Aggregations

NodeStateEvent (org.knime.core.node.workflow.NodeStateEvent)3 IAction (org.eclipse.jface.action.IAction)1 NodeContainerState (org.knime.core.node.workflow.NodeContainerState)1 NodeStateChangeListener (org.knime.core.node.workflow.NodeStateChangeListener)1 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)1 WorkflowEvent (org.knime.core.node.workflow.WorkflowEvent)1 InteractiveWebViewsResult (org.knime.core.node.workflow.action.InteractiveWebViewsResult)1 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)1