org.knime.core.node
Class NodeDialogPane

java.lang.Object
  extended by org.knime.core.node.NodeDialogPane
Direct Known Subclasses:
AccuracyScorerNodeDialog, AggregateOutputNodeDialogPane, AppendedRowsNodeDialog, AppendToTableNodeDialogPane, ARFFReaderNodeDialog, ARFFWriterNodeDialog, BasisFunctionLearnerNodeDialogPane, BasisFunctionPredictorNodeDialog, BinnerNodeDialogPane, BitVectorGeneratorNodeDialog, BWElimFilterNodeDialog, BWElimLoopEndNodeDialog, CaseConvertNodeDialog, CellSplitterNodeDialogPane, ColCombineNodeDialog, ColConvertNodeDialog, CollectionSplitNodeDialogPane, ColorManager2NodeDialogPane, ColumnComparatorNodeDialogPane, ColumnResorterNodeDialog, ConditionalBoxPlotNodeDialog, CSVWriterNodeDialog, DatabaseLoopingNodeDialogPane, DBColumnFilterNodeDialogPane, DBReaderDialogPane, DBRowFilterNodeDialogPane, DBWriterDialogPane, DefaultNodeSettingsPane, DomainNodeDialogPane, EmptyNodeDialogPane, EnrichmentPlotterDialog, EntropyNodeDialogPane, FileReaderNodeDialog, FilterColumnNodeDialog, FuzzyClusterNodeDialog, GroupByNodeDialog, KnnNodeDialogPane, LinRegLearnerNodeDialogPane, LoopEndConditionNodeDialog, LoopEndNodeDialog, LoopStartCountNodeDialog, LoopStartIntervalNodeDialog, LowVarFilterNodeDialogPane, MissingValueHandlingNodeDialog, NewJoinerNodeDialog, NominalValueRowFilterNodeDialog, NormalizerNodeDialog, NumericRowSplitterNodeDialogPane, PartitionNodeDialog, PMCCFilterNodeDialogPane, PolyRegLearnerDialog, RegexSplitNodeDialogPane, RenameNodeDialogPane, ROCNodeDialog, RowFilterNodeDialogPane, RuleEngineNodeDialog, SampleDataNodeDialog, SamplingNodeDialog, SearchReplaceDictNodeDialogPane, ShapeManagerNodeDialogPane, ShuffleNodeDialogPane, SmoteNodeDialog, SorterNodeDialog, SotaNodeDialog, SplitNodeDialog, StringReplacerDialog, StringToNumberNodeDialog, SVMLearnerNodeDialog, ValueCounterNodeDialog, VariableFileReaderNodeDialog, VariableToTableNodeDialogPane, XValidateDialog

public abstract class NodeDialogPane
extends Object

The base class for all node dialogs. It provides a tabbed pane to which the derived dialog can add its own components (method addTab(String, Component). Subclasses will also override saveSettingsTo(NodeSettingsWO) and either loadSettingsFrom(NodeSettingsRO, DataTableSpec[]) or loadSettingsFrom(NodeSettingsRO, PortObjectSpec[]), whereby the latter is only of interest when dealing with custom port types. Failing to override one of the two load methods will result in errors during runtime.

Author:
Thomas Gabriel, University of Konstanz
See Also:
DefaultNodeSettingsPane

Constructor Summary
protected NodeDialogPane()
          Creates a new dialog with the given title.
 
Method Summary
 void addJobMgrTab(NodeContainer.NodeContainerSettings.SplitType splitType)
          Creates and adds the job manager selection tab.
(package private)  void addMiscTab()
          creates and adds the miscellaneous tab that is contained in each dialog of nodes with output ports.
protected  void addTab(String title, Component comp)
          Adds a new component in a new tab to the node's dialog.
protected  int addTabAt(int index, String title, Component comp)
          Adds a new tab at a certain position in the tabbed pane of the node's dialog.
protected  FlowVariableModel createFlowVariableModel(SettingsModelFlowVariableCompatible dc)
          Create model and register a new variable for a specific settings object.
 FlowVariableModel createFlowVariableModel(String[] keys, FlowVariable.Type type)
          Create model and register a new variable for a specific settings entry for a hierarchical settings object.
 FlowVariableModel createFlowVariableModel(String key, FlowVariable.Type type)
          Create model and register a new variable for a specific settings entry (in a non-hierarchical settings object).
 void finishEditingAndSaveSettingsTo(NodeSettingsWO settings)
          Commit spinners and save settings.
 Map<String,FlowVariable> getAvailableFlowVariables()
           
 JPanel getPanel()
           
protected  Component getTab(String title)
          Returns the component of the tab with the specified title.
protected  int getTabIndex(String title)
          Returns the current index of the specified tab.
 void internalLoadSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs, FlowObjectStack foStack)
          Method being called from the node when the dialog shall load the settings from a NodeSettingsRO object.
