org.knime.core.node.defaultnodesettings
Class SettingsModelFilterString

java.lang.Object
  extended by org.knime.core.node.defaultnodesettings.SettingsModel
      extended by org.knime.core.node.defaultnodesettings.SettingsModelFilterString

public class SettingsModelFilterString
extends SettingsModel

Implements a settings model that provides include and exclude lists. These lists contain strings. It's currently used e.g. in the column filter component and provides the list of column names to include and exclude.

Author:
Peter Ohl, University of Konstanz

Constructor Summary
SettingsModelFilterString(String configName)
          Constructs a new model with initially empty include and exclude lists.
SettingsModelFilterString(String configName, Collection<String> defaultInclList, Collection<String> defaultExclList)
          Creates a new object holding a list of strings in an exclude list and a list of strings in an include list..
SettingsModelFilterString(String configName, Collection<String> defaultInclList, Collection<String> defaultExclList, boolean keepAll)
          Creates a new object holding a list of strings in an exclude list and a list of strings in an include list..
SettingsModelFilterString(String configName, String[] defaultInclList, String[] defaultExclList)
          Creates a new object holding a list of strings in an exclude list and a list of strings in an include list..
SettingsModelFilterString(String configName, String[] defaultInclList, String[] defaultExclList, boolean keepAll)
          Creates a new object holding a list of strings in an exclude list and a list of strings in an include list.
 
Method Summary
protected  SettingsModelFilterString createClone()
          
protected  String getConfigName()
          
 List<String> getExcludeList()
           
 List<String> getIncludeList()
           
protected  String getModelTypeID()
          Each settings model provides an ID which will be stored with its values.
 boolean isKeepAllSelected()
          Returns the status of the keep-all columns selection box.
protected  void loadSettingsForDialog(NodeSettingsRO settings, PortObjectSpec[] specs)
          Read the value(s) of this settings model from configuration object.
protected  void loadSettingsForModel(NodeSettingsRO settings)
          Read value(s) of this settings model from the configuration object.
protected  void saveSettingsForDialog(NodeSettingsWO settings)
          Write value(s) of this component model to configuration object.
protected  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 setExcludeList(Collection<String> newValue)
          set the value of the stored exclude list.
 void setExcludeList(String[] newValue)
          set the value of the stored exclude list.
 void setIncludeList(Collection<String> newValue)
          set the value of the stored include list.
 void setIncludeList(String[] newValue)
          set the value of the stored include list.
 void setKeepAllSelected(boolean selected)
          Set a new keep all selection state.
 void setNewValues(Collection<String> incl, Collection<String> excl, boolean keepAll)
           
 String toString()
          Derived classes should print their class name plus the config name for nice and useful error messages.
protected  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 org.knime.core.node.defaultnodesettings.SettingsModel
addChangeListener, createCloneWithValidatedValue, dlgLoadSettingsFrom, dlgSaveSettingsTo, isEnabled, loadSettingsFrom, notifyChangeListeners, prependChangeListener, removeChangeListener, saveSettingsTo, setEnabled, validateSettings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SettingsModelFilterString

public SettingsModelFilterString(String configName,
                                 Collection<String> defaultInclList,
                                 Collection<String> defaultExclList)
Creates a new object holding a list of strings in an exclude list and a list of strings in an include list..

Parameters:
configName - the identifier the values are stored with in the NodeSettings object
defaultInclList - the initial value for the include list
defaultExclList - the initial value for the exclude list.

SettingsModelFilterString

public SettingsModelFilterString(String configName,
                                 Collection<String> defaultInclList,
                                 Collection<String> defaultExclList,
                                 boolean keepAll)
Creates a new object holding a list of strings in an exclude list and a list of strings in an include list..

Parameters:
configName - the identifier the values are stored with in the NodeSettings object
defaultInclList - the initial value for the include list
defaultExclList - the initial value for the exclude list.
keepAll - true, if all column should be kept selected

SettingsModelFilterString

public SettingsModelFilterString(String configName,
                                 String[] defaultInclList,
                                 String[] defaultExclList)
Creates a new object holding a list of strings in an exclude list and a list of strings in an include list..

Parameters:
configName - the identifier the values are stored with in the NodeSettings object
defaultInclList - the initial value for the include list
defaultExclList - the initial value for the exclude list.

SettingsModelFilterString

public SettingsModelFilterString(String configName,
                                 String[] defaultInclList,
                                 String[] defaultExclList,
                                 boolean keepAll)
Creates a new object holding a list of strings in an exclude list and a list of strings in an include list.

Parameters:
configName - the identifier the values are stored within the NodeSettings object
defaultInclList - the initial value for the include list
defaultExclList - the initial value for the exclude list.
keepAll - true, if all column should be kept selected

