ARoad0.Gui1
Class GraphicViewPropertyEditor

java.lang.Object
  extended by ARoad0.Gui1.GraphicViewPropertyEditor
All Implemented Interfaces:
CommonPropertyEditor, java.awt.event.ActionListener, java.beans.PropertyChangeListener, java.beans.PropertyEditor, java.util.EventListener

public class GraphicViewPropertyEditor
extends java.lang.Object
implements CommonPropertyEditor, java.awt.event.ActionListener, java.beans.PropertyChangeListener

This class is responsible for displaying, without editing, the GraphicView and the text properties of a ViewInBase, by the mean of a simple panel without buttons. The getCustomEditor() method returns the final result. This class is returned by Gui1.ActionOpenAllFullViews or ActionOpenAllNoThanViews, which generates the descriptors, and it is so independant to the gBase package, on the contrary of other CommonPropertyEditor subclasses. getSource() returns null. It is used by Gui1.BeamerManager.addPropertyEditor() when BeamerManager is called by ActionOpenAllFullViews or ActionOpenAllNoThanViews.

This class displays two properties derived from the view, and their types are ARoad0.Gui2.GraphicView and javax.swing.JTextPane. This class is a PropertyEditor that gets the property and does NOT listen the changes. It is a custom editor that provides getCustomEditor(), and specifies the prefered size of the panel to be displayed.

When the user updatings make some changes in the view, there are listen by a GraphicViewBaseListenerImpl instance dedicated to the view, then this instance updates directly the GraphicView and the JTextPane in this property editor by the way of propertyChange(). The GUI displays always the right data.

As a PropertyEditor, it must be able to register PropertyChangeListeners but this is not a feature to use so far. Use only registration on GraphicViewBaseListenerImpl, that handle PropertyChangeListeners.

An instance is constructed by the factory method valueOf(), and it is possible to get a reusable empty instance. java.beans.PropertyEditorManager is not used.

For thread management, this class runs a worker thread in propertyChange(). It calls GraphicView.resetGraphicView() or resetRights(), then call GraphicView.setWhyText() in the Event Dispatch Thread. propertyChange() processes the calls in their calling order, as asynchronous tasks in the worker thread.


Field Summary
protected  java.lang.String displayName_
          It is not the display name of the property, given by the property descriptor.
static GraphicViewPropertyEditor EMPTY_INSTANCE
          A reusable empty instance for initialization, to avoid the use of 'new' for temporary values.
protected static java.lang.Object EMPTY_OBJECT
          An empty object for initialization
protected static int INITIAL_CAPACITY
           
protected  java.util.ArrayList listeners_
          The listeners for property updates
protected  GraphicView property_
          The property is a GraphicView there.
protected  java.beans.PropertyDescriptor propertyDescriptor_
          The property descriptor
protected  java.lang.Class propertyType_
          The property type.
protected  BaseObject source_
          The instance owning the property.
protected  javax.swing.JTextPane subproperty_
          The subproperty is a text from the GraphicView.
protected  java.lang.Class subpropertyType_
          The subproperty type.
protected  boolean withSeeWhy_
          True when the 'See Why' text is displayed; then, subproperty_ is not null.
 
Fields inherited from interface ARoad0.Gui1.CommonPropertyEditor
BOOLEAN_FIELD_DIMENSION, BOOLEAN_NAME_DIMENSION, BUTTON_DIMENSION, BUTTON_DIMENSION_2, BUTTON_DIMENSION_3, COLOMN_DIMENSION, COMBOBOX_FIELD_DIMENSION, EMPTY_FIELD_DIMENSION, HEIGHT_DIMENSION, INT_EMPTY_FIELD_DIMENSION, INT_FIELD_DIMENSION, LIST_HEIGHT_DIMENSION, LIST_WIDTH_DIMENSION, MAP_NAME_WIDTH_DIMENSION, NAME_DIMENSION, NAME_MAP_DIMENSION, NAME_WIDTH_DIMENSION, NAME_WIDTH_DIMENSION_2, NO_BUTTON_FIELD_DIMENSION, NO_BUTTON_WIDTH_DIMENSION, ONE_BUTTON_FIELD_DIMENSION, THREE_BUTTONS_FIELD_DIMENSION, TWO_BUTTONS_FIELD_DIMENSION
 
Constructor Summary
GraphicViewPropertyEditor()
          Constructor FOR USE ONLY through the valueOf() method, EMPTY_INSTANCE and the subclasses.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent _evt)
          NOOP
 void addPropertyChangeListener(java.beans.PropertyChangeListener _listener)
          Register a listener for the PropertyChange event - NO USE SO FAR.
 void finalizeForProcess()
          Finalizes the instance; the call is reserved to BeamerManager.
