use of org.knime.core.node.workflow.NodeContainerState in project knime-core by knime.
the class NodeContainerFigure method setStateFromNC.
/**
* @param nc new state of underlying node
*/
public void setStateFromNC(final NodeContainerUI nc) {
boolean isInactive = false;
LoopStatus loopStatus = LoopStatus.NONE;
if (nc instanceof SingleNodeContainerUI) {
SingleNodeContainerUI snc = (SingleNodeContainerUI) nc;
isInactive = snc.isInactive();
if (Wrapper.wraps(snc, NativeNodeContainer.class)) {
NativeNodeContainer nnc = Wrapper.unwrap(snc, NativeNodeContainer.class);
loopStatus = nnc.getLoopStatus();
}
}
NodeContainerState state = nc.getNodeContainerState();
if (!isInactive) {
if (state.isIdle()) {
setStatusAmple();
m_statusFigure.setIcon(RED);
} else if (state.isConfigured()) {
setStatusAmple();
m_statusFigure.setIcon(YELLOW);
} else if (state.isExecuted()) {
setStatusAmple();
m_statusFigure.setIcon(GREEN);
} else if (state.isWaitingToBeExecuted()) {
if (LoopStatus.PAUSED.equals(loopStatus)) {
setProgressBar(ProgressMode.PAUSED);
} else {
setProgressBar(ProgressMode.QUEUED);
}
} else if (state.isExecutionInProgress()) {
setProgressBar(ProgressMode.EXECUTING);
} else {
setStatusAmple();
m_statusFigure.setIcon(INACTIVE);
}
} else {
setStatusAmple();
m_statusFigure.setIcon(INACTIVE);
}
setLoopStatus(loopStatus, state.isExecuted());
repaint();
}
use of org.knime.core.node.workflow.NodeContainerState 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());
}
use of org.knime.core.node.workflow.NodeContainerState in project knime-core by knime.
the class KnimeResourceLabelProvider method getImage.
/**
* {@inheritDoc}
*/
@Override
public Image getImage(final Object element) {
Image img = super.getImage(element);
NodeContainerUI projectNode = null;
if (element instanceof IContainer) {
IContainer container = (IContainer) element;
if (container.exists(WORKFLOW_FILE)) {
// in any case a knime workflow or meta node (!)
projectNode = ProjectWorkflowMap.getWorkflowUI(container.getLocationURI());
if (projectNode == null && !isMetaNode(container)) {
return CLOSED_WORKFLOW;
}
}
if (projectNode == null) {
if (isMetaNode(container)) {
return NODE;
} else if (container.exists(METAINFO_FILE)) {
return WORKFLOW_GROUP;
}
}
} else if (element instanceof NodeContainerUI) {
projectNode = (NodeContainerUI) element;
}
if (projectNode != null) {
if (projectNode instanceof WorkflowManagerUI && // are displayed with state
((WorkflowManagerUI) projectNode).getID().hasSamePrefix(WorkflowManager.ROOT.getID())) {
NodeContainerState state = projectNode.getNodeContainerState();
if (projectNode.getNodeMessage().getMessageType().equals(NodeMessage.Type.ERROR)) {
return ERROR;
}
if (state.isExecuted()) {
return EXECUTED;
} else if (state.isExecutionInProgress()) {
return EXECUTING;
} else {
return CONFIGURED;
}
} else {
return NODE;
}
}
return img;
}
use of org.knime.core.node.workflow.NodeContainerState in project knime-core by knime.
the class SubnodeViewableModel method onNodeStateChange.
/**
* Called by state listener on subnode container.
*/
private void onNodeStateChange() {
NodeContainerState nodeContainerState = m_container.getNodeContainerState();
// (ideally this should be removed but those state changes on the SNC are not protected by the workflow lock)
if (!(m_isReexecuteInProgress.get() || nodeContainerState.isExecutionInProgress())) {
boolean isCallModelChanged = true;
SubnodeViewValue v = getViewValue();
if (nodeContainerState.isExecuted()) {
if (v == null) {
// node was just executed, i.e. view is open and user executes via "run" button in main application
try {
createPageAndValue();
assert m_value != null : "value supposed to be non-null on executed node";
} catch (IOException e) {
LOGGER.error("Creating view failed: " + e.getMessage(), e);
reset();
}
} else {
// reset->configured->executing events were swallowed as part of m_isReexecutionInProgress
if (m_view != null && v.equals(m_view.getLastRetrievedValue())) {
isCallModelChanged = false;
}
}
} else if (v != null) {
// sets #getViewValue to null
reset();
}
if (m_view != null && isCallModelChanged) {
m_view.callViewableModelChanged();
}
}
}
use of org.knime.core.node.workflow.NodeContainerState in project knime-core by knime.
the class SubnodeViewableModel method loadViewValue.
/**
* {@inheritDoc}
*/
@Override
public void loadViewValue(final SubnodeViewValue value, final boolean useAsDefault) {
try {
CheckUtils.checkState(m_container.getNodeContainerState().isExecuted(), "Node needs to be in executed state to apply new view values.");
m_isReexecuteInProgress.set(true);
try (WorkflowLock lock = m_container.getParent().lock()) {
m_spm.applyValidatedValuesAndReexecute(value.getViewValues(), m_container.getID(), useAsDefault);
m_value = value;
} finally {
m_isReexecuteInProgress.set(false);
NodeContainerState state = m_container.getNodeContainerState();
if (state.isExecuted()) {
// the framework refused to reset the node (because there are downstream nodes still executing);
// ignore it.
} else if (!m_container.getNodeContainerState().isExecutionInProgress()) {
// this happens if after the reset the execution can't be triggered, e.g. because #configure of
// a node rejects the current settings -> #onNodeStateChange has been called as part of the reset
// but was ignored due to the m_isReexecuteInProgress = true.
onNodeStateChange();
}
}
} catch (IOException e) {
logErrorAndReset("Loading view values for node " + m_container.getID() + " failed: ", e);
}
}
Aggregations