SettingsModelFilterString

public SettingsModelFilterString(String configName)
Constructs a new model with initially empty include and exclude lists.

Parameters:
configName - the identifier the values are stored with in the NodeSettings object
Method Detail

isKeepAllSelected

public boolean isKeepAllSelected()
Returns the status of the keep-all columns selection box.

Returns:
true, if all column should be kept selected

setKeepAllSelected

public void setKeepAllSelected(boolean selected)
Set a new keep all selection state.

Parameters:
selected - if keep all box is selected or not

createClone

protected SettingsModelFilterString createClone()

Specified by:
createClone in class SettingsModel
Returns:
a new instance of the same object with identical state and value(s).

getModelTypeID

protected String getModelTypeID()
Each settings model provides an ID which will be stored with its values. This is to ensure that the same type of model is used to read the values back. Otherwise an assertion will go off. Make sure to provide a unique ID - and to re-use that ID in all compatible models. IntegerModels for example should use the same ID as BoundedInteger models.

Specified by:
getModelTypeID in class SettingsModel
Returns:
a string that identifies all models that are able (and empowered) to read the values stored by this model.

getConfigName

protected String getConfigName()

Specified by:
getConfigName in class SettingsModel
Returns:
the name provided at settings model construction time. The id associated with the value.

loadSettingsForDialog

protected void loadSettingsForDialog(NodeSettingsRO settings,
                                     PortObjectSpec[] specs)
                              throws NotConfigurableException
Read the value(s) of this settings model from configuration object. If the value is not stored in the config, the objects value must remain unchanged. Called only from within the components using this model. If the model is disabled it should not throw the exception.
This method must always notify change listeners!!
NOTE: Do not call this method directly, rather call dlgLoadSettingsFrom

Specified by:
loadSettingsForDialog in class SettingsModel
Parameters:
settings - The NodeSettings to read from.
specs - The input specs.
Throws:
NotConfigurableException - if the specs are not good enough to

saveSettingsForDialog

protected void saveSettingsForDialog(NodeSettingsWO settings)
                              throws InvalidSettingsException
Write value(s) of this component model to configuration object. Called only from within the components using this model.
NOTE: Don't call this method directly, rather use dlgSaveSettingsTo.

Specified by:
saveSettingsForDialog in class SettingsModel
Parameters:
settings - The NodeSettings to read from.
Throws:
InvalidSettingsException - if the user has entered wrong values.

setIncludeList

public void setIncludeList(String[] newValue)
set the value of the stored include list.

Parameters:
newValue - the new value to store as include list.

setIncludeList

public void setIncludeList(Collection<String> newValue)
set the value of the stored include list.

Parameters:
newValue - the new value to store as include list. Can't be null.

setNewValues

public final void setNewValues(Collection<String> incl,
                               Collection<String> excl,
                               boolean keepAll)

getIncludeList

public List<String> getIncludeList()
Returns:
the currently stored include list. Don't modify the list.

setExcludeList

public void setExcludeList(String[] newValue)
set the value of the stored exclude list.

Parameters:
newValue - the new value to store as exclude list.

setExcludeList

public void setExcludeList(Collection<String> newValue)
set the value of the stored exclude list.

Parameters:
newValue - the new value to store as exclude list. Can't be null.

getExcludeList

public List<String> getExcludeList()
Returns:
the currently stored exclude list. Don't modify the list.

loadSettingsForModel

protected void loadSettingsForModel(NodeSettingsRO settings)
                             throws InvalidSettingsException
Read value(s) of this settings model from the configuration object. If the value is not stored in the config, an exception will be thrown.
NOTE: Don't call this method directly, rather call loadSettingsFrom.

Specified by:
loadSettingsForModel in class SettingsModel
Parameters:
settings - The NodeSettings to read from.
Throws:
InvalidSettingsException - if load fails.

saveSettingsForModel

protected void saveSettingsForModel(NodeSettingsWO settings)
Write value(s) of this settings model to configuration object.
NOTE: Don't call this method directly, rather call saveSettingsTo.

Specified by:
saveSettingsForModel in class SettingsModel
Parameters:
settings - The NodeSettings to write into.

validateSettingsForModel

protected void validateSettingsForModel(NodeSettingsRO settings)
                                 throws InvalidSettingsException
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.)

Specified by:
validateSettingsForModel in class SettingsModel
Parameters:
settings - the object to read the value(s) from
Throws:
InvalidSettingsException - if the value(s) in the settings object are invalid.

toString

public String toString()
Derived classes should print their class name plus the config name for nice and useful error messages. Like that,
return getClass().getSimpleName() + " ('" + m_configName + "')";

Specified by:
toString in class SettingsModel


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
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.