de.unihalle.informatik.Alida.dataio.provider.swing.components
Class ALDOperatorParameterPanel

java.lang.Object
  extended by de.unihalle.informatik.Alida.dataio.provider.swing.events.ALDSwingValueChangeReporter
      extended by de.unihalle.informatik.Alida.dataio.provider.swing.components.ALDOperatorParameterPanel
All Implemented Interfaces:
ALDSwingValueChangeListener, java.util.EventListener

public class ALDOperatorParameterPanel
extends ALDSwingValueChangeReporter
implements ALDSwingValueChangeListener

Panel to hold graphical elements for configuring an operator.

Author:
Birgit Moeller

Field Summary
private  boolean debug
          Local debug flag, not accessible from outside of the class.
private  Parameter.ExpertMode displayMode
          Mode for displaying parameters.
private  javax.swing.JPanel mainPanel
          Main panel containing all operator parameters.
protected  ALDOperator operator
          The operator associated with this panel.
private  java.util.LinkedList<ALDOpParameterDescriptor> opParamDescrips
          List of all parameter descriptors associated with the operator.
private  ALDParameterPanel panelOptionalParams
          Sub-panel managing the configuration of optional parameters.
private  ALDParameterPanel panelRequiredParams
          Sub-panel managing the configuration of required parameters.
private  ALDParameterPanel panelSupplementalParams
          Sub-panel managing the configuration of supplemental parameters.
private  boolean topLevelCall
          Flag indicating if panel is used on top level or not.
private  boolean valueChangeEventsDisabled
          Flag to disable event handling (e.g. during resets and updates).
 
Fields inherited from class de.unihalle.informatik.Alida.dataio.provider.swing.events.ALDSwingValueChangeReporter
listenerList
 
Constructor Summary
ALDOperatorParameterPanel(ALDOperator op, Parameter.ExpertMode mode, boolean topLevel, ALDSwingValueChangeListener listener)
          Default constructor.
 
Method Summary
 void changeViewMode(Parameter.ExpertMode mode)
          Switches view mode of the panel.
 void copyConfiguration(ALDOperatorParameterPanel opParameterPanel)
          TODO Function should usually not be required...
private  ALDParameterPanel createInParameterPanel(java.lang.Boolean useRequired, java.lang.Boolean useSupplemental)
          Create a panel with an entry for each input parameter as requested.
 void disableComponents()
           
 void enableComponents()
           
protected  java.lang.Object getDefaultValue(java.lang.Boolean useRequired, java.lang.Boolean useSupplemental, ALDOpParameterDescriptor descr)
          Get the default for a paramter.
 javax.swing.JPanel getJPanel()
          Get access to the main panel.
 void handleValueChangeEvent(ALDSwingValueChangeEvent event)
          Method which is called on event occurence.
private  void initPanel()
          Inits the panel according to formerly specified descriptors.
protected  void registerDescriptor(java.util.LinkedList<ALDOpParameterDescriptor> paramDescriptors, ALDOpParameterDescriptor descr)
          Register a descriptor.
 java.util.HashMap<ALDOpParameterDescriptor,java.lang.String> setNewOperator(ALDOperator op)
          Sets a new operator for the panel.
 java.util.HashMap<ALDOpParameterDescriptor,java.lang.String> setOperatorParameters()
          Retrieve parameter values from GUI and configure operator accordingly.
 boolean setParameterBatchModeInput(java.lang.String paramName)
           
 boolean setParameterLinked(java.lang.String paramName, java.lang.String sourceOp, java.lang.String sourceParamName)
           
 boolean setParameterNotLinked(java.lang.String paramName)
           
 void updateConfigurationStatus(java.util.Collection<java.lang.String> missingParams)
          Marks configurations status of required parameters by color.
protected  void updateOperatorDescriptors()
          Initializes all internal members dealing with operator descriptors.
private  java.util.HashMap<ALDOpParameterDescriptor,java.lang.String> updatePanel()
          Updates panel according to values in currently given operator.
 java.util.HashMap<ALDParameterDescriptor,java.lang.String> validateOperatorParameters(boolean deepValidate)
          Check if operator is ready to run.
 
Methods inherited from class de.unihalle.informatik.Alida.dataio.provider.swing.events.ALDSwingValueChangeReporter
addValueChangeEventListener, fireALDSwingValueChangeEvent, removeValueChangeEventListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

private boolean debug
Local debug flag, not accessible from outside of the class.


displayMode

private Parameter.ExpertMode displayMode
Mode for displaying parameters.

In standard mode the view is restricted to parameters annotated as standard, in advanced mode all annotated parameters of the operator are displayed in the GUI.


mainPanel

private javax.swing.JPanel mainPanel
Main panel containing all operator parameters.


operator

protected ALDOperator operator
The operator associated with this panel.


opParamDescrips

private java.util.LinkedList<ALDOpParameterDescriptor> opParamDescrips
List of all parameter descriptors associated with the operator.


panelOptionalParams

private ALDParameterPanel panelOptionalParams
Sub-panel managing the configuration of optional parameters.


panelRequiredParams

private ALDParameterPanel panelRequiredParams
Sub-panel managing the configuration of required parameters.


panelSupplementalParams

private ALDParameterPanel panelSupplementalParams
Sub-panel managing the configuration of supplemental parameters.


topLevelCall

private boolean topLevelCall
Flag indicating if panel is used on top level or not.

Using the panel on top-level refers to usage with operators directly executed, while non-top-level use refers to usage with operators passed as parameters to other operators. In the second case no deep validation is done, i.e. required parameters are allowed to have null values.


valueChangeEventsDisabled

private boolean valueChangeEventsDisabled
Flag to disable event handling (e.g. during resets and updates).

Constructor Detail

ALDOperatorParameterPanel

public ALDOperatorParameterPanel(ALDOperator op,
                                 Parameter.ExpertMode mode,
                                 boolean topLevel,
                                 ALDSwingValueChangeListener listener)
Default constructor.

Note that value change event listeners added after construction of the object might will events generated during initialization. To avoid that a listener can be handed over to the object upon creation.

Parameters:
op - Operator associated with this panel.
mode - Display mode of the panel.
topLevel - If true, a top-level context is assumed.
listener - Optional value change event listener.
Method Detail

changeViewMode

public void changeViewMode(Parameter.ExpertMode mode)
Switches view mode of the panel.

Parameters:
mode - Desired view mode.

copyConfiguration

public void copyConfiguration(ALDOperatorParameterPanel opParameterPanel)
                       throws ALDDataIOException
TODO Function should usually not be required...

Parameters:
opLink -
b -
Throws:
ALDDataIOException

createInParameterPanel

private ALDParameterPanel createInParameterPanel(java.lang.Boolean useRequired,
                                                 java.lang.Boolean useSupplemental)
Create a panel with an entry for each input parameter as requested.

The latter is determined via useRequired and useSupplemental.

Parameters:
useRequired - If non-null only parameters with a required flag are used; if null the required flag is ignored.
useSupplemental - If non-null use only parameters with supplemental flag, otherwise supplemental flag is ignored.
Returns:
Generated parameter panel.

disableComponents

public void disableComponents()

enableComponents

public void enableComponents()

getDefaultValue

protected java.lang.Object getDefaultValue(java.lang.Boolean useRequired,
                                           java.lang.Boolean useSupplemental,
                                           ALDOpParameterDescriptor descr)
Get the default for a paramter.

Usually the default value of a parameter is fetched directly from the parameter descriptor itself. However, sometimes default values depend on the system state or are taken from external devices (database, GUI). This method allows to customize the reading of default parameters and is intended to be overriden by sub-classes.

Parameters:
useRequired - Ignored.
useSupplemental - Ignored.
descr - Parameter descriptor in question.
Returns:
Default value of requested parameter, might be null.

getJPanel

public javax.swing.JPanel getJPanel()
Get access to the main panel.

Returns:
Reference to the main panel.

handleValueChangeEvent

public void handleValueChangeEvent(ALDSwingValueChangeEvent event)
Description copied from interface: ALDSwingValueChangeListener
Method which is called on event occurence.

Specified by:
handleValueChangeEvent in interface ALDSwingValueChangeListener
Parameters:
event - Event to be handled.

initPanel

private void initPanel()
Inits the panel according to formerly specified descriptors.


registerDescriptor

protected void registerDescriptor(java.util.LinkedList<ALDOpParameterDescriptor> paramDescriptors,
                                  ALDOpParameterDescriptor descr)
Register a descriptor.

Registration is needed to allow the panel to get aware of the parameter. E.g., sometimes actions are required for certain parameter types on initialization, and this can be done within this function.

This method is intended to be overriden to customize parameter handling.

Parameters:
paramDescriptors - List to which the descriptor is added.
descr - Descriptor to be registered.

setNewOperator

public java.util.HashMap<ALDOpParameterDescriptor,java.lang.String> setNewOperator(ALDOperator op)
                                                                            throws ALDDataIOProviderException
Sets a new operator for the panel.

This function is, e.g., called in case of loading a new operator from file.

Parameters:
op - New operator object to be associated with GUI.
Returns:
Null in case of success, otherwise list of parameters that could not be set.
Throws:
ALDDataIOProviderException

setOperatorParameters

public java.util.HashMap<ALDOpParameterDescriptor,java.lang.String> setOperatorParameters()
Retrieve parameter values from GUI and configure operator accordingly.

Returns:
Null if successful, otherwise list with parameters that could not been set.

setParameterBatchModeInput

public boolean setParameterBatchModeInput(java.lang.String paramName)

setParameterLinked

public boolean setParameterLinked(java.lang.String paramName,
                                  java.lang.String sourceOp,
                                  java.lang.String sourceParamName)

setParameterNotLinked

public boolean setParameterNotLinked(java.lang.String paramName)

updateConfigurationStatus

public void updateConfigurationStatus(java.util.Collection<java.lang.String> missingParams)
Marks configurations status of required parameters by color.

A required parameter which is neither properly configured nor has an incoming edge is gets a red label, all others get black labels.


updateOperatorDescriptors

protected void updateOperatorDescriptors()
Initializes all internal members dealing with operator descriptors.


updatePanel

private java.util.HashMap<ALDOpParameterDescriptor,java.lang.String> updatePanel()
Updates panel according to values in currently given operator.

Returns:
List of parameters that could not be updated properly.

validateOperatorParameters

public java.util.HashMap<ALDParameterDescriptor,java.lang.String> validateOperatorParameters(boolean deepValidate)
                                                                                      throws ALDOperatorException
Check if operator is ready to run.

The operator can be run if all GUI elements of required parameters return non-null values, and if furtheron the operator's validate() method returns true.

Parameters:
deepValidate - True if operator has to be validate itself.
Returns:
True, if operator is properly configured.
Throws:
ALDOperatorException