QJCC homepage

biz.chitec.qapp.gjsaadminclient
Class AbstractEditElement

java.lang.Object
  extended bybiz.chitec.qapp.gjsaadminclient.AbstractEditElement
All Implemented Interfaces:
EditElement
Direct Known Subclasses:
BooleanEditElement, IntEditElement, PasswordEditElement, StringEditElement

public abstract class AbstractEditElement
extends java.lang.Object
implements EditElement

General implementation of an edit element for the GJSA server settings editor. This generic ancestor class for the read editors implements most of the business logic. The derived "real" editors do only have to implement the parts which define the actual edit component and transferring the data to and from it. For this, an additional set of abstract methods is defined which are to be implemented by the ancestors.

Version:
$Id: 05774d32823150202e4a5a41effb9d6cef72a891 $
Author:
cantamen/Dirk Hillbrecht 2007. Released under the GPL.

Nested Class Summary
protected  class AbstractEditElement.DCL
          Helper class for edit components to easily propagate value changes through the rest of the system.
protected  class AbstractEditElement.EFL
          Helper class for edit component to easily start help text showing.
protected  class AbstractEditElement.ML
          Internal helper class for help text showing.
 
Field Summary
private  boolean darkelement
           
protected  java.awt.event.ActionListener editcomponental
           
protected  javax.swing.JLabel editlabel
           
protected  java.lang.String helptext
           
private  boolean lastchangesend
           
protected  java.lang.Object oldvalue
           
protected  java.beans.PropertyChangeSupport pcs
           
protected  java.lang.String propertyname
           
protected  java.util.ResourceBundle rb
           
protected  javax.swing.JButton resetbutton
           
protected  javax.swing.JButton transferbutton
           
 
Constructor Summary
protected AbstractEditElement()
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Add a listener for property changed of the edit element.
 void addTransferActionListener(java.awt.event.ActionListener al)
          Add a listener to the "transfer" button.
protected  void checkButtons()
           
 void finalizeChange()
          Called if a change in the edit element has been transferred to the server and by this way has been made permanent.
protected  void fireIsChangedChange()
           
protected abstract  javax.swing.JComponent getEditComponent()
          Create the edit component and return it.
 java.lang.String getPropertyName()
          Return the name/key of the property.
 java.lang.Object getValue()
          Return the current value of the property in the edit element.
protected abstract  java.lang.Object getValueFromEditComponent()
          Get edited value out of the edit component.
 boolean isChanged()
          Return whether the property has been changed in the edit element.
protected  boolean isEqualInNonNullCase(java.lang.Object oldvalue, java.lang.Object newvalue)
          Comparison of old and new value.
 void realize(javax.swing.JPanel p, java.lang.String propname, boolean darkelementx, java.lang.String title, java.lang.String explanation)
          Finish the edit element's setup and show it in the embedding panel.
protected  void resetChange()
           
 void setValue(java.lang.Object data)
          Set the propertie's value.
protected abstract  void setValueInEditComponent(java.lang.Object value)
          Pass value of the property to the edit component in an appropriate way.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rb

protected java.util.ResourceBundle rb

pcs

protected java.beans.PropertyChangeSupport pcs

transferbutton

protected javax.swing.JButton transferbutton

resetbutton

protected javax.swing.JButton resetbutton

editlabel

protected javax.swing.JLabel editlabel

propertyname

protected java.lang.String propertyname

helptext

protected java.lang.String helptext

oldvalue

protected java.lang.Object oldvalue

editcomponental

protected java.awt.event.ActionListener editcomponental

lastchangesend

private boolean lastchangesend

darkelement

private boolean darkelement
Constructor Detail

AbstractEditElement

protected AbstractEditElement()
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Description copied from interface: EditElement
Add a listener for property changed of the edit element. Property change events are sent if the change state changes or if a help text should be shown.

Specified by:
addPropertyChangeListener in interface EditElement
Parameters:
pcl - Listener for property change events

addTransferActionListener

public void addTransferActionListener(java.awt.event.ActionListener al)
Description copied from interface: EditElement
Add a listener to the "transfer" button.

Specified by:
addTransferActionListener in interface EditElement
Parameters:
al - Listener for the "transfer" button.

realize

public void realize(javax.swing.JPanel p,
                    java.lang.String propname,
                    boolean darkelementx,
                    java.lang.String title,
                    java.lang.String explanation)
Description copied from interface: EditElement
Finish the edit element's setup and show it in the embedding panel. This method passes all information about the property to show into the edit element, apart from the actual value of the property. The edit element has to pass its contents into the given panel so that it will be shown.

Specified by:
realize in interface EditElement
Parameters:
p - Panel to put the components of the edit element in.
propname - Internal name/key of the component to show.
darkelementx - Flag whether this is a property for which the server does not disclose the current setting.
title - Human-readable name/title of the property. May be empty or null.
explanation - Human-readable explanation of the property. May be empty or null.

getPropertyName

public java.lang.String getPropertyName()
Description copied from interface: EditElement
Return the name/key of the property.

Specified by:
getPropertyName in interface EditElement
Returns:
Name/key of the property.

getValue

public java.lang.Object getValue()
Description copied from interface: EditElement
Return the current value of the property in the edit element.

Specified by:
getValue in interface EditElement
Returns:
Current value of the property in the edit element.

isEqualInNonNullCase

protected boolean isEqualInNonNullCase(java.lang.Object oldvalue,
                                       java.lang.Object newvalue)
Comparison of old and new value. Default implementation uses equals(). For complex data types, different approach could be needed.

Parameters:
oldvalue - First data to be compared. Must not be null.
newvalue - Second data to be compared. Must not be null.
Returns:
true if both data are contentwise equal, false otherwise.

isChanged

public boolean isChanged()
Description copied from interface: EditElement
Return whether the property has been changed in the edit element.

Specified by:
isChanged in interface EditElement
Returns:
True if some non-transmitted edits have been made, false otherwise.

checkButtons

protected void checkButtons()

finalizeChange

public void finalizeChange()
Description copied from interface: EditElement
Called if a change in the edit element has been transferred to the server and by this way has been made permanent.

Specified by:
finalizeChange in interface EditElement

resetChange

protected void resetChange()

setValue

public void setValue(java.lang.Object data)
Description copied from interface: EditElement
Set the propertie's value.

Specified by:
setValue in interface EditElement
Parameters:
data - Current value of the property in the server.

fireIsChangedChange

protected void fireIsChangedChange()

getEditComponent

protected abstract javax.swing.JComponent getEditComponent()
Create the edit component and return it. Only called once per instance. Returns the actual edit element and performs certain initialisation steps on it. It's up to the derived implementation to do the right things with the edit component in advance.

Returns:
Fully initialized edit component

setValueInEditComponent

protected abstract void setValueInEditComponent(java.lang.Object value)
Pass value of the property to the edit component in an appropriate way. The representation of the value to be edited is up to the edit component and completely encapsulated in this method.

Parameters:
value - Value to show in the edit component

getValueFromEditComponent

protected abstract java.lang.Object getValueFromEditComponent()
Get edited value out of the edit component. The value has to be converted from the representation in the edit component to real representation.

Returns:
Edited value.

QJCC homepage