use of org.knime.core.node.NodeModel in project knime-core by knime.
the class SubNodeContainer method setHideNodeFromDialog.
/**
* Sets a flag on a given {@link DialogNode}, whether or not it is hidden from a containing metanode dialog
* @param id the node to set the flag on
* @param hide true if the node is supposed to be hidden from a containing metanode dialog, false otherwise
* @since 3.5
* @noreference This method is not intended to be referenced by clients.
*/
public void setHideNodeFromDialog(final NodeID id, final boolean hide) {
try (WorkflowLock lock = lock()) {
NativeNodeContainer nnc = m_wfm.getNodeContainer(id, NativeNodeContainer.class, true);
NodeModel model = nnc.getNodeModel();
CheckUtils.checkArgument(model instanceof DialogNode, "Can't set hide in dialog flag on non-dialog nodes.");
DialogNode<?, ?> dn = (DialogNode<?, ?>) model;
if (hide != dn.isHideInDialog()) {
dn.setHideInDialog(hide);
nnc.saveNodeSettingsToDefault();
nnc.setDirty();
}
}
}
use of org.knime.core.node.NodeModel in project knime-core by knime.
the class ScopeEndNode method getFlowContext.
/**
* @return T the scope context put onto the stack by the matching ScopeStartNode
* or null if something was wrong (illegally wired loops should have been
* reported elsewhere - IllegalLoopExecption is only thrown/caught inside core)
* @since 3.1
*/
public default T getFlowContext() {
if (this instanceof NodeModel) {
NodeModel m = (NodeModel) this;
FlowScopeContext fsc = Node.invokePeekFlowScopeContext(m);
try {
return (T) fsc;
} catch (ClassCastException cce) {
return null;
}
} else {
throw new IllegalStateException("Not a " + NodeModel.class.getSimpleName());
}
}
use of org.knime.core.node.NodeModel in project knime-core by knime.
the class WebResourceController method getWizardPageInternal.
/**
* Crates the wizard page for a given node id. Throws exception if no wizard page available.
*
* @param subnodeID the node id for the subnode to retrieve the wizard page for
* @return The wizard page for the given node id
*/
@SuppressWarnings("rawtypes")
protected WizardPageContent getWizardPageInternal(final NodeID subnodeID) {
if (subnodeID == null) {
LOGGER.error("No node ID supplied for creating wizard page");
return null;
}
final WorkflowManager manager = m_manager;
assert manager.isLockedByCurrentThread();
// int currentSubnodeIDSuffix = m_promptedSubnodeIDSuffixes.peek();
// final NodeID subNodeID = toNodeID(currentSubnodeIDSuffix);
SubNodeContainer subNC = manager.getNodeContainer(subnodeID, SubNodeContainer.class, true);
WorkflowManager subWFM = subNC.getWorkflowManager();
Map<NodeID, WizardNode> wizardNodeMap = subWFM.findNodes(WizardNode.class, NOT_HIDDEN_FILTER, false);
LinkedHashMap<NodeIDSuffix, WizardNode> resultMap = new LinkedHashMap<NodeIDSuffix, WizardNode>();
// LinkedHashMap<NodeIDSuffix, WizardNode> errorMap = new LinkedHashMap<NodeIDSuffix, WizardNode>();
LinkedHashMap<NodeIDSuffix, WizardPageNodeInfo> infoMap = new LinkedHashMap<NodeIDSuffix, WizardPageNodeInfo>();
Set<HiLiteHandler> initialHiliteHandlerSet = new HashSet<HiLiteHandler>();
for (Map.Entry<NodeID, WizardNode> entry : wizardNodeMap.entrySet()) {
NodeContainer nc = subWFM.getNodeContainer(entry.getKey());
if ((nc instanceof SingleNodeContainer) && ((SingleNodeContainer) nc).isInactive()) {
// skip nodes in inactive branches
continue;
}
NodeID.NodeIDSuffix idSuffix = NodeID.NodeIDSuffix.create(manager.getID(), entry.getKey());
WizardPageNodeInfo nodeInfo = new WizardPageNodeInfo();
nodeInfo.setNodeName(nc.getName());
nodeInfo.setNodeAnnotation(nc.getNodeAnnotation().toString());
nodeInfo.setNodeState(nc.getInternalState());
nodeInfo.setNodeMessage(nc.getNodeMessage());
infoMap.put(idSuffix, nodeInfo);
if (EXECUTED.equals(nc.getInternalState())) {
// regular viewable nodes need to be executed
resultMap.put(idSuffix, entry.getValue());
}
for (int i = 0; i < nc.getNrInPorts() - 1; i++) {
HiLiteHandler hiLiteHandler = ((NodeModel) entry.getValue()).getInHiLiteHandler(i);
if (hiLiteHandler != null) {
initialHiliteHandlerSet.add(hiLiteHandler);
}
}
}
NodeID.NodeIDSuffix pageID = NodeID.NodeIDSuffix.create(manager.getID(), subWFM.getID());
String pageLayout = subNC.getLayoutJSONString();
if (StringUtils.isEmpty(pageLayout)) {
try {
pageLayout = LayoutUtil.createDefaultLayout(resultMap);
} catch (IOException ex) {
LOGGER.error("Default page layout could not be created: " + ex.getMessage(), ex);
}
}
Set<HiLiteHandler> knownHiLiteHandlers = new HashSet<HiLiteHandler>();
Set<HiLiteTranslator> knownTranslators = new HashSet<HiLiteTranslator>();
Set<HiLiteManager> knownManagers = new HashSet<HiLiteManager>();
for (HiLiteHandler initialHandler : initialHiliteHandlerSet) {
getHiLiteTranslators(initialHandler, knownHiLiteHandlers, knownTranslators, knownManagers);
}
List<HiLiteTranslator> translatorList = knownTranslators.size() > 0 ? new ArrayList<HiLiteTranslator>(knownTranslators) : null;
List<HiLiteManager> managerList = knownManagers.size() > 0 ? new ArrayList<HiLiteManager>(knownManagers) : null;
WizardPageContent page = new WizardPageContent(pageID, resultMap, pageLayout, translatorList, managerList);
page.setInfoMap(infoMap);
return page;
}
use of org.knime.core.node.NodeModel in project knime-core by knime.
the class TableSorterTest method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
NodeFactory<NodeModel> dummyFactory = (NodeFactory) new VirtualParallelizedChunkPortObjectInNodeFactory(new PortType[0]);
m_exec = new ExecutionContext(new DefaultNodeProgressMonitor(), new Node(dummyFactory), SingleNodeContainer.MemoryPolicy.CacheOnDisc, new HashMap<Integer, ContainerTable>());
}
use of org.knime.core.node.NodeModel in project knime-core by knime.
the class OpenInteractiveWebViewAction method run.
@Override
public void run() {
LOGGER.debug("Open Interactive Web Node View " + m_nodeContainer.getName());
NativeNodeContainer nativeNC = m_webViewForNode.getNativeNodeContainer();
try {
@SuppressWarnings("rawtypes") AbstractWizardNodeView view = null;
NodeContext.pushContext(nativeNC);
try {
NodeModel nodeModel = nativeNC.getNodeModel();
view = getConfiguredWizardNodeView(nodeModel);
} finally {
NodeContext.removeLastContext();
}
view.setWorkflowManagerAndNodeID(nativeNC.getParent(), nativeNC.getID());
final String title = m_webViewForNode.getViewName();
Node.invokeOpenView(view, title, OpenViewAction.getAppBoundsAsAWTRec());
} catch (Throwable t) {
final MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR | SWT.OK);
mb.setText("Interactive View cannot be opened");
mb.setMessage("The interactive view cannot be opened for the following reason:\n" + t.getMessage());
mb.open();
LOGGER.error("The interactive view for node '" + nativeNC.getNameWithID() + "' has thrown a '" + t.getClass().getSimpleName() + "'. That is most likely an implementation error.", t);
}
}
Aggregations