NodeDialog option changes due to Input Port Data

#1

Hi,

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:

  1. is it possible to read input port object in NodeModel/configuration() method?
    But in configuration method, there is only the PortSpec.
  2. 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??

Regards
Kefang

0 Likes

#2

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.

Steve

1 Like

#3

Nice answer!!

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 ??

Best
Kefang

0 Likes

#4

Thanks. Yes, that should still work. What you cannot do is use the nice DialogComponents (e.g. DialogComponentBoolean etc), as DataAwareNodeDialogPane subclasses NodeDialogPane rather than DefaultNodeSettingsPane. If you want to use those components, I guess you could look at https://github.com/knime/knime-core/blob/master/org.knime.core/src/eclipse/org/knime/core/node/defaultnodesettings/DefaultNodeSettingsPane.java and reimplement on top of DataAwareNodeDialogPane

Steve

0 Likes

#5

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

Best
Kefang

0 Likes

#6

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)

Steve

1 Like

#7

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.

best,
Gabriel

1 Like

#8

Hi, @gab1one
Since it is based on customized port object, it might not be possible to use DataColumnSpec in my case…

Kefang

0 Likes