|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knime.core.node.defaultnodesettings.SettingsModel
public abstract class SettingsModel
Abstract implementation of an encapsulating class holding a (usually rather basic) model of NodeModel Settings. The main motivation for this class is the need to access (read/write) the settings of model at various places (NodeModel, NodeDialog) and the need to unify and simplify this. It also enables the user to register to change-events so that other models/components can be updated accordingly (enable/disable...).
Constructor Summary | |
---|---|
SettingsModel()
Default constructor. |
Method Summary | ||
---|---|---|
void |
addChangeListener(ChangeListener l)
Adds a listener (to the end of the listener list) which is notified, whenever a new values is set in the model or the enable status changes. |
|
protected abstract
|
createClone()
|
|
|
createCloneWithValidatedValue(NodeSettingsRO settings)
Creates a new settings model with identical values for everything except the stored value (also except the list of listeners). |
|
(package private) void |
dlgLoadSettingsFrom(NodeSettingsRO settings,
PortObjectSpec[] specs)
This is the method called from the default dialog component to load the model specific settings from the settings object. |
|
(package private) void |
dlgSaveSettingsTo(NodeSettingsWO settings)
This method is called by the default dialog to save the model specific settings into the settings object. |
|
protected abstract String |
getConfigName()
|
|
protected abstract String |
getModelTypeID()
Each settings model provides an ID which will be stored with its values. |
|
boolean |
isEnabled()
|
|
protected abstract void |
loadSettingsForDialog(NodeSettingsRO settings,
PortObjectSpec[] specs)
Read the value(s) of this settings model from configuration object. |
|
protected abstract void |
loadSettingsForModel(NodeSettingsRO settings)
Read value(s) of this settings model from the configuration object. |
|
void |
loadSettingsFrom(NodeSettingsRO settings)
Read value(s) of this component model from configuration object. |
|
protected void |
notifyChangeListeners()
Notifies all registered listeners about a new model content. |
|
protected void |
prependChangeListener(ChangeListener l)
Adds a listener (to the beginning of the listener list) which is notified, whenever a new values is set in the model or the enable status changes. |
|
void |
removeChangeListener(ChangeListener l)
Remove a specific listener. |
|
protected abstract void |
saveSettingsForDialog(NodeSettingsWO settings)
Write value(s) of this component model to configuration object. |
|
protected abstract void |
saveSettingsForModel(NodeSettingsWO settings)
Write value(s) of this settings model to configuration object. NOTE: Don't call this method directly, rather call saveSettingsTo. |
|
void |
saveSettingsTo(NodeSettingsWO settings)
Write value(s) of this setttings model to configuration object. |
|
void |
setEnabled(boolean enabled)
Sets the enabled status of the model. |
|
abstract String |
toString()
Derived classes should print their class name plus the config name for nice and useful error messages. |
|
void |
validateSettings(NodeSettingsRO settings)
Read the expected values from the settings object, without assigning them to the internal variables! |
|
protected abstract void |
validateSettingsForModel(NodeSettingsRO settings)
Read the expected values from the settings object, without assigning them to the internal variables! (Is not called when the model was disabled at the time the settings were saved.) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SettingsModel()
Method Detail |
---|
public final <T extends SettingsModel> T createCloneWithValidatedValue(NodeSettingsRO settings) throws InvalidSettingsException
T
- the actual typesettings
- the object to read the new model's value(s) from
InvalidSettingsException
- if the settings object passed doesn't
contain a valid value for the newly created settings model.protected abstract <T extends SettingsModel> T createClone()
T
- determined by the implementation class. Must be the same than
the class implementing this method.
protected abstract String getModelTypeID()
protected abstract String getConfigName()
protected abstract void loadSettingsForDialog(NodeSettingsRO settings, PortObjectSpec[] specs) throws NotConfigurableException
settings
- The NodeSettings
to read from.specs
- The input specs.
NotConfigurableException
- if the specs are not good enough tofinal void dlgLoadSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs) throws NotConfigurableException
settings
- The NodeSettings
to read from.specs
- The input specs.
NotConfigurableException
- if the specs are not good enough to load
settings for this modelprotected abstract void saveSettingsForDialog(NodeSettingsWO settings) throws InvalidSettingsException
settings
- The NodeSettings
to read
from.
InvalidSettingsException
- if the user has entered wrong values.final void dlgSaveSettingsTo(NodeSettingsWO settings) throws InvalidSettingsException
settings
- The NodeSettings
to read
from.
InvalidSettingsException
- if the user has entered wrong values.public void addChangeListener(ChangeListener l)
l
- listener to add.protected void prependChangeListener(ChangeListener l)
l
- listener to add.public void removeChangeListener(ChangeListener l)
l
- listener to remove.protected void notifyChangeListeners()
public void setEnabled(boolean enabled)
enabled
- the new enable status. If true the model
saves/validates/loads its value, if false, all these
operations are skipped.public boolean isEnabled()
setEnabled(boolean)
public final void validateSettings(NodeSettingsRO settings) throws InvalidSettingsException
settings
- the object to read the value(s) from
InvalidSettingsException
- if the value(s) in the settings object
are invalid.protected abstract void validateSettingsForModel(NodeSettingsRO settings) throws InvalidSettingsException
settings
- the object to read the value(s) from
InvalidSettingsException
- if the value(s) in the settings object
are invalid.public final void loadSettingsFrom(NodeSettingsRO settings) throws InvalidSettingsException
settings
- The NodeSettings
to read
from.
InvalidSettingsException
- if load fails.protected abstract void loadSettingsForModel(NodeSettingsRO settings) throws InvalidSettingsException
settings
- The NodeSettings
to read
from.
InvalidSettingsException
- if load fails.public final void saveSettingsTo(NodeSettingsWO settings)
settings
- The NodeSettings
to write
into.protected abstract void saveSettingsForModel(NodeSettingsWO settings)
settings
- The NodeSettings
to write
into.public abstract String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |