de.unihalle.informatik.Alida.dataio
Class ALDDataIOManagerSwing

java.lang.Object
  extended by de.unihalle.informatik.Alida.dataio.ALDDataIOManager
      extended by de.unihalle.informatik.Alida.dataio.ALDDataIOManagerSwing

public class ALDDataIOManagerSwing
extends ALDDataIOManager

This class implements a DataIO mangager for reading/writing from a graphical user interface.

For IO, it essentially looks up the correct provider for GUI-based execution using the method of its super class and invokes its method.

It does its work in collaboration with ALDDataIOSwing.

Author:
posch

Nested Class Summary
static class ALDDataIOManagerSwing.ProviderInteractionLevel
          Levels to enable/disable interactive provider behaviour.
 
Field Summary
(package private) static ALDDataIOManagerSwing instance
          The singleton instance of this class
private  ALDDataIOManagerSwing.ProviderInteractionLevel provInterLevel
          Interaction level the providers should obey.
private  boolean triggerValueChangeEvents
          Flag to indicate if change value events should be triggered or not.
 
Fields inherited from class de.unihalle.informatik.Alida.dataio.ALDDataIOManager
debug, mapTable
 
Constructor Summary
private ALDDataIOManagerSwing()
          private constructor
 
Method Summary
 ALDSwingComponent createGUIElement(java.lang.reflect.Field field, java.lang.Class<?> cl, java.lang.Object obj, ALDParameterDescriptor descr)
          Create a gui element which may be used to request the user to input data of class cl.
static ALDDataIOManagerSwing getInstance()
          Return the single instance of this class
 ALDDataIOManagerSwing.ProviderInteractionLevel getProviderInteractionLevel()
          Returns the current level of provider interaction.
 boolean isTriggerValueChangeEvents()
          Returns value of event trigger flag.
 java.lang.Object readData(java.lang.reflect.Field field, java.lang.Class<?> cl, ALDSwingComponent guiElement)
          Reads data of given class from a specified source.
 void setProviderInteractionLevel(ALDDataIOManagerSwing.ProviderInteractionLevel level)
          Set the level of provider interaction which is allowed.
 void setTriggerValueChangeEvents(boolean b)
          Set the value change event trigger flag.
 void setValue(java.lang.reflect.Field field, java.lang.Class<?> cl, ALDSwingComponent guiElement, java.lang.Object value)
          Update the value of a parameter in the GUI component.
 javax.swing.JComponent writeData(java.lang.Object obj, ALDParameterDescriptor descr)
          Return a gui element displaying the obj or null.
 
Methods inherited from class de.unihalle.informatik.Alida.dataio.ALDDataIOManager
getProvider, getProviderMap, initMapTable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

static final ALDDataIOManagerSwing instance
The singleton instance of this class


provInterLevel

private ALDDataIOManagerSwing.ProviderInteractionLevel provInterLevel
Interaction level the providers should obey.


triggerValueChangeEvents

private boolean triggerValueChangeEvents
Flag to indicate if change value events should be triggered or not.

Constructor Detail

ALDDataIOManagerSwing

private ALDDataIOManagerSwing()
private constructor

Method Detail

createGUIElement

public ALDSwingComponent createGUIElement(java.lang.reflect.Field field,
                                          java.lang.Class<?> cl,
                                          java.lang.Object obj,
                                          ALDParameterDescriptor descr)
                                   throws ALDDataIOException
Create a gui element which may be used to request the user to input data of class cl. This element may later be forwarded to readData to extract an object representig this data. Null may be returned if no provider was found. Additionally an object may be supplied which is assumed to be of type cl. If it is non-null its value may be used to set up an inital value in the gui element.

Parameters:
cl - Class of data to be read.
obj - The value of this object to set as inital value.
descr - Optional descriptor to hand over additional information.
Returns:
gui Elemen, null if no provider was found. TODO BM: Rückgabe-Wert der Provider sollte bei Fehler nicht Null sein!
Throws:
ALDDataIOException

getInstance

public static ALDDataIOManagerSwing getInstance()
Return the single instance of this class

Returns:
single instance

getProviderInteractionLevel

public ALDDataIOManagerSwing.ProviderInteractionLevel getProviderInteractionLevel()
Returns the current level of provider interaction.

Returns:
Current level of provider interaction.

isTriggerValueChangeEvents

public boolean isTriggerValueChangeEvents()
Returns value of event trigger flag.

Returns:
True, if value change events are allowed.

readData

public java.lang.Object readData(java.lang.reflect.Field field,
                                 java.lang.Class<?> cl,
                                 ALDSwingComponent guiElement)
                          throws ALDDataIOException
Reads data of given class from a specified source.

Parameters:
cl - Class of data to be read.
guiElement - gui element from where to read data.
Returns:
data object read or null if no provider was found TODO BM: Rückgabe-Wert der Provider sollte bei Fehler nicht Null sein!
Throws:
ALDDataIOException

setProviderInteractionLevel

public void setProviderInteractionLevel(ALDDataIOManagerSwing.ProviderInteractionLevel level)
Set the level of provider interaction which is allowed.

Parameters:
level - New level of interaction providers have to obey.

setTriggerValueChangeEvents

public void setTriggerValueChangeEvents(boolean b)
Set the value change event trigger flag.

Parameters:
b - New value of the event trigger flag.

setValue

public void setValue(java.lang.reflect.Field field,
                     java.lang.Class<?> cl,
                     ALDSwingComponent guiElement,
                     java.lang.Object value)
              throws ALDDataIOException
Update the value of a parameter in the GUI component.

Parameters:
field - Related field of parameter to be updated.
cl - Class of object to be handled.
guiElement - Corresponding GUI element.
value - New value to be set.
Throws:
ALDDataIOException - TODO BM: Rückgabe-Wert der Provider sollte bei Fehler nicht Null sein!

writeData

public javax.swing.JComponent writeData(java.lang.Object obj,
                                        ALDParameterDescriptor descr)
                                 throws ALDDataIOException
Return a gui element displaying the obj or null. In the latter case the obj may have been shown otherwise, e.g. in an own window.

Parameters:
obj - Object to write.
descr - Optional descriptor to hand over additional information.
Returns:
gui Element created. TODO BM: Rückgabe-Wert der Provider sollte bei Fehler nicht Null sein!
Throws:
ALDDataIOException