com.virtualweaver.xotics.datamodel.editor
Class XoAbstractPropertyEditor

java.lang.Object
  extended byjava.beans.PropertyEditorSupport
      extended bycom.virtualweaver.xotics.datamodel.editor.XoAbstractPropertyEditor
All Implemented Interfaces:
java.beans.PropertyEditor, XoPropertyEditor
Direct Known Subclasses:
XoBooleanPropertyEditor, XoEnumPropertyEditor, XoTextualPropertyEditor, XoXsdPropertyEditor

public abstract class XoAbstractPropertyEditor
extends java.beans.PropertyEditorSupport
implements XoPropertyEditor

This class implements an abstract PropertyEditor implementing interface XoPropertyEditor. It provides a standard way to implement a PropertyEditor by extending the functionalities of PropertyEditorSupport. The main principle is about custom editor which can be created only when first need (with create an init customEditor), in order to save large amount of memory.

Version:
4.1

Field Summary
protected  java.awt.Component customEditor
          the graphical UI used to edit value.
protected  java.lang.Object value
          the internaly stored value.
 
Constructor Summary
XoAbstractPropertyEditor()
          Creates a new instance of XoAbstractPropertyEditor.
 
Method Summary
protected abstract  void createCustomEditor()
          This method informs this to create the graphical UI to edit the value.
protected abstract  java.lang.Object createValue(java.lang.String str)
          Creates an instance of value object by converting string param str.
 java.lang.String getAsText()
          Returns current value as string representation
 java.awt.Component getCustomEditor()
          Returns the custom editor UI, by creating it at first call of this method.
 java.lang.Object getValue()
          returns the internaly stored value.
protected abstract  void initCustomEditor()
          This method informs this to init or reinit the graphical UI previously created by createCustomEditor().
 boolean isPaintable()
          by default, return false. if derived class returns true, it must also implement paintValue() from PropertyEditor interface.
 void setAsText(java.lang.String str)
          Sets value with result of converting param str as object, by createValue()
protected abstract  void setCustomEditorValue()
          This method informs this to setup the graphical UI with current value.
 void setProperty(XoProperty p)
          Sets the property possibly using this editor.
 void setValue(java.lang.Object obj)
          Sets value with obj and sets customEditor also if created
 boolean supportsCustomEditor()
          This class supports customEditor
 
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getJavaInitializationString, getTags, paintValue, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.beans.PropertyEditor
addPropertyChangeListener, getJavaInitializationString, getTags, paintValue, removePropertyChangeListener
 

Field Detail

value

protected java.lang.Object value
the internaly stored value.


customEditor

protected java.awt.Component customEditor
the graphical UI used to edit value.

Constructor Detail

XoAbstractPropertyEditor

public XoAbstractPropertyEditor()
Creates a new instance of XoAbstractPropertyEditor. An empty arg constructor is mandatory.

Method Detail

createValue

protected abstract java.lang.Object createValue(java.lang.String str)
                                         throws java.lang.IllegalArgumentException
Creates an instance of value object by converting string param str.

Parameters:
str - the string to convert into value
Returns:
an object created with str
Throws:
java.lang.IllegalArgumentException - if str is not convertible

createCustomEditor

protected abstract void createCustomEditor()
This method informs this to create the graphical UI to edit the value. The result must be stored in customEditor field. If a customEditor instance already exists, it must be released cleanly (i.e. remove any listener on it) before creating new instance.


initCustomEditor

protected abstract void initCustomEditor()
This method informs this to init or reinit the graphical UI previously created by createCustomEditor().


setCustomEditorValue

protected abstract void setCustomEditorValue()
This method informs this to setup the graphical UI with current value.


getAsText

public java.lang.String getAsText()
Returns current value as string representation

Specified by:
getAsText in interface java.beans.PropertyEditor
Returns:
this method returns null if value is null or value.toString()

setProperty

public void setProperty(XoProperty p)
Sets the property possibly using this editor. This method is not mandatory, but could be used to obtain some useful data or tools to edit value, such as property class, owner object, and then DM instance and through it other functionalities.

Specified by:
setProperty in interface XoPropertyEditor
Parameters:
p - the property wrapper

getCustomEditor

public java.awt.Component getCustomEditor()
Returns the custom editor UI, by creating it at first call of this method. If this method is never called, this should not create any customEditor.

Specified by:
getCustomEditor in interface java.beans.PropertyEditor

getValue

public java.lang.Object getValue()
returns the internaly stored value.

Specified by:
getValue in interface java.beans.PropertyEditor

isPaintable

public boolean isPaintable()
by default, return false. if derived class returns true, it must also implement paintValue() from PropertyEditor interface.

Specified by:
isPaintable in interface java.beans.PropertyEditor

setAsText

public void setAsText(java.lang.String str)
               throws java.lang.IllegalArgumentException
Sets value with result of converting param str as object, by createValue()

Specified by:
setAsText in interface java.beans.PropertyEditor
Throws:
java.lang.IllegalArgumentException

setValue

public void setValue(java.lang.Object obj)
Sets value with obj and sets customEditor also if created

Specified by:
setValue in interface java.beans.PropertyEditor

supportsCustomEditor

public boolean supportsCustomEditor()
This class supports customEditor

Specified by:
supportsCustomEditor in interface java.beans.PropertyEditor