there is a situation. I want to adapt the options in NodeDialog according to input port object. In a scenario, if I choose the option in Dialog, then it gives me available attributes of event log; after choosing attribute, it lists all possible values for this attribute. It needs the interaction with input data.
My questions are:
is it possible to read input port object in NodeModel/configuration() method?
But in configuration method, there is only the PortSpec.
How it works that option parts in NodeDialog in advance knows columns names from one DataTable before NodeModel/execute()? Is it all based on the columnSpec??
Firstly, the answer to 2. - normally, all this happens from the DataTableSpec.
The answer to 1 is more complicated - normally you dont have access to the port object, only the spec of it, in the dialog pane (and never in the configure method in the NodeModel implementation), but if you need it in the node dialog, then there is the DataAwareNodeDialogPane dialog class (see https://github.com/knime/knime-core/blob/master/org.knime.core/src/eclipse/org/knime/core/node/DataAwareNodeDialogPane.java), which is the basis of e.g. the R Snippet node, which needs the full input table ideally.
One more additional question to the configuration in NodeDialog related to FlowVariable. Can we still set the options in NodeDIalog by FlowVariables, if we use the DataAwareNodeDialogPane to set the configuration ??
Hi, Steve
I also found out the conflict to use DialogComponent in it. Thanks for the hint to build on top!!
Ps: will try to check if it works for FlowVariable
I think the KNIME framework handles replacing node settings with flow variables, so pretty sure it should work “out of the box”… (I just checked one of the few nodes where we don’t use the DialogComponent route, and we did nothing special to make flow variable replacement work - https://community.knime.org/svn/nodes4knime/trunk/com.vernalis/com.vernalis.knime.pdbconnector/src/com/vernalis/pdbconnector/nodes/pdbconnector/AbstractPdbConnectorNodeDialog.java - the only ‘special’ thing we did there with flow variables was to force the ‘Test’ button to use the flow variable value if one was supplied in place of the settings in the actual dialog - if you are interested in that, it is in the TestQuery inner class in that link)
Hi @KFDing,
if you only want to know things like the number of distinct values, you can make use of the DataColumnDomain which you can get from the ColumnSpecs of an DataTableSpec.