org.knime.core.node.defaultnodesettings
Class DialogComponentStringListSelection

java.lang.Object
  extended by org.knime.core.node.defaultnodesettings.DialogComponent
      extended by org.knime.core.node.defaultnodesettings.DialogComponentStringListSelection

public final class DialogComponentStringListSelection
extends DialogComponent

Provide a standard component for a dialog that allows to select one or more strings from a list of strings.

Author:
Tobias Koetter, University of Konstanz

Nested Class Summary
 
Nested classes/interfaces inherited from class org.knime.core.node.defaultnodesettings.DialogComponent
DialogComponent.EmptySettingsModel
 
Field Summary
 
Fields inherited from class org.knime.core.node.defaultnodesettings.DialogComponent
DEFAULT_BG, DEFAULT_FG
 
Constructor Summary
DialogComponentStringListSelection(SettingsModelStringArray stringModel, String label, Collection<String> list, boolean required, int visibleRowCount)
          Constructor that puts label and select box into panel.
DialogComponentStringListSelection(SettingsModelStringArray stringModel, String label, Collection<String> list, int selectionMode, boolean required, int visibleRowCount)
          Constructor that puts label and select box into panel.
DialogComponentStringListSelection(SettingsModelStringArray stringModel, String label, String... list)
          Constructor that puts label and select box into panel.
DialogComponentStringListSelection(SettingsModelStringArray stringModel, String label, StringIconOption[] list, int selectionMode, boolean required, int visibleRowCount)
          Constructor that puts label and select box into panel.
 
Method Summary
protected  void checkConfigurabilityBeforeLoad(PortObjectSpec[] specs)
          Will be called before the new values are loaded from the NodeSettings object.
 void replaceListItems(Collection<String> newItems, String... select)
          Replaces the list of selectable strings in the component.
 void replaceListItems(StringIconOption[] newItems, String... select)
          Replaces the list of selectable options in the component.
protected  void setEnabledComponents(boolean enabled)
          This method is called by the above (final) DialogComponent.setEnabled(boolean) method.
 void setSizeComponents(int width, int height)
          Sets the preferred size of the internal component.
 void setToolTipText(String text)
          Implement this so it sets the tooltip on your component(s).
 void setVisibleRowCount(int visibleRowCount)
          Sets the preferred number of rows in the list that can be displayed.
protected  void updateComponent()
          Read the value from the DialogComponent.EmptySettingsModel and set/display it in the component.
(package private)  void updateModel(boolean checkRequired)
          Transfers the current value from the component into the model.
protected  void validateSettingsBeforeSave()
          Will be called before the value of the component is saved into the NodeSettings object.
 
Methods inherited from class org.knime.core.node.defaultnodesettings.DialogComponent
clearError, getComponentPanel, getLastTableSpec, getLastTableSpecs, getModel, loadSettingsFrom, saveSettingsTo, setEnabled, showError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DialogComponentStringListSelection

public DialogComponentStringListSelection(SettingsModelStringArray stringModel,
                                          String label,
                                          String... list)
Constructor that puts label and select box into panel. It expects the user to make a selection, thus, at least one item in the list of selectable items is required. When the settings are applied, the model stores all selected strings of the provided list.

Parameters:
stringModel - the model that stores the values for this component.
label - the optional label of the select box. Set to null for none label. Set an empty String for a border.
list - list of items for the select box

DialogComponentStringListSelection

public DialogComponentStringListSelection(SettingsModelStringArray stringModel,
                                          String label,
                                          Collection<String> list,
                                          boolean required,
                                          int visibleRowCount)
Constructor that puts label and select box into panel. When the settings are applied, the model stores all selected strings of the provided list.

Parameters:
stringModel - the model that stores the values for this component.
label - the optional label of the select box. Set to null for none label. Set an empty String for a border.
list - list of items for the select box
required - if at least one item must be selected
visibleRowCount - the number of visible rows

DialogComponentStringListSelection

public DialogComponentStringListSelection(SettingsModelStringArray stringModel,
                                          String label,
                                          Collection<String> list,
                                          int selectionMode,
                                          boolean required,
                                          int visibleRowCount)
Constructor that puts label and select box into panel. When the settings are applied, the model stores all selected strings of the provided list. The following selectionMode values are allowed:

