org.formaria.editor.project.pages.components
Class PropertyHelper

java.lang.Object
  extended by org.formaria.editor.project.pages.components.PropertyHelper
Direct Known Subclasses:
ComboBoxHelper, GenericPropertyHelper, ImageButtonHelper, IncludeReferenceHelper, LabelHelper, LayerHelper, LayoutPropertyHelper, ListHelper, MenuHelper, MenuItemHelper, MultipleSelectionHelper, PageHelper, PanelHelper, RadioButtonHelper, RegisteredComponentPropertyHelper, RepeatReferenceHelper, ScrollPaneHelper, TableHelper, TextAreaHelper, UnknownHelper

public abstract class PropertyHelper
extends java.lang.Object

A helper class to describe the properties of an individual component

Copyright (c) Formaria Ltd., 2002-2006

$Revision: 1.33 $


Field Summary
protected static int[] alignmentOptionIds
           
protected static java.lang.String[] alignmentOptions
           
protected  boolean allowsChildren
           
protected static java.util.ArrayList<java.lang.String> builtinProperties
           
protected  java.lang.String className
           
protected  java.lang.String componentType
           
protected  java.util.Hashtable<java.lang.String,java.lang.String> defaultValues
           
protected  java.lang.String defExt
           
protected  java.lang.String[] extensions
           
protected  java.lang.String fileTypeDesc
           
protected static int[] horzScrollOptionIds
           
protected  boolean isSwing
           
protected static int[] lblAlignmentOptionIds
           
protected static java.lang.String[] lblAlignmentOptions
           
protected  int numBuiltinProperties
           
protected  java.util.ArrayList<java.lang.String> properties
           
protected static java.util.Hashtable<java.lang.String,PlainProperty> propertyTypes
           
protected  boolean restrictsSize
           
protected static java.lang.String[] scrollOptions
           
protected  boolean usesContentFile
           