(package private)  void internalSaveSettingsTo(NodeSettingsWO settings)
          Called from the node when the current settings shall be writing to a NodeSettings object.
 void loadSettingsFrom(InputStream in)
          Loads settings from an input stream (in xml format).
protected  void loadSettingsFrom(NodeSettingsRO settings, DataTableSpec[] specs)
          Invoked before the dialog window is opened.
protected  void loadSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs)
          Invoked before the dialog window is opened.
 void onCancel()
          Override this method in order to react on events induced by the Cancel button from the surrounding dialog.
 void onClose()
          Override this method in order to react on events if the surrounding dialog is supposed to be closed.
 void onOpen()
          Override this method in order to react on events if the surrounding dialog is supposed to be opened.
protected  void removeTab(String name)
          Removes the tab and its component specified by the title from the tabbed pane.
protected  void renameTab(String oldName, String newName)
          Changes the name of an existing tab.
protected abstract  void saveSettingsTo(NodeSettingsWO settings)
          Invoked when the settings need to be applied.
 void saveSettingsTo(OutputStream out)
          Saves current settings to an output stream (in xml format).
protected  void setEnabled(boolean enabled, String tabTitle)
          Sets the enable status of a certain tab in the dialog.
protected  boolean setSelected(String tabTitle)
          Selects the tab with the specified title.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeDialogPane

protected NodeDialogPane()
Creates a new dialog with the given title. The pane holds a tabbed pane ready to take additional components needed by the derived class (#addTab(String,Component)).

Method Detail

addMiscTab

void addMiscTab()
creates and adds the miscellaneous tab that is contained in each dialog of nodes with output ports.


addJobMgrTab

public void addJobMgrTab(NodeContainer.NodeContainerSettings.SplitType splitType)
Creates and adds the job manager selection tab.

Parameters:
splitType - indicates how table splitting is supported in this node

getPanel

public final JPanel getPanel()
Returns:
The underlying dialog panel which keeps the tabbed pane.

getAvailableFlowVariables

public final Map<String,FlowVariable> getAvailableFlowVariables()
Returns:
available flow variables in a non-modifiable map (ensured to be not null) .

internalLoadSettingsFrom

public void internalLoadSettingsFrom(NodeSettingsRO settings,
                                     PortObjectSpec[] specs,
                                     FlowObjectStack foStack)
                              throws NotConfigurableException
Method being called from the node when the dialog shall load the settings from a NodeSettingsRO object. This method will call the abstract loadSettingsFrom method and finally load internals (i.e. memory policy of outports, if any).

Parameters:
settings - To load from.
specs - The DTSs from the inports.
foStack - Flow object stack (contains flow variables)
Throws:
NotConfigurableException - If loadSettingsFrom throws this exception.
See Also:
loadSettingsFrom(NodeSettingsRO, PortObjectSpec[])

internalSaveSettingsTo

void internalSaveSettingsTo(NodeSettingsWO settings)
                      throws InvalidSettingsException
Called from the node when the current settings shall be writing to a NodeSettings object. It will call the abstract saveSettingsTo method and finally write misc settings to the argument object. Misc settings

Parameters:
settings - To write to. Forwarded to abstract saveSettings method.
Throws:
InvalidSettingsException - If any of the writing fails.

loadSettingsFrom

protected void loadSettingsFrom(NodeSettingsRO settings,
                                PortObjectSpec[] specs)
                         throws NotConfigurableException
Invoked before the dialog window is opened. The settings object passed, contains the current settings of the corresponding node model. The model and the dialog must agree on a mutual contract on how settings are stored in the spec. I.e. they must able to read each other's settings.

The implementation must be able to handle invalid or incomplete settings as the model may not have any reasonable values yet (for example when the dialog is opened for the first time). When an empty/invalid settings object is passed the dialog should set default values in its components.

Parameters:
settings - The settings to load into the dialog. Could be an empty object or contain invalid settings. But will never be null.
specs - The input data table specs. Items of the array could be null if no spec is available from the corresponding input port.
Throws:
NotConfigurableException - if the dialog cannot be opened because of real invalid settings or if any preconditions are not fulfilled, e.g. no predecessor node, no nominal column in input table, etc.
See Also:
NodeModel.loadSettingsFrom(NodeSettingsRO)

loadSettingsFrom

protected void loadSettingsFrom(NodeSettingsRO settings,
                                DataTableSpec[] specs)
                         throws NotConfigurableException
Invoked before the dialog window is opened. The settings object passed, contains the current settings of the corresponding node model. The model and the dialog must agree on a mutual contract on how settings are stored in the spec. I.e. they must able to read each other's settings.

The implementation must be able to handle invalid or incomplete settings as the model may not have any reasonable values yet (for example when the dialog is opened for the first time). When an empty/invalid settings object is passed the dialog should set default values in its components.

Parameters:
settings - The settings to load into the dialog. Could be an empty object or contain invalid settings. But will never be null.
specs - The input data table specs. Items of the array could be null if no spec is available from the corresponding input port.
Throws:
NotConfigurableException - if the dialog cannot be opened because of real invalid settings or if any preconditions are not fulfilled, e.g. no predecessor node, no nominal column in input table, etc.
See Also:
NodeModel.loadSettingsFrom(NodeSettingsRO)

onCancel

public void onCancel()
Override this method in order to react on events induced by the Cancel button from the surrounding dialog.


onClose

public void onClose()
Override this method in order to react on events if the surrounding dialog is supposed to be closed.


onOpen

public void onOpen()
Override this method in order to react on events if the surrounding dialog is supposed to be opened.


saveSettingsTo

protected abstract void saveSettingsTo(NodeSettingsWO settings)
                                throws InvalidSettingsException
Invoked when the settings need to be applied. The implementation should write the current user settings from its components into the passed object. It should not check consistency or completeness of the settings - this is part of the model's load method. The only situation this method would throw an exception is when a component contains an invalid value that can't be stored in the settings object.
The settings must be written in a way the model is able to load in, i.e. with the model's keys.

Parameters:
settings - The settings object to write into.
Throws:
InvalidSettingsException - If the settings are not applicable to the model.
See Also:
NodeModel.loadSettingsFrom(NodeSettingsRO)

finishEditingAndSaveSettingsTo

public final void finishEditingAndSaveSettingsTo(NodeSettingsWO settings)
                                          throws InvalidSettingsException
Commit spinners and save settings. It will first call the commitJSpinners method (which traverses all components and commits them if they are instance of JSpinner) and finally call saveSettingsTo(settings).

Derived classes should not be required to call this method. It may change in future versions without prior notice.

Parameters:
settings - The settings object to write into.
Throws:
InvalidSettingsException - If the settings are not applicable to the model.
See Also:
NodeModel.saveSettingsTo(NodeSettingsWO)

saveSettingsTo

public final void saveSettingsTo(OutputStream out)
                          throws InvalidSettingsException,
                                 IOException
Saves current settings to an output stream (in xml format).

Derived classes should not be required to call this method. It may change in future versions without prior notice.

Parameters:
out - To save to.
Throws:
InvalidSettingsException - If the settings can't be save since they are invalid
IOException - If problems writing to the stream occur.
See Also:
loadSettingsFrom(InputStream)

loadSettingsFrom

public final void loadSettingsFrom(InputStream in)
                            throws NotConfigurableException,
                                   IOException
Loads settings from an input stream (in xml format).

Derived classes should not be required to call this method. It may change in future versions without prior notice.

Parameters:
in - to load from.
Throws:
NotConfigurableException - If settings can't be loaded since the most recent input spec does not match the settings (or is not available)
IOException - If problems reading the stream occur.
See Also:
saveSettingsTo(OutputStream)

addTab

protected final void addTab(String title,
                            Component comp)
Adds a new component in a new tab to the node's dialog. Tabs are referenced by their title (to remove or replace them). The tab is added at the right most position (for nodes with outputs this is left of KNIME's default tab though).

If the specified title already exists, this method creates a new unique title for the new tab (and issues a coding problem warning). If the same title with the same component was added before, this method does nothing (but issues a coding problem warning). Also, the same component with a different title is accepted (again with a coding problem warning), the tab that was added before with this component is removed before adding the component again to the dialog.

