hibergui
Class Edit<T>

java.lang.Object
  extended by hibergui.Component<T>
      extended by hibergui.Edit<T>
Direct Known Subclasses:
AssociationEdit, CheckBoxEdit, DateCombo, DateCombo2, RadioEdit, TextEdit, TimeEdit

public abstract class Edit<T>
extends Component<T>

Common superclass of HiberGUI components for editing properties of business entities.

Author:
Miklós Espák

Nested Class Summary
static interface Edit.DefaultComputation<TT>
           
protected  class Edit.EditConstraint
           
private  class Edit.WidgetModificationListener
           
 
Field Summary
private  Edit.DefaultComputation<T> defaultComputation
           
private  T defaultValue
           
private  boolean dirty
           
private  boolean dirty2
           
private  boolean fixed
           
protected  Form<?> form
          The form which the edit is placed on.
private  boolean invalid
           
protected  org.eclipse.swt.events.TraverseListener lsn_TRAVERSE
          This SWT listener fires a HiberGUI traverse event when an SWT traverse event is fired.
protected  Edit.WidgetModificationListener lsn_WIDGET_MOD
          lsn_WIDGET_MOD should be added for every widget used up in the implementation of the Edit.
private  java.util.List<ModificationListener> modificationListeners
           
private  java.lang.String name
           
private  java.lang.String prop
           
private  boolean readonly
           
private  java.util.List<TraverseListener> traverseListeners
           
protected  T value
          The actual value of the edit.
private  SelfVerifier verifier
           
 
Fields inherited from class hibergui.Component
lsn_WIDGET_FOCUS, lsn_WIDGET_KEY, style
 
Constructor Summary
protected Edit(Form<?> form, org.eclipse.swt.widgets.Composite cptParent, int style, java.lang.String prop, java.lang.String name)
          Constructs an edit.
 
Method Summary
 void addConstraint(Constraint c, VerificationException e)
           
protected  void addConstraint(SelfConstraint c, VerificationException e)
           
 void addModificationListener(ModificationListener listener)
           
 void addTraverseListener(TraverseListener lsn)
           
abstract  void clear()
          Clears the controls of the edit.
abstract  T extract()
          Extracts the value from the controls of the edit.
abstract  void fill()
          Fills the controls of the edit with its actual value.
protected  void fireKeyPressed(KeyEvent event)
           
protected  void fireKeyReleased(KeyEvent event)
           
private  void fireModification(ModificationEvent<T> event)
           
protected  void fireTraversal(Edit<T> edit, TraverseEvent<?> event)
           
 void fix(boolean b)
          Makes the edit read only.
 T get()
          If the edit has been modified since its last change, it returns the value extracted from itself.
 T getDefault()
           
 java.lang.String getName()
          Returns the name of the edit.
 java.lang.String getPropertyName()
          Returns the name of the property handled by the edit.
 boolean hasDefault()
           
 boolean isDirty()
           
 boolean isEditable()
           
abstract  boolean isEnabled()
           
 boolean isFixed()
           
 boolean isValid()
           
 void markClean()
           
 void markDirty()
           
 void markInvalid()
           
 void markValid()
           
 void removeConstraint(Constraint c)
           
protected  void removeConstraint(SelfConstraint c)
           
 void removeModificationListener(ModificationListener listener)
           
 void removeTraverseListener(TraverseListener lsn)
           
 void resetBackground()
           
 void set(T value)
          Sets the actual value of the edit and fills the value into the controls of the edit.
abstract  void setBackground(org.eclipse.swt.graphics.Color clr)
           
 void setDefault()
           
 void setDefault(Edit.DefaultComputation<T> defaultComp)
           
 void setDefault(T defaultValue)
           
abstract  void setEditable(boolean b)
           
abstract  void setEnabled(boolean b)
           
 void verify()
           
 
Methods inherited from class hibergui.Component
addChangeListener, addControlListener, addFocusListener, addKeyListener, createContents, dispose, fireChange, getControl, init, removeChangeListener, removeControlListener, removeFocusListener, removeKeyListener, setFocus, setLayoutData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

protected T value
The actual value of the edit.


form

protected final Form<?> form
The form which the edit is placed on.


prop

private final java.lang.String prop

name

private final java.lang.String name

dirty

