Skip to main content
- There are two places to specify a default value (with the settings model, when adding a component, and in the one used in the NodeModel). Which one is used?
- The one specified in the settings model used by the NodeModel. Before the dialog opens, the NodeModel's settings are transfered into the dialog. In some cases the default value in the dialog constructor is used to determine the components width, if it is not set explicitly.
- When the user enters an invalid value some components are colored red, others aren't. Why?
- If you use the same SettingsModel in the dialog and the NodeModel it should work. Especially if you expect numbers in a certain range, make sure you use bounded models in the dialog and the NodeModel - with the same upper and lower bounds! The coloring doesn't work if the NodeModel has a more restricted settings model than the dialog component, if it is the NodeModel that rejects the value.
- Why do I need to instantiate two SettingsModels for each component, why can't I just transfer the object from the NodeModel to the NodeDialog and get the user input stored in there?
- That's how the Nodes in KNIME are designed. The NodeModel doesn't know it's dialog, and vice versa. Values are transfered through settings objects. You need to implement a mechanism to store and load your current settings anyway - we re-use it to transfer the current values into the dialog. Also, the NodeModel must be able to reject invalid/inconsistent values (in the validateSettings method). If we would have only one object, the invalid settings would be set to let the NodeModel validate them and canceling the dialog then would leave these invalid or inconsistent values in the NodeModel.
- How can I influence the width of the components?
- There are some components that calculate their width automatically (like ComboBoxes). Others have a constructor that allow setting the width (in columns/characters) explicitly. If you don't use this constructor, the value in the SettingsModel passed will be used to determine the width.