Data form previous node for custom node dialog

Hi,

I have a custom node which get the table's column name from a previous node. I want to use this columns name in both  "NodeModel .java" and in "NodeDialog.java". So far I could get the column names in "NodeModel .java" without any issue. However, I am not yet able to do the same for "NodeDialog.java". The reason is that I want to use one of the column name from previous node as default value in the "NodeDialog.java".  

 

Any hints in how to do that?

If you inherit from `NodeDialogPane`, the columns names are available through the `DataTableSpec` in the following method:

@Override 
protected void loadSettingsFrom(NodeSettingsRO settings, DataTableSpec[] specs) throws NotConfigurableException { 
  // ... 
}

I reached this point but I when I replace "DefaultNodeSettingsPane" "NodeDialogPane" with how then I can addDialogComponent ?

using:

public class ABCNodeDialog extends NodeDialogPane  { 

I got error "The method addDialogComponent(DialogComponentMultiLineString) is undefined for the type ABCNodeDialog" e.g., :

 protected ABCNodeDialog () {
       super();

addDialogComponent(new DialogComponentMultiLineString(
                  new SettingsModelString(ABCNodeNodeModel.CFGKEY_Name,ABCNodeNodeModel.DEFAULT_Name), "Name:", false, 2, 2));
        

How I can define dialog components as it is in "extends DefaultNodeSettingsPane" and in same time get the table data using "DataTableSpec" ?

 

using:

public class ABCNodeDialog extends NodeDialogPane  { 

I got error "The method addDialogComponent(DialogComponentMultiLineString) is undefined for the type ABCNodeDialog" e.g., :

 protected ABCNodeDialog () {
       super();

addDialogComponent(new DialogComponentMultiLineString(
                  new SettingsModelString(ABCNodeModel.CFGKEY_Name,ABCNodeModel.DEFAULT_Name), "Name:", false, 2, 2));
        

How I can define dialog components as it is in "extends DefaultNodeSettingsPane" and in same time get the table data using "DataTableSpec" ?

 

`DefaultNodeSettingsPane` inherits from the mentioned class. So you'll be able to override the method anyways, wouldn't you?

[edit] Just seen they're final. But there are some `loadAdditionalSettingsFrom` methods which can be overridden according to the docs.

Thanks a lot. Now I can get the column names inside the "NodeDialog" and store them in my defined "ColumnsArray". Unfortunately the "ColumnsArray" values still doesn't show up in the configuration dialog.Only the default values of "ColumnsArray" show up in the configuration dialog. Here part of the code:

public class VizDataConfiguratorNodeDialog extends   DefaultNodeSettingsPane {  

private static final String[] ColumnsArray= new String[] { "a","b"};

 protected VizDataConfiguratorNodeDialog() {
       super();

.

.

.

addDialogComponent(new DialogComponentStringSelection(
                  new SettingsModelString(ABCNodeModel.CFGKEY_Columns, ColumnsArray[0]), "Select Column",
                  Arrays.asList(ColumnsArray)));

.

.

}

 

public void loadAdditionalSettingsFrom(NodeSettingsRO settings, DataTableSpec[] specs) throws NotConfigurableException {

// get the column names and store them in "ColumnsArray"

// tested and it work fine

}

// saveAdditionalSettingsTo:

   @Override
   
        public void saveAdditionalSettingsTo(NodeSettingsWO settings) {
        settings.addStringArray("columnName", BindingColumn);    
         
    } 

}

any hint ?

Mmmh, haven't tested myself, but maybe simply invoke `org.knime.core.node.defaultnodesettings.SettingsModelString.setStringValue(String)` in the `loadAdditionalSettingsFrom` method? (keep the settings model, which you instantiate in the constructor, as a field)

Unfortunately the array still not showing up in configuration dialog. Any further hints ? 

I could solve the problem by moving the DialogComponent under 

 

public void loadAdditionalSettingsFrom(NodeSettingsRO settings, DataTableSpec[] specs) throws NotConfigurableException {

// get the column names and store them in "ColumnsArray"

 .

 .

 

addDialogComponent(new DialogComponentStringSelection(
                  new SettingsModelString(ABCNodeModel.CFGKEY_Columns, ColumnsArray[0]), "Select Column",
                  Arrays.asList(ColumnsArray)));

}

 

hmm but I think there is a better solution?