Parameters:
stringModel - the model that stores all selected strings.
label - the optional label of the select box. Set to null for none label. Set an empty String for a border.
list - list (not empty) of strings (not null) for the select box.
selectionMode - an integer specifying the type of selections that are permissible
required - if at least one item must be selected
visibleRowCount - the number of visible rows
Throws:
NullPointerException - if one of the strings in the list is null
IllegalArgumentException - if the list is empty or null.

DialogComponentStringListSelection

public DialogComponentStringListSelection(SettingsModelStringArray stringModel,
                                          String label,
                                          StringIconOption[] list,
                                          int selectionMode,
                                          boolean required,
                                          int visibleRowCount)
Constructor that puts label and select box into panel. When the settings are applied, the model stores all selected strings of the provided list. The following selectionMode values are allowed:

Parameters:
stringModel - the model that stores all selected strings.
label - the optional label of the select box. Set to null for none label. Set an empty String for a border.
list - list (not empty) of StringIconOptions (not null) for the select box.
selectionMode - an integer specifying the type of selections that are permissible
required - if at least one item must be selected
visibleRowCount - the number of visible rows
Throws:
NullPointerException - if one of the strings in the list is null
IllegalArgumentException - if the list is empty or null.
Method Detail

updateComponent

protected void updateComponent()
Read the value from the DialogComponent.EmptySettingsModel 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.

Specified by:
updateComponent in class DialogComponent

updateModel

void updateModel(boolean checkRequired)
           throws InvalidSettingsException
Transfers the current value from the component into the model.

Parameters:
checkRequired - if the method should check the required flag
Throws:
InvalidSettingsException - if a selection is required and no item is selected

validateSettingsBeforeSave

protected void validateSettingsBeforeSave()
                                   throws InvalidSettingsException
Will be called before the value of the component is saved into the NodeSettings object. Can be used to commit values, to update the model and must be used to validate the entered value. NOTE: it will be called even if the model is disabled.

Specified by:
validateSettingsBeforeSave in class DialogComponent
Throws:
InvalidSettingsException - if the entered values are invalid

checkConfigurabilityBeforeLoad

protected void checkConfigurabilityBeforeLoad(PortObjectSpec[] specs)
Will be called before the new values are loaded from the NodeSettings object. Can be used to avoid loading due to missing, invalid, or inappropriate incoming table specs.
Note: This is called even if the component is disabled. Don't reject specs that might be handled by other components

Specified by:
checkConfigurabilityBeforeLoad in class DialogComponent
Parameters:
specs - the specs from the input ports.

setEnabledComponents

protected void setEnabledComponents(boolean enabled)
This method is called by the above (final) DialogComponent.setEnabled(boolean) method. Derived classes should disable all the contained components in here.

Specified by:
setEnabledComponents in class DialogComponent
Parameters:
enabled - the new status of the component
See Also:
DialogComponent.setEnabled(boolean)

setSizeComponents

public void setSizeComponents(int width,
                              int height)
Sets the preferred size of the internal component.

Parameters:
width - The width.
height - The height.

setVisibleRowCount

public void setVisibleRowCount(int visibleRowCount)
Sets the preferred number of rows in the list that can be displayed.

The default value of this property is 8.

Parameters:
visibleRowCount - an integer specifying the preferred number of visible rows

setToolTipText

public void setToolTipText(String text)
Implement this so it sets the tooltip on your component(s).

Specified by:
setToolTipText in class DialogComponent
Parameters:
text - the tool tip text to set.
See Also:
JComponent.setToolTipText(java.lang.String)

replaceListItems

public void replaceListItems(Collection<String> newItems,
                             String... select)
Replaces the list of selectable strings in the component. If select is specified (not null) and it exists in the collection it will be selected. If select is null, the previous value will stay selected (if it exists in the new list).

Parameters:
newItems - new strings for the select box
select - the item to select after the replace. Can be null, in which case the previous selection remains - if it exists in the new list.

replaceListItems

public void replaceListItems(StringIconOption[] newItems,
                             String... select)
Replaces the list of selectable options in the component. If select is specified (not null) and it exists in the collection it will be selected. If select is null, the previous value will stay selected (if it exists in the new list).

Parameters:
newItems - new StringIconOptions for the select box
select - the item to select after the replace. Can be null, in which case the previous selection remains - if it exists in the new list.


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.