protected static int[] vertScrollOptionIds
           
 
Constructor Summary
PropertyHelper()
           
 
Method Summary
 boolean accepts(java.lang.String targetClass)
          Does this property helper work with the specified class
 boolean addPropertyType(java.lang.String name, PlainProperty type)
          Add a property type if it is not already present
 boolean allowsChildren()
          Check if this component allows children to be added.
 void cleanupClassName()
           
 AriaBuilder getBuilder()
          Get the page builder
 javax.swing.table.TableCellEditor getCellEditor(javax.swing.JTable table, java.lang.Object comp, EditorProject currentProject, java.lang.String propertyName, int row, int col, java.lang.Object value)
          Get a table cell editor
 java.lang.String getClassName()
          Gets the className of the soure component.
 java.lang.String getComponentType()
           
 java.lang.String getDefaultExtension()
           
 java.lang.String getDefaultValue(PageResource pageResource, java.lang.Object comp, java.lang.String propertyName)
          Get the value of the property exposed by the component
 java.lang.String getDisplayPropertyValue(PageResource pageResource, java.lang.Object comp, java.lang.String propertyName)
          Get the value of the property displayed by the editor
 boolean getEnabled(java.lang.Object comp, java.lang.String propertyName)
          Is the property enabled
 java.lang.Class getEventClass(java.lang.Object comp, java.lang.String propertyName)
          Get the event class attribute
 long getEventMask(java.lang.Object comp, java.lang.String propertyName)
          Get the event mask attribute
 java.lang.String getExpression(java.lang.Object comp, java.lang.String propertyName)
          Get the expression value of this property if one exists
 java.lang.String getFileDescription()
          Get a description of the file extension set to be used for file/image names in the popup chooser
 java.lang.String[] getFileExtensions()
          Get the file extension set to be used for file/image names in the popup chooser
 java.lang.String[] getListItems(java.lang.Object comp, java.lang.String propertyName)
          Get the items to display for a list property
 int getNumBuiltinProperties()
          Get the number of built-in properties
 int getNumProperties(java.lang.Object comp)
          Get the number of properties that the component exposes
 java.lang.String getOutputPropertyValue(PageResource pageResource, java.lang.Object comp, java.lang.String propertyName)
          Get the value of the property written to the XML file
 java.util.ArrayList getProperties(int propertyType)
          Get the names of the proeprties provided for this component of the specified type
 PlainProperty getProperty(java.lang.String name)
          Get a property of the specified name
 PlainProperty getProperty(java.lang.String name, boolean checkTags)
          Get a property of the specified name
 java.lang.String getPropertyDisplayName(java.lang.String key)
          Get the display name of the property
 java.lang.String getPropertyName(int i)
          Get the name of the property
 java.lang.String getPropertyTag(int i)
          Get the XML tag name for the property
 int getPropertyType(java.lang.String propertyName)
          Get the type of the property
 java.lang.String getPropertyTypeName(java.lang.String propertyName)
          Get the type name of the property displaying the name (synonym)
 java.lang.String getPropertyValue(PageResource pageResource, java.lang.Object comp, java.lang.String propertyName)
          Get the value of the property exposed by the component
 boolean isLangProperty(java.lang.String propertyName)
          Is this a lang property
 boolean isLayoutOwner()
          Is this helper's component oen that supports layouts?
 boolean isListProperty(java.lang.String propertyName)
          Is this a list property
 boolean isReadOnly(java.lang.String propertyName)
          Is the property read-only?
 boolean isSwing()
          Is this a swing component helper?
 boolean restrictsSize()
          Flag the component as having a restricted size if true is returned
 void setAllowsChildren(boolean state)
          Set the component allows children flag
 void setComponent(java.lang.Object comp)
           
 void setCopiedProperties(PageResource page, java.awt.Component srcComp, java.awt.Component targetComp)
          Calls the relevant component helper to set the attributes of a new component when a paste operation has been invoked from the main menu.
 boolean setExpression(java.lang.Object comp, java.lang.String propertyName, java.lang.Object expression)
          Set the expression value for this property
 void setFileExtensions(java.lang.String desc, java.lang.String defaultExt, java.lang.String[] newExtensions)
          Set the array/list of extensions used by the file/image name chooser
 boolean setPropertyValue(PageResource pageResource, java.lang.Object comp, java.lang.String propertyName, java.lang.Object value)
          Set the value of the property exposed by the component
 void setRestrictsSize(boolean state)
          Set the flag for restricted size
 void setSwing(boolean iss)
          Sets the flag to indicate if this is a swing component helper?
 void setUsesContentFile(boolean ucf)
          Sets the flag to indicate if this is component uses a content file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alignmentOptions

protected static final java.lang.String[] alignmentOptions

alignmentOptionIds

protected static final int[] alignmentOptionIds

lblAlignmentOptions

protected static final java.lang.String[] lblAlignmentOptions

lblAlignmentOptionIds

protected static final int[] lblAlignmentOptionIds

scrollOptions

protected static final java.lang.String[] scrollOptions

horzScrollOptionIds

protected static final int[] horzScrollOptionIds

vertScrollOptionIds

protected static final int[] vertScrollOptionIds

propertyTypes

protected static java.util.Hashtable<java.lang.String,PlainProperty> propertyTypes

builtinProperties

protected static java.util.ArrayList<java.lang.String> builtinProperties

usesContentFile

protected boolean usesContentFile

allowsChildren

protected boolean allowsChildren

restrictsSize

protected boolean restrictsSize

isSwing

protected boolean isSwing

numBuiltinProperties

protected int numBuiltinProperties

className

protected java.lang.String className

componentType

protected java.lang.String componentType

extensions

protected java.lang.String[] extensions

fileTypeDesc

protected java.lang.String fileTypeDesc

defExt

protected java.lang.String defExt

properties

protected java.util.ArrayList<java.lang.String> properties

defaultValues

protected java.util.Hashtable<java.lang.String,java.lang.String> defaultValues
Constructor Detail

PropertyHelper

public PropertyHelper()
Method Detail

getBuilder

public AriaBuilder getBuilder()
Get the page builder

Returns:
the builder

addPropertyType

public boolean addPropertyType(java.lang.String name,
                               PlainProperty type)
Add a property type if it is not already present

Parameters:
name - the name of the new property
type - the property type
Returns:
true if successfully added, otherwise false (if it already exists)

