DialogComponentColumnNameSelection

I'm currently working on a custom Knime node but I'm stuck with the NodeDialog, this is my code:

addDialogComponent(
                new DialogComponentColumnNameSelection(
                        createSettingsModelColumnSelection(),
                        "Select a feature:",
                        0,
                        true,
                        DoubleValue.class
                ));

 

Correct me if I'm wrong but this should get Double-type columns from the input and put them in a dropdownlist, right? Unfortunately it takes Integer-type columns aswell, how do I fix this?

Thx!

Hi!

This is supposed to be a feature. The content of an IntCell can always be represented as a double, thus IntCells implement the DoubleValue interface - and will end up in the list of selectable double columns.

To avoid this, use the constructor taking a ColumnFilter:

new DialogComponentColumnNameSelection(
    createSettingsModelColumnSelection(),
    "Select a feature",
    0,
    true,
    new ColumnFilter() {
        public boolean includeColumn(final DataColumnSpec colSpec) {
            return colSpec.getType().equals(DoubleCell.TYPE);
        }
        public String allFilteredMsg() {
            return "No double columns in input table";
        }
    });
 
Best,
 - Peter.
1 Like