Interface DefaultNodeSettings

All Superinterfaces:
PersistableSettings
All Known Implementing Classes:
ImageViewViewSettings, TableViewViewSettings

public interface DefaultNodeSettings extends PersistableSettings
Marker interface for implementations that define a DefaultNodeDialog. The implementations allow one to declare the dialog's settings and widgets in a compact manner. See package.info for some known limitations.

Constructors and fields

The implementations must follow the following conventions:

  1. It must provide an empty constructor and optionally a constructor that receives a DefaultNodeSettings.DefaultNodeSettingsContext.
  2. Fields must be of any of the following supported types:
    • boolean, int, long, double, float, String, char, or byte
    • POJOs, arrays or Collections holding other supported types
  3. Fields should be initialized with proper default values.
    • If no default value is provided, then the Java default is used
    • Make sure that the persistors of non-primitive fields support null values if no proper default is provided

Dialog widgets

All fields with visibility of at least 'package scope' are represented as dialog widgets; they can optionally be annotated with Widget and other widget annotations to supply additional information (e.g. description, domain info, ...). Note that getters of at least 'package scope' will also be represented as dialog widgets. If this is not intended, they can be annotated by an JsonIgnore annotation. The table below lists all the supported type with

  • the default widget being displayed if no specific widget annotation is given
  • the widget annotations that are compatible with the type
Type to Widget Mapping
Type Default Widget Compatible widget annotations
boolean Checkbox
byte, int, long, double, float Number Input NumberInputWidget
String Text Input ChoicesWidget (twin-list)
TextInputWidget
DateTimeWidget
LocalFileChooserWidget
RichTextInputWidget
LocalDate Date Picker DateWidget
String[] ChoicesWidget (drop-down)
Enums(*) Drop Down ValueSwitchWidget
RadioButtonsWidget
Arrays/Collections of objects(**) Array Widget ArrayWidget
ColumnSelection ChoicesWidget (drop-down)
ColumnFilter ChoicesWidget (twin-list)
Credentials Credentials Input (username + password) CredentialsWidget (for customizing username + password)
PasswordWidget (password only)
UsernameWidget (username only)
FileChooser Path file chooser (currently with options "Local File System" and "Custom/KNIME URL")
Any type ButtonWidget (button with backend-side action handler)

(*) Note on enums: In order to control the labels of enum-values to be used within the respective widget (e.g. Value Switch), the Label-annotation can be used.

(**) Note on arrays: To be more precise, the elements of an array need to be serialized to an Object, i.e. arrays of Strings or boxed types will not lead to an array layout. Instead these need to be wrapped inside a class.

Nested settings

For nested fields to be transformed to dialog widgets themselves the containing class has to be annotated with LayoutGroup

Layouting

Additional annotations can be used to set the layouting for the generated dialog. See the layout package for further information. The class of the elements of an arrays are treated as self-contained settings with their own layouting.
Author:
Martin Horn, KNIME GmbH, Konstanz, Germany, Marc Bux, KNIME GmbH, Berlin, Germany
  • Method Details

    • verifySettings

      static void verifySettings(Class<? extends DefaultNodeSettings> settingsClass)
      Verifies a given node settings implementation, making sure that it follows the contract of DefaultNodeSettings, as defined in its documentation.
      Parameters:
      settingsClass - the settings class to verify
    • loadSettings

      static <S extends DefaultNodeSettings> S loadSettings(org.knime.core.node.NodeSettingsRO settings, Class<S> clazz) throws org.knime.core.node.InvalidSettingsException
      Helper to serialize a DefaultNodeSettings of specified class from a NodeSettingsRO-object.
      Type Parameters:
      S -
      Parameters:
      settings - the settings-object to create the instance from
      clazz - default node settings class
      Returns:
      a new DefaultNodeSettings-instance
      Throws:
      org.knime.core.node.InvalidSettingsException - if the settings are invalid
    • createSettings

      static <S extends DefaultNodeSettings> S createSettings(Class<S> clazz, org.knime.core.node.port.PortObjectSpec[] specs)
      Helper to create a new DefaultNodeSettings of the specified type.
      Type Parameters:
      S - the type of DefaultNodeSettings
      Parameters:
      clazz - default node settings class
      specs - the specs with which to create the settings. NOTE: can contain null values, e.g., if input port is not connected
      Returns:
      a new DefaultNodeSettings-instance
    • createSettings

      static <S extends DefaultNodeSettings> S createSettings(Class<S> clazz, DefaultNodeSettings.DefaultNodeSettingsContext context)
      Helper to create a new DefaultNodeSettings of the specified type.
      Type Parameters:
      S - the type of DefaultNodeSettings
      Parameters:
      clazz - default node settings class
      context - the DefaultNodeSettings.DefaultNodeSettingsContext to be used as constructor argument
      Returns:
      a new DefaultNodeSettings-instance
    • createSettings

      static <S extends DefaultNodeSettings> S createSettings(Class<S> clazz)
      Creates a new DefaultNodeSettings object of the specified type.
      Type Parameters:
      S - the type of DefaultNodeSettings
      Parameters:
      clazz - the class of the DefaultNodeSettings type
      Returns:
      a new instance of the DefaultNodeSettingsType
    • saveSettings

      static void saveSettings(Class<? extends DefaultNodeSettings> settingsClass, DefaultNodeSettings settingsObject, org.knime.core.node.NodeSettingsWO settings)
      Helper to serialize a DefaultNodeSettings-instance into a NodeSettingsWO-object.
      Parameters:
      settingsClass - the setting object's class
      settingsObject - the default node settings object to serialize
      settings - the settings to write to
    • createDefaultNodeSettingsContext

      static DefaultNodeSettings.DefaultNodeSettingsContext createDefaultNodeSettingsContext(org.knime.core.node.port.PortObjectSpec[] specs)
      Method to create a new DefaultNodeSettings.DefaultNodeSettingsContext from input PortObjectSpecs.
      Parameters:
      specs - the non-null specs with which to create the schema
      Returns:
      the newly created context
      Throws:
      NullPointerException - if the argument is null