setComponent

public void setComponent(java.lang.Object comp)

getClassName

public java.lang.String getClassName()
Gets the className of the soure component. If the name has not been explicitly set the class name of this helper is used and the name is truncated to remove the 'Helper' part.

Returns:
the class name of the source component

accepts

public boolean accepts(java.lang.String targetClass)
Does this property helper work with the specified class

Parameters:
targetClass -
Returns:
true if this helper works with the target class

cleanupClassName

public void cleanupClassName()

getComponentType

public java.lang.String getComponentType()

getNumProperties

public int getNumProperties(java.lang.Object comp)
Get the number of properties that the component exposes

Returns:
the number of propeties

getNumBuiltinProperties

public int getNumBuiltinProperties()
Get the number of built-in properties


getPropertyName

public java.lang.String getPropertyName(int i)
Get the name of the property

Parameters:
i - the property index
Returns:
the name

getPropertyDisplayName

public java.lang.String getPropertyDisplayName(java.lang.String key)
Get the display name of the property

Parameters:
key - the property index
Returns:
the display name

getPropertyTag

public java.lang.String getPropertyTag(int i)
Get the XML tag name for the property

Parameters:
i - the property index
Returns:
the tag

getProperty

public PlainProperty getProperty(java.lang.String name)
Get a property of the specified name

Parameters:
name - the property name
Returns:
the property or null if the proeprty is not available

getProperty

public PlainProperty getProperty(java.lang.String name,
                                 boolean checkTags)
Get a property of the specified name

Parameters:
name - the property name
checkTags - true to check if a property tag matches the name and that property is contained in the list of properties.
Returns:
the property or null if the proeprty is not available

getCellEditor

public javax.swing.table.TableCellEditor getCellEditor(javax.swing.JTable table,
                                                       java.lang.Object comp,
                                                       EditorProject currentProject,
                                                       java.lang.String propertyName,
                                                       int row,
                                                       int col,
                                                       java.lang.Object value)
Get a table cell editor

Parameters:
table - the table being edited
comp - the current component
currentProject - the current project
propertyName - the property name
row - the current row
col - the current column
the - current value

getEnabled

public boolean getEnabled(java.lang.Object comp,
                          java.lang.String propertyName)
Is the property enabled

Parameters:
propertyName - the property name
comp - the component instance
Returns:
the name

getPropertyType

public int getPropertyType(java.lang.String propertyName)
Get the type of the property

Parameters:
propertyName - the property name
Returns:
the type as defined by PropertiesEditor

getPropertyTypeName

public java.lang.String getPropertyTypeName(java.lang.String propertyName)
Get the type name of the property displaying the name (synonym)

Parameters:
propertyName - the property name
Returns:
the type as defined by PropertiesEditor

getProperties

public java.util.ArrayList getProperties(int propertyType)
Get the names of the proeprties provided for this component of the specified type

Parameters:
propertyType - the property type e.g. PlainProperty.DATA_PROPERTY

getDisplayPropertyValue

public java.lang.String getDisplayPropertyValue(PageResource pageResource,
                                                java.lang.Object comp,
                                                java.lang.String propertyName)
Get the value of the property displayed by the editor

Parameters:
pageResource - the page resource to which this component belongs
comp - the component instance
propertyName - the component property name
Returns:
the value

getPropertyValue

public java.lang.String getPropertyValue(PageResource pageResource,
                                         java.lang.Object comp,
                                         java.lang.String propertyName)
Get the value of the property exposed by the component

Parameters:
pageResource - the page resource to which this component belongs
comp - the component instance
propertyName - the component property name
propertyName - the property name
Returns:
the value

getOutputPropertyValue

public java.lang.String getOutputPropertyValue(PageResource pageResource,
                                               java.lang.Object comp,
                                               java.lang.String propertyName)
Get the value of the property written to the XML file

Parameters:
pageResource - the page resource to which this component belongs
comp - the component instance
propertyName - the component property name
Returns:
the value

getDefaultValue

public java.lang.String getDefaultValue(PageResource pageResource,
                                        java.lang.Object comp,
                                        java.lang.String propertyName)