Parameters:
title - The title of the tab for the given component. Must be unique for this dialog.
comp - The component to add to this dialog's tabbed pane.
Throws:
NullPointerException - If either the title or the component is null.

addTabAt

protected final int addTabAt(int index,
                             String title,
                             Component comp)
Adds a new tab at a certain position in the tabbed pane of the node's dialog. Tabs are referenced by their title (to remove or replace them). If the specified title already exists or if the specified component is already used by another tab this method throws an exception. If the specified index is greater than the number of existing tabs, the tab is added at the right most position. For nodes with outputs this is left of KNIME's "General Node Settings" tab though. The actual index of the new tab after insertion is returned.

NOTE: This method is more restrictive than the addTab(String, Component) method, in that it does not accept duplicate titles or components.

Parameters:
index - the index of the new tab after insertion. Must be greater than or equal to zero.
title - The title of the new tab for the given component. Must be unique for this dialog.
comp - The component to add to this dialog's tabbed pane.
Returns:
the index where the new tab actually has been placed (might be different from the specified argument).
Throws:
NullPointerException - If either the title or the component is null.
IllegalArgumentException - if another tab with the same title or the same component exists already
IndexOutOfBoundsException - if the index is smaller than zero.

renameTab

protected final void renameTab(String oldName,
                               String newName)
Changes the name of an existing tab. Doesn't modify the tab's component or position. It throws an exception, if the specified old name doesn't exist, a tab with the new name already exists, or one of the arguments is null.

Parameters:
oldName - the current name of the tab to be renamed
newName - the new name. Must be unique for this dialog. Must not be null.
Throws:
NullPointerException - if one of the arguments is null

setEnabled

protected final void setEnabled(boolean enabled,
                                String tabTitle)
Sets the enable status of a certain tab in the dialog. This does not affect any component placed in the tab - just the tab itself. Disabled tabs can't be brought to front - but if the tab which is currently visible is disabled it works as before, i.e. all components in the tab can be used/clicked/changed.

Parameters:
enabled - set to true to enable the specified tab, or to false to disable it.
tabTitle - the title of the tab to en/disable
Throws:
IllegalArgumentException - if a tab with the specified tabTitle does not exist.

setSelected

protected final boolean setSelected(String tabTitle)
Selects the tab with the specified title. Selected tabs are in front of all the other tabs and their components are shown.

Parameters:
tabTitle - the title to bring to front,
Returns:
true, if it selected the specified tab, false, if a tab with this title doesn't exist.

getTab

protected final Component getTab(String title)
Returns the component of the tab with the specified title.

Parameters:
title - The name of tab to return the component from.
Returns:
the component of the tab with the given title.

removeTab

protected final void removeTab(String name)
Removes the tab and its component specified by the title from the tabbed pane. Does nothing if a tab with the specified title doesn't exist.

Parameters:
name - The title of the tab to remove.
See Also:
getTabIndex(String), addTabAt(int, String, Component)

getTabIndex

protected final int getTabIndex(String title)
Returns the current index of the specified tab. Or -1 if no tab with the given title exists.

Parameters:
title - of the tab to return the index for.
Returns:
the index of the tab with the specified title.

createFlowVariableModel

public FlowVariableModel createFlowVariableModel(String key,
                                                 FlowVariable.Type type)
Create model and register a new variable for a specific settings entry (in a non-hierarchical settings object). This can serve two purposes: 1) replace the actual value in the settings object by the value of the variable 2) and/or put the current value of the settings object into the specified variable.

Parameters:
key - of corresponding settings object
type - of variable/settings object
Returns:
new FlowVariableModel which is already registered

createFlowVariableModel

public FlowVariableModel createFlowVariableModel(String[] keys,
                                                 FlowVariable.Type type)
Create model and register a new variable for a specific settings entry for a hierarchical settings object. This can serve two purposes: 1) replace the actual value in the settings object by the value of the variable 2) and/or put the current value of the settings object into the specified variable.

Parameters:
keys - hierarchy of keys of corresponding settings object
type - of variable/settings object
Returns:
new FlowVariableModel which is already registered

createFlowVariableModel

protected FlowVariableModel createFlowVariableModel(SettingsModelFlowVariableCompatible dc)
Create model and register a new variable for a specific settings object.

Parameters:
dc - settings object of corresponding DialogComponent
Returns:
new FlowVariableModel which is already registered


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.