public abstract class DialogComponent extends Object
DefaultNodeSettingsPane
it is easy to add such Component to quickly
assemble a dialog dealing with typical parameters. SettingsModel
associated with it, which stores
the current value of the component and handles all value related operations,
like loading, saving, etc.DefaultNodeSettingsPane
,
SettingsModel
Modifier and Type | Class and Description |
---|---|
protected static class |
DialogComponent.EmptySettingsModel
-------------------------------------------------------------------------
Components deriving from
DialogComponent can use this model if
they don't need or want to store any value (but are only displaying
stuff). |
Modifier and Type | Field and Description |
---|---|
protected static Color |
DEFAULT_BG
default background color for editable components.
|
protected static Color |
DEFAULT_FG
default foreground color for editable components.
|
Constructor and Description |
---|
DialogComponent(SettingsModel model)
Abstract constructor expecting the model for this component.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
checkConfigurabilityBeforeLoad(PortObjectSpec[] specs)
Will be called before the new values are loaded from the NodeSettings
object.
|
protected void |
clearError(JTextField field)
Sets the foreground and background colors of the specified component back
to the normal default colors.
|
JPanel |
getComponentPanel() |
protected PortObjectSpec |
getLastTableSpec(int portID) |
protected PortObjectSpec[] |
getLastTableSpecs() |
SettingsModel |
getModel() |
void |
loadSettingsFrom(NodeSettingsRO settings,
PortObjectSpec[] specs)
Read value(s) of this dialog component from the configuration object.
|
void |
saveSettingsTo(NodeSettingsWO settings)
Write value(s) of this dialog component to the configuration object.
|
void |
setEnabled(boolean enabled)
Deprecated.
rather use the component's
SettingsModel to
enable/disable the component. |
protected abstract void |
setEnabledComponents(boolean enabled)
This method is called by the above (final)
setEnabled(boolean)
method. |
abstract void |
setToolTipText(String text)
Implement this so it sets the tooltip on your component(s).
|
protected void |
showError(JTextField field)
Colors the component red, and registers a listener to the edit field that
sets the colors back to the default as soon as the user edits something
in the field.
|
protected abstract void |
updateComponent()
Read the value from the
SettingsModel and set/display it in the
component. |
protected abstract void |
validateSettingsBeforeSave()
Will be called before the value of the component is saved into the
NodeSettings object.
|
protected static final Color DEFAULT_FG
protected static final Color DEFAULT_BG
public DialogComponent(SettingsModel model)
model
- the value model for this componentpublic JPanel getComponentPanel()
public final SettingsModel getModel()
protected final PortObjectSpec getLastTableSpec(int portID)
portID
- the id of the port the spec should be returned forloadSettingsFrom(NodeSettingsRO, PortObjectSpec[])
protected final PortObjectSpec[] getLastTableSpecs()
loadSettingsFrom(NodeSettingsRO, PortObjectSpec[])
public final void loadSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs) throws NotConfigurableException
settings
- the NodeSettings
to read fromspecs
- the input specsNotConfigurableException
- If there is no chance for the dialog
component to be valid (i.e. the settings are valid), e.g. if
the given specs lack some important columns or column types.protected abstract void updateComponent()
SettingsModel
and set/display it in the
component. (Called after loading new values in the model to ensure they
are transfered into the component.) Implementations should set the new
value(s) in the components, should clear any possible error indications,
and should also take over the enable state.public final void saveSettingsTo(NodeSettingsWO settings) throws InvalidSettingsException
settings
- the NodeSettings
to read fromInvalidSettingsException
- if the user has entered wrong values.protected abstract void validateSettingsBeforeSave() throws InvalidSettingsException
InvalidSettingsException
- if the entered values are invalidprotected abstract void checkConfigurabilityBeforeLoad(PortObjectSpec[] specs) throws NotConfigurableException
specs
- the specs from the input ports.NotConfigurableException
- if the component can't be used due to
inappropriate table specs. (Prevents the dialog from being
opened.)@Deprecated public final void setEnabled(boolean enabled)
SettingsModel
to
enable/disable the component.enabled
- if true
the contained components will be
enabledComponent.setEnabled(boolean)
protected abstract void setEnabledComponents(boolean enabled)
setEnabled(boolean)
method. Derived classes should disable all the contained components in
here.enabled
- the new status of the componentsetEnabled(boolean)
protected void showError(JTextField field)
field
- the component to set the color inprotected void clearError(JTextField field)
field
- the textfield to clear the error forpublic abstract void setToolTipText(String text)
text
- the tool tip text to set.JComponent.setToolTipText(java.lang.String)
KNIME GmbH, Konstanz, Germany
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.