private  void firePropertyChange()
          Reports that we have been modified to any interested listeners - NOT USED SO FAR.
 java.lang.String getAsText()
          Gets the property value as a string suitable for presentation to a human to edit.
 java.awt.Component getCustomEditor()
          Returns a full custom Component that displays the GraphicView and the associated 'See why' text.
 java.lang.String getDisplayName()
          Gets the value of the display property name (not the true name, given by the property descriptor).
 java.lang.String getJavaInitializationString()
          This method is intended for use when generating Java code to set the value of the property.
 java.awt.Dimension getPreferedSizeForEditing()
          Get the prefered size for the rectangle into which the value is displayed, in the component returned by getCustomEditor().
 java.beans.PropertyDescriptor getPropertyDescriptor()
          Gets the descriptor of the property.
 java.lang.Class getPropertyType()
          Gets the value of the property type, that is the Class of the returned object in getValue(): GraphicView, and not ViewInBase.
 BaseObject getSource()
          Gets the value of the property source, which is null there.
 java.lang.String[] getTags()
          When the value is a boolean, the tages are yes/no, excepted if a couple of tag is set in the property descriptor with the key 'tags'.
 java.lang.Object getValue()
          Get the value of the GraphicView.
 java.lang.reflect.Method getWriteMethod()
          Gets the method on the source for updates.
 boolean isPaintable()
          Determines whether the class will honor the paintValue method.
 void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box)
          Paint a representation of the value into a given area of screen real estate.
 void propertyChange(java.beans.PropertyChangeEvent _evt)
          Manages the event fired by the GraphicViewBaseListener when the GraphicView has to be changed (then, _evt.getNewValue() is not null) or to be reset only for updating the rights.
 void removePropertyChangeListener(java.beans.PropertyChangeListener _listener)
          Remove a listener for the PropertyChange event - NO USE SO FAR.
 void setAsText(java.lang.String _text)
          Raise java.lang.IllegalArgumentException since this kind of property can't be expressed as text.
 void setValue(java.lang.Object _value)
          NOOP - Set (or change) the object that is to be edited.
 boolean supportsCustomEditor()
          Determines whether the propertyEditor can provide a custom editor.
 java.lang.String toString()
          Get the values of variables for the instance.
static CommonPropertyEditor valueOf(BaseObject _source, java.beans.PropertyDescriptor _propertyDescriptor)
          Factory method to use when a CommonPropertyEditor is delegating to us.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INITIAL_CAPACITY

protected static final int INITIAL_CAPACITY
See Also:
Constant Field Values

displayName_

protected java.lang.String displayName_
It is not the display name of the property, given by the property descriptor.


source_

protected BaseObject source_
The instance owning the property. Always null.


propertyDescriptor_

protected java.beans.PropertyDescriptor propertyDescriptor_
The property descriptor


property_

protected GraphicView property_
The property is a GraphicView there. It is NOT a BaseObject.


propertyType_

protected java.lang.Class propertyType_
The property type. A GraphicView there. It is NOT a BaseObject subclass.


subproperty_

protected javax.swing.JTextPane subproperty_
The subproperty is a text from the GraphicView. It is NOT a BaseObject.


subpropertyType_

protected java.lang.Class subpropertyType_
The subproperty type. A JTextPane there. It is NOT a BaseObject subclass.


withSeeWhy_

protected boolean withSeeWhy_
True when the 'See Why' text is displayed; then, subproperty_ is not null.


listeners_

protected java.util.ArrayList listeners_
The listeners for property updates


EMPTY_OBJECT

protected static final java.lang.Object EMPTY_OBJECT
An empty object for initialization


EMPTY_INSTANCE

public static final GraphicViewPropertyEditor EMPTY_INSTANCE
A reusable empty instance for initialization, to avoid the use of 'new' for temporary values. Caution: never change the state of the returned instance.

Constructor Detail

GraphicViewPropertyEditor

GraphicViewPropertyEditor()
Constructor FOR USE ONLY through the valueOf() method, EMPTY_INSTANCE and the subclasses.

Method Detail

valueOf

public static CommonPropertyEditor valueOf(BaseObject _source,
                                           java.beans.PropertyDescriptor _propertyDescriptor)
                                    throws java.lang.NullPointerException,
                                           BaseError,
                                           ProcessError
Factory method to use when a CommonPropertyEditor is delegating to us. The graphic view associated to the ViewInBase has to be created and registered before. Called by BeamerManager.addPropertyEditor().

Parameters:
_source - the ViewInBase - no use there
_propertyDescriptor - for the property, where getDisplayName() gives the ViewInBase name.toString()
Returns:
a GraphicViewPropertyEditor instance
Throws:
java.lang.NullPointerException - if _source or _propertyDescriptor is null
BaseError - if the display name or the graphic view are not found
ProcessError - if BeanInfo and PropertyDecriptor calls fail

setValue

public void setValue(java.lang.Object _value)
NOOP - Set (or change) the object that is to be edited.

Specified by:
setValue in interface java.beans.PropertyEditor
Parameters:
_value - is the new target object to be edited. This object is not modified by the PropertyEditor. Never null.

getValue

public java.lang.Object getValue()
Get the value of the GraphicView.

Specified by:
getValue in interface java.beans.PropertyEditor
Returns:
the value of the property. May be null.

getAsText

public java.lang.String getAsText()
Gets the property value as a string suitable for presentation to a human to edit.

Specified by:
getAsText in interface java.beans.PropertyEditor
Returns:
the GraphicView.setWhyText() or null.