Get the value of the property exposed by the component

Parameters:
pageResource - the page resource to which this component belongs
comp - the component instance
propertyName - the component property name
Returns:
the value

setPropertyValue

public boolean setPropertyValue(PageResource pageResource,
                                java.lang.Object comp,
                                java.lang.String propertyName,
                                java.lang.Object value)
Set the value of the property exposed by the component

Parameters:
pageResource - the page resource to which this component belongs
comp - the component instance
propertyName - the component property name
Returns:
true if all is OK

getEventMask

public long getEventMask(java.lang.Object comp,
                         java.lang.String propertyName)
Get the event mask attribute

Parameters:
propertyName - the component property name
Returns:
the value

getEventClass

public java.lang.Class getEventClass(java.lang.Object comp,
                                     java.lang.String propertyName)
Get the event class attribute

Parameters:
propertyName - the component property name
Returns:
the value

getListItems

public java.lang.String[] getListItems(java.lang.Object comp,
                                       java.lang.String propertyName)
Get the items to display for a list property

Parameters:
propertyName - the property name
Returns:
an array of list items

allowsChildren

public boolean allowsChildren()
Check if this component allows children to be added.

Returns:
true to allow addition of children. By default false is returned as most components do not intend to allow addition of children

setAllowsChildren

public void setAllowsChildren(boolean state)
Set the component allows children flag

Parameters:
state - true to allow addition of children. By default false is returned

restrictsSize

public boolean restrictsSize()
Flag the component as having a restricted size if true is returned

Returns:
false

setRestrictsSize

public void setRestrictsSize(boolean state)
Set the flag for restricted size

Parameters:
state - true for restricted size

setSwing

public void setSwing(boolean iss)
Sets the flag to indicate if this is a swing component helper?

Parameters:
iss - true if it is a swing helper

setUsesContentFile

public void setUsesContentFile(boolean ucf)
Sets the flag to indicate if this is component uses a content file

Parameters:
ucf - true if it is a swing helper

isSwing

public boolean isSwing()
Is this a swing component helper?

Returns:
true if it is a swing helper

isListProperty

public boolean isListProperty(java.lang.String propertyName)
Is this a list property


isLangProperty

public boolean isLangProperty(java.lang.String propertyName)
Is this a lang property


isLayoutOwner

public boolean isLayoutOwner()
Is this helper's component oen that supports layouts?

Returns:
false by default

isReadOnly

public boolean isReadOnly(java.lang.String propertyName)
Is the property read-only?

Parameters:
propertyName - the name of the selected property
Returns:
true if the property is read-only

setCopiedProperties

public void setCopiedProperties(PageResource page,
                                java.awt.Component srcComp,
                                java.awt.Component targetComp)
Calls the relevant component helper to set the attributes of a new component when a paste operation has been invoked from the main menu.

Parameters:
srcComp - the component which was selected when the copy or cut command was invoked
targetComp - the new component which will be added to the current page

getFileExtensions

public java.lang.String[] getFileExtensions()
Get the file extension set to be used for file/image names in the popup chooser

Returns:
an array of strings

getFileDescription

public java.lang.String getFileDescription()
Get a description of the file extension set to be used for file/image names in the popup chooser

Returns:
an array of strings

getDefaultExtension

public java.lang.String getDefaultExtension()

setFileExtensions

public void setFileExtensions(java.lang.String desc,
                              java.lang.String defaultExt,
                              java.lang.String[] newExtensions)
Set the array/list of extensions used by the file/image name chooser

Parameters:
desc - the description of the file type.
defaultExt - the default file extension
newExtensions -

getExpression

public java.lang.String getExpression(java.lang.Object comp,
                                      java.lang.String propertyName)
Get the expression value of this property if one exists

Parameters:
propertyName - the name of the property
Returns:
the expression or null

setExpression

public boolean setExpression(java.lang.Object comp,
                             java.lang.String propertyName,
                             java.lang.Object expression)
Set the expression value for this property

Parameters:
comp - the component instance
propertyName - the name of the property
expression - the new expression
Returns:
true if the value is an expression and it is stored, otherwise false is returned