private boolean dirty

invalid

private boolean invalid

dirty2

private boolean dirty2

readonly

private boolean readonly

fixed

private boolean fixed

lsn_TRAVERSE

protected org.eclipse.swt.events.TraverseListener lsn_TRAVERSE
This SWT listener fires a HiberGUI traverse event when an SWT traverse event is fired. The listener has to be added to the internal controls of HiberGUI components. Not working yet.


traverseListeners

private java.util.List<TraverseListener> traverseListeners

lsn_WIDGET_MOD

protected final Edit.WidgetModificationListener lsn_WIDGET_MOD
lsn_WIDGET_MOD should be added for every widget used up in the implementation of the Edit.


modificationListeners

private java.util.List<ModificationListener> modificationListeners

verifier

private SelfVerifier verifier

defaultValue

private T defaultValue

defaultComputation

private Edit.DefaultComputation<T> defaultComputation
Constructor Detail

Edit

protected Edit(Form<?> form,
               org.eclipse.swt.widgets.Composite cptParent,
               int style,
               java.lang.String prop,
               java.lang.String name)
Constructs an edit.

Parameters:
form - The form which the edit belongs to.
cptParent - The composite which the edit will be placed on.
style - The style of the edit. It is a combination of constants defined in hibergui.HiberGUI.
prop - The name of the property of the business entity class which the edit should handle.
name - The name of the edit. It may appear in GUI messages.
Method Detail

addTraverseListener

public final void addTraverseListener(TraverseListener lsn)

removeTraverseListener

public final void removeTraverseListener(TraverseListener lsn)

fireTraversal

protected void fireTraversal(Edit<T> edit,
                             TraverseEvent<?> event)

get

public final T get()
If the edit has been modified since its last change, it returns the value extracted from itself. Otherwise, it returns the value set last time.

Returns:
the value of the edit

set

public final void set(T value)
Sets the actual value of the edit and fills the value into the controls of the edit. If the value is null then the edit is cleared. Finally, it fires a change event.

Parameters:
value -

fix

public final void fix(boolean b)
Makes the edit read only.

Parameters:
b - If true then the edit will be read only, otherwise not.

clear

public abstract void clear()
Clears the controls of the edit.


fill

public abstract void fill()
Fills the controls of the edit with its actual value.


extract

public abstract T extract()
Extracts the value from the controls of the edit.

Returns:
the extracted value

getPropertyName

public java.lang.String getPropertyName()
Returns the name of the property handled by the edit.

Returns:
the name of the property

getName

public java.lang.String getName()
Returns the name of the edit. It may appear in GUI messages.

Returns:
the name of the edit

setBackground

public abstract void setBackground(org.eclipse.swt.graphics.Color clr)

resetBackground

public void resetBackground()

isDirty

public final boolean isDirty()

isValid

public final boolean isValid()

markClean

public void markClean()

markDirty

public void markDirty()

markValid

public void markValid()

markInvalid

public void markInvalid()

isEnabled

public abstract boolean isEnabled()

setEnabled

public abstract void setEnabled(boolean b)

isEditable

public boolean isEditable()

setEditable

public abstract void setEditable(boolean b)

isFixed

public boolean isFixed()

fireKeyPressed

protected void fireKeyPressed(KeyEvent event)
Overrides:
fireKeyPressed in class Component<T>

fireKeyReleased

protected void fireKeyReleased(KeyEvent event)
Overrides:
fireKeyReleased in class Component<T>

addModificationListener

public void addModificationListener(ModificationListener listener)

removeModificationListener

public void removeModificationListener(ModificationListener listener)

fireModification

private final void fireModification(ModificationEvent<T> event)

addConstraint

protected void addConstraint(SelfConstraint c,
                             VerificationException e)

removeConstraint

protected void removeConstraint(SelfConstraint c)

addConstraint

public void addConstraint(Constraint c,
                          VerificationException e)

removeConstraint

public void removeConstraint(Constraint c)

verify

public void verify()
            throws VerificationException
Throws:
VerificationException

hasDefault

public boolean hasDefault()

getDefault

public T getDefault()

setDefault

public void setDefault()

setDefault

public void setDefault(T defaultValue)

setDefault

public void setDefault(Edit.DefaultComputation<T> defaultComp)