setAsText

public void setAsText(java.lang.String _text)
               throws java.lang.IllegalArgumentException
Raise java.lang.IllegalArgumentException since this kind of property can't be expressed as text.

Specified by:
setAsText in interface java.beans.PropertyEditor
Parameters:
_text - is the string to be parsed.
Throws:
in - all cases.
java.lang.IllegalArgumentException

getSource

public BaseObject getSource()
Gets the value of the property source, which is null there.

Returns:
the source of the property.

getDisplayName

public java.lang.String getDisplayName()
Gets the value of the display property name (not the true name, given by the property descriptor).

Specified by:
getDisplayName in interface CommonPropertyEditor
Returns:
the display name of the property.

getPropertyType

public java.lang.Class getPropertyType()
Gets the value of the property type, that is the Class of the returned object in getValue(): GraphicView, and not ViewInBase.

Specified by:
getPropertyType in interface CommonPropertyEditor
Returns:
The type of the property.

getPropertyDescriptor

public java.beans.PropertyDescriptor getPropertyDescriptor()
Gets the descriptor of the property.

Specified by:
getPropertyDescriptor in interface CommonPropertyEditor
Returns:
The descriptor of the property.

getWriteMethod

public java.lang.reflect.Method getWriteMethod()
Gets the method on the source for updates.

Specified by:
getWriteMethod in interface CommonPropertyEditor
Returns:
null.

getTags

public java.lang.String[] getTags()
When the value is a boolean, the tages are yes/no, excepted if a couple of tag is set in the property descriptor with the key 'tags'.

Specified by:
getTags in interface java.beans.PropertyEditor
Returns:
null.

supportsCustomEditor

public boolean supportsCustomEditor()
Determines whether the propertyEditor can provide a custom editor.

Specified by:
supportsCustomEditor in interface java.beans.PropertyEditor
Returns:
true.

getJavaInitializationString

public java.lang.String getJavaInitializationString()
This method is intended for use when generating Java code to set the value of the property. It should return a fragment of Java code that can be used to initialize a variable with the current property value.

Example results are "2", "new Color(127,127,34)", "Color.orange", etc.

Specified by:
getJavaInitializationString in interface java.beans.PropertyEditor
Returns:
"???".

getPreferedSizeForEditing

public java.awt.Dimension getPreferedSizeForEditing()
Get the prefered size for the rectangle into which the value is displayed, in the component returned by getCustomEditor().

Specified by:
getPreferedSizeForEditing in interface CommonPropertyEditor
Returns:
prefered size.

isPaintable

public boolean isPaintable()
Determines whether the class will honor the paintValue method.

Specified by:
isPaintable in interface java.beans.PropertyEditor
Returns:
false.

paintValue

public void paintValue(java.awt.Graphics gfx,
                       java.awt.Rectangle box)
Paint a representation of the value into a given area of screen real estate. Note that the propertyEditor is responsible for doing its own clipping so that it fits into the given rectangle.

If the PropertyEditor doesn't honor paint requests (see isPaintable) this method should be a silent noop.

Specified by:
paintValue in interface java.beans.PropertyEditor
Parameters:
gfx - Graphics object to paint into.
box - Rectangle within graphics object into which we should paint.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener _listener)
Register a listener for the PropertyChange event - NO USE SO FAR. The class will fire a PropertyChange value whenever the value is updated.

Specified by:
addPropertyChangeListener in interface java.beans.PropertyEditor
Parameters:
_listener - An object to be invoked when a PropertyChange event is fired.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener _listener)
Remove a listener for the PropertyChange event - NO USE SO FAR.

Specified by:
removePropertyChangeListener in interface java.beans.PropertyEditor
Parameters:
_listener - The PropertyChange listener to be removed.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent _evt)
Manages the event fired by the GraphicViewBaseListener when the GraphicView has to be changed (then, _evt.getNewValue() is not null) or to be reset only for updating the rights. This method is called in the event dispatch thread, and uses a worker thread pool which processes the calls in their calling order.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
_evt - the event

toString

public java.lang.String toString()
Get the values of variables for the instance.

Overrides:
toString in class java.lang.Object
Returns:
source, propertyName and listeners (if they have toString() methods).

finalizeForProcess

public void finalizeForProcess()
Finalizes the instance; the call is reserved to BeamerManager.

Specified by:
finalizeForProcess in interface CommonPropertyEditor

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent _evt)
NOOP

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
_evt - is the event fired by a JComponent displayed by getCustomEditor()

getCustomEditor

public java.awt.Component getCustomEditor()
Returns a full custom Component that displays the GraphicView and the associated 'See why' text. Called by BeamerManager.addPropertyEditor().

Specified by:
getCustomEditor in interface CommonPropertyEditor
Specified by:
getCustomEditor in interface java.beans.PropertyEditor
Returns:
a JPanel which displays the GraphicView and the 'See why' text
See Also:
PropertyEditor.getCustomEditor()

firePropertyChange

private void firePropertyChange()
Reports that we have been modified to any interested listeners - NOT USED SO FAR.