Interface DefaultNodeSettings
- All Superinterfaces:
PersistableSettings
- All Known Implementing Classes:
ImageViewViewSettings,TableViewViewSettings
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:
- It must provide an empty constructor and optionally a constructor that receives a
DefaultNodeSettings.DefaultNodeSettingsContext. - 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
- 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 | Default Widget | Compatible widget annotations |
|---|---|---|
| boolean | Checkbox | |
| byte, int, long, double, float | Number Input | NumberInputWidget |
| String | Text Input | ChoicesWidget (twin-list)TextInputWidgetDateTimeWidgetLocalFileChooserWidgetRichTextInputWidget |
| LocalDate | Date Picker | DateWidget |
| String[] | ChoicesWidget (drop-down) |
|
| Enums(*) | Drop Down | ValueSwitchWidgetRadioButtonsWidget |
| 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 withLayoutGroup
Layouting
Additional annotations can be used to set the layouting for the generated dialog. See thelayout 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
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classA context that holds any available information that might be relevant for creating a new instance ofDefaultNodeSettings. -
Method Summary
Static MethodsModifier and TypeMethodDescriptioncreateDefaultNodeSettingsContext(org.knime.core.node.port.PortObjectSpec[] specs) Method to create a newDefaultNodeSettings.DefaultNodeSettingsContextfrom inputPortObjectSpecs.static <S extends DefaultNodeSettings>
ScreateSettings(Class<S> clazz) Creates a newDefaultNodeSettingsobject of the specified type.static <S extends DefaultNodeSettings>
ScreateSettings(Class<S> clazz, org.knime.core.node.port.PortObjectSpec[] specs) Helper to create a newDefaultNodeSettingsof the specified type.static <S extends DefaultNodeSettings>
ScreateSettings(Class<S> clazz, DefaultNodeSettings.DefaultNodeSettingsContext context) Helper to create a newDefaultNodeSettingsof the specified type.static <S extends DefaultNodeSettings>
SloadSettings(org.knime.core.node.NodeSettingsRO settings, Class<S> clazz) Helper to serialize aDefaultNodeSettingsof specified class from aNodeSettingsRO-object.static voidsaveSettings(Class<? extends DefaultNodeSettings> settingsClass, DefaultNodeSettings settingsObject, org.knime.core.node.NodeSettingsWO settings) Helper to serialize aDefaultNodeSettings-instance into aNodeSettingsWO-object.static voidverifySettings(Class<? extends DefaultNodeSettings> settingsClass) Verifies a given node settings implementation, making sure that it follows the contract ofDefaultNodeSettings, as defined in its documentation.
-
Method Details
-
verifySettings
Verifies a given node settings implementation, making sure that it follows the contract ofDefaultNodeSettings, 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 aDefaultNodeSettingsof specified class from aNodeSettingsRO-object.- Type Parameters:
S-- Parameters:
settings- the settings-object to create the instance fromclazz- 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 newDefaultNodeSettingsof the specified type.- Type Parameters:
S- the type of DefaultNodeSettings- Parameters:
clazz- default node settings classspecs- the specs with which to create the settings. NOTE: can containnullvalues, 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 newDefaultNodeSettingsof the specified type.- Type Parameters:
S- the type of DefaultNodeSettings- Parameters:
clazz- default node settings classcontext- theDefaultNodeSettings.DefaultNodeSettingsContextto be used as constructor argument- Returns:
- a new
DefaultNodeSettings-instance
-
createSettings
Creates a newDefaultNodeSettingsobject 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 aDefaultNodeSettings-instance into aNodeSettingsWO-object.- Parameters:
settingsClass- the setting object's classsettingsObject- the default node settings object to serializesettings- the settings to write to
-
createDefaultNodeSettingsContext
static DefaultNodeSettings.DefaultNodeSettingsContext createDefaultNodeSettingsContext(org.knime.core.node.port.PortObjectSpec[] specs) Method to create a newDefaultNodeSettings.DefaultNodeSettingsContextfrom inputPortObjectSpecs.- Parameters:
specs- the non-null specs with which to create the schema- Returns:
- the newly created context
- Throws:
NullPointerException- if the argument is null
-