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

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

public class ALDParameterPanel
extends ALDSwingValueChangeReporter
implements ALDSwingValueChangeListener

Class for configuring sets of parameters via GUI in Alida.

This class provides a panel containing GUI elements to configure all parameters of a set provided at initialization. Note that parameter labels can be marked and unmarked externally. This feature is, e.g., be used during parameter validation.

This panel allows to validate its parameters, i.e. if a certain parameter is declared as required, but reading the parameter results in 'null', the parameter is marked in the GUI.

Author:
moeller

Field Summary
private  java.util.HashMap<ALDParameterDescriptor,ALDSwingComponent> compMap
          Maps a parameter descriptor to its component in the GUI.
private  java.util.HashMap<ALDParameterDescriptor,ALDSwingComponent> compMapLinkBak
           
private  boolean debug
          Local debug flag, not accessible from outside of the class.
private  java.util.HashMap<ALDParameterDescriptor,java.lang.Boolean> isParamLinked
           
private  java.util.HashMap<ALDParameterDescriptor,javax.swing.JLabel> labelMap
          Maps a descriptor to its JLabel component in the panel.
private  javax.swing.JPanel mainPanel
          The main panel containing everything.
private  boolean onlyDisplay
          Flag to disable editability of GUI elements.
private  java.util.HashMap<ALDParameterDescriptor,javax.swing.JPanel> panelMap
          Maps a parameter descriptor to its panel in the GUI.
private  java.util.LinkedList<? extends ALDParameterDescriptor> paramDescriptors
          List of parameter descriptors managed by this panel.
private  java.lang.String titleString
          Optional title string for panel.
private  boolean topLevelCall
          Flag indicating if panel is used on top level or not.
 
Fields inherited from class de.unihalle.informatik.Alida.dataio.provider.swing.events.ALDSwingValueChangeReporter
listenerList
 
Constructor Summary
ALDParameterPanel(java.util.LinkedList<? extends ALDParameterDescriptor> paramDescrips, java.lang.String title, boolean topCall)
          Default constructor.
ALDParameterPanel(java.util.LinkedList<? extends ALDParameterDescriptor> paramDescrips, java.lang.String title, boolean topLevel, boolean noEdit)
          Constructor.
 
Method Summary
private  void buildInputPanel()
          Builds up the input panel.
 void changePanel(ALDParameterDescriptor descr, java.lang.Object value)
          Deprecated. 
 void changeViewMode(Parameter.ExpertMode mode)
          Changes the view mode.
 void copyConfiguration(ALDParameterPanel parameterPanel)
           
 void disableComponents()
           
 void enableComponents()
           
 javax.swing.JPanel getJPanel()
          Method to access associated panel.
 void handleValueChangeEvent(ALDSwingValueChangeEvent event)
          Method which is called on event occurence.
 void markParameter(ALDParameterDescriptor descr)
          Sets label color of parameter to red (e.g. if validation failed).
 void markParameterProbablyConf(ALDParameterDescriptor descr)
           
 java.lang.Object readParameter(ALDParameterDescriptor descr)
          Get value of given parameter from the GUI element.
 void setEnabled(boolean b)
          Function to enable or disable the panel.
 void setParameter(ALDParameterDescriptor descr, java.lang.Object value)
          Set value of given parameter, i.e. pass the value to GUI component.
 boolean setParamExternallyConfigured(ALDParameterDescriptor desc, java.lang.String val)
           
 boolean setParamNotExternallyConfigured(ALDParameterDescriptor desc)
           
 void unmarkAllParameters()
          Sets label colors of all parameter to black and of all links to blue.
 void unmarkParameter(ALDParameterDescriptor descr)
          Sets label color of parameter to black or of link to blue (e.g. if validation successful).
 void updateOperatorDescriptors(java.util.LinkedList<ALDOpParameterDescriptor> newDescr)
           
 java.util.HashMap<ALDParameterDescriptor,java.lang.String> validateParameters()
          Check if all GUI elements can deliver a proper (non-null) value.
 
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

compMap

private java.util.HashMap<ALDParameterDescriptor,ALDSwingComponent> compMap
Maps a parameter descriptor to its component in the GUI.


compMapLinkBak

private java.util.HashMap<ALDParameterDescriptor,ALDSwingComponent> compMapLinkBak

debug

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


isParamLinked

private java.util.HashMap<ALDParameterDescriptor,java.lang.Boolean> isParamLinked

labelMap

private java.util.HashMap<ALDParameterDescriptor,javax.swing.JLabel> labelMap
Maps a descriptor to its JLabel component in the panel.


mainPanel

private javax.swing.JPanel mainPanel
The main panel containing everything.


onlyDisplay

private boolean onlyDisplay
Flag to disable editability of GUI elements.

If the flag is set true, parameter editing is not possible, i.e. the graphical elements in the window are not editable.


panelMap

private java.util.HashMap<ALDParameterDescriptor,javax.swing.JPanel> panelMap
Maps a parameter descriptor to its panel in the GUI.


paramDescriptors

private java.util.LinkedList<? extends ALDParameterDescriptor> paramDescriptors
List of parameter descriptors managed by this panel.


titleString

private java.lang.String titleString
Optional title string for panel.


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. Consequently missing parameters are only marked orange in the GUI.

Constructor Detail

ALDParameterPanel

public ALDParameterPanel(java.util.LinkedList<? extends ALDParameterDescriptor> paramDescrips,
                         java.lang.String title,
                         boolean topCall)
Default constructor.

Parameters:
paramDescrips - List of parameter descriptors to manage.
title - Title of panel.
topCall - If true, null returns are forbidden.

ALDParameterPanel

public ALDParameterPanel(java.util.LinkedList<? extends ALDParameterDescriptor> paramDescrips,
                         java.lang.String title,
                         boolean topLevel,
                         boolean noEdit)
Constructor.

Parameters:
paramDescrips - List of parameter descriptors to manage.
title - Title of panel.
topLevel - If true, null returns are forbidden.
noEdit - If true, elements cannot be edited.
Method Detail

buildInputPanel

private void buildInputPanel()
Builds up the input panel.


changePanel

@Deprecated
public void changePanel(ALDParameterDescriptor descr,
                                   java.lang.Object value)
Deprecated. 

Replace the panel of given parameter to insert a link.

Parameters:
descr - Descriptor of parameter.
value - Default value of the new panel.
editorFrame -

changeViewMode

public void changeViewMode(Parameter.ExpertMode mode)
Changes the view mode.

There are the view modes 'standard' and 'advanced' available in the GUI. In standard mode only the parameters annotated as standard are visible, while in advanced mode all parameters are visible.

Parameters:
mode - Desired display mode.

copyConfiguration

public void copyConfiguration(ALDParameterPanel parameterPanel)
                       throws ALDDataIOException
Throws:
ALDDataIOException

disableComponents

public void disableComponents()

enableComponents

public void enableComponents()

getJPanel

public javax.swing.JPanel getJPanel()
Method to access associated 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.

markParameter

public void markParameter(ALDParameterDescriptor descr)
Sets label color of parameter to red (e.g. if validation failed).

Parameters:
descr - Descriptor of parameter to mark.

markParameterProbablyConf

public void markParameterProbablyConf(ALDParameterDescriptor descr)

readParameter

public java.lang.Object readParameter(ALDParameterDescriptor descr)
                               throws ALDDataIOProviderException
Get value of given parameter from the GUI element.

Parameters:
descr - Descriptor of desired parameter
Returns:
Value of parameter, might be null.
Throws:
ALDDataIOException
ALDDataIOProviderException

setEnabled

public void setEnabled(boolean b)
Function to enable or disable the panel.

Parameters:
b - If true, panel is enabled, otherwise components are disabled.

setParameter

public void setParameter(ALDParameterDescriptor descr,
                         java.lang.Object value)
                  throws ALDDataIOProviderException
Set value of given parameter, i.e. pass the value to GUI component.

Parameters:
descr - Descriptor of parameter to be updated.
value - New value of parameter to be displayed.
Throws:
ALDDataIOException
ALDDataIOProviderException

setParamExternallyConfigured

public boolean setParamExternallyConfigured(ALDParameterDescriptor desc,
                                            java.lang.String val)

setParamNotExternallyConfigured

public boolean setParamNotExternallyConfigured(ALDParameterDescriptor desc)

unmarkAllParameters

public void unmarkAllParameters()
Sets label colors of all parameter to black and of all links to blue.


unmarkParameter

public void unmarkParameter(ALDParameterDescriptor descr)
Sets label color of parameter to black or of link to blue (e.g. if validation successful).

Parameters:
descr - Descriptor of parameter to unmark.

updateOperatorDescriptors

public void updateOperatorDescriptors(java.util.LinkedList<ALDOpParameterDescriptor> newDescr)

validateParameters

public java.util.HashMap<ALDParameterDescriptor,java.lang.String> validateParameters()
Check if all GUI elements can deliver a proper (non-null) value.

Parameters delivering null as value are marked red or orange. Red color is used for panels used in top-level context, orange otherwise.

Returns:
Null, if successful, otherwise list of failing parameters.