|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.formaria.aria.ComponentFactory
public class ComponentFactory
A component factory. The factory is designed to create components for a null layout. The factory will use an incrementing id to name each component. When an Panel is added it will automatically become the parent for subsequent components added using the factory. If another parent component is needed then the parent can be explicitly set.
When components are added their size is checked against that of the parent and reduced if they extend beyond the bounds of the parent.
The component factory can be extended by registering new ComponentConstructors. These constructors are invoked if the build in constructors cannot build the specified type.
Components can be specified by a type name, an type constant or by a class name. The type constants for the built-in components are specified in Page so as to make referencing the constants easier in the client code (subclasses of Page). The package name is set as an attribute of the factory so that various versions of the widgets can be create for say Swing and AWT without needing to create distinct factories and without need to include such implementation details in the client code.
Copyright (c) Formaria Ltd., 2008
License: see license.txt
$Revision: 2.21 $
| Field Summary | |
|---|---|
protected WidgetAdapter |
adapter
The adapter used for the current package's widgets |
static int |
ANNOTATEDIMAGE
A constant used internally to identify an annotated image component. |
protected java.lang.String |
basePackageName
The package to which the widgets belong |
static int |
BUTTON
A constant used internally to identify a push buttob. |
static int |
CHECK
A constant used internally to identify a Checkbox. |
static int |
COMBO
A constant used internally to identify a Combo Box. |
protected static java.util.Hashtable |
componentFactories
A collection of component factories |
protected java.lang.Object |
currentMenu
The current menu. |
protected java.lang.Object |
currentMenuBar
The application's menu bar |
protected Project |
currentProject
The project that owns this factory |
static int |
EDIT
A constant used internally to identify a Edit field. |
static int |
GROUP
A constant used internally to identify a RadioButton group. |
static int |
HOTSPOTIMAGE
A constant used internally to identify a hotspot image. |
static int |
IMAGE
A constant used internally to identify an image component. |
static int |
IMAGEMAP
A constant used internally to identify an image map. |
static int |
LABEL
A static text |
protected static LayoutHelper |
layoutHelper
A helper to construct various layout managers |
static int |
LIST
A constant used internally to identify a List. |
static int |
MENU
A constant used internally to identify a Menu. |
static int |
MENUBAR
A constant used internally to identify a MenuBar. |
static int |
MENUITEM
A constant used internally to identify a Menu item. |
static int |
METACONTENT
A constant used internally to identify a container for tagged content. |
static int |
PANEL
A panel / container |
protected int |
parentH
|
protected java.lang.Object |
parentPanel
The parent panel to which components are added |
protected int |
parentW
|
static int |
PASSWORD
A constant used internally to identify a password field. |
static int |
RADIO
A constant used internally to identify a RadioButton. |
protected static boolean |
requiresParent
A flag indicating is the components require the parent object to be passed as an argumnet to the constructor. |
static int |
SCROLLABLEMETACONTENT
A constant used internally to identify a scrollable meta content. |
static int |
SCROLLPANE
A constant used internally to identify a scroll panel. |
static int |
SPLITPANE
A constant used internally to identify a splitter. |
static int |
TABLE
A constant used internally to identify a table component. |
static int |
TABPANEL
A constant used internally to identify a tab panel. |
static int |
TEXTAREA
A constant used internally to identify a multiline text edit component. |
protected Translator |
translator
The translator used for translation |
protected static java.util.Hashtable |
typeNames
A collection of component type names and ids used to aid construction of components |
static int |
UNKNOWN
A component of a type that is unknown to Aria (i.e. |
static int |
WMF
A constant used internally to identify a vector image component. |
| Constructor Summary | |
|---|---|
ComponentFactory(Project proj,
java.lang.String packageName)
Constructs a component factory |
|
| Method Summary | |
|---|---|
java.lang.Object |
addComponent(java.lang.Object c)
Add a component to the panel. |
java.lang.Object |
addComponent(java.lang.Object c,
java.lang.Object constraint)
Add a component to the panel. |
java.lang.Object |
addComponent(java.lang.String type,
java.lang.String nameStr,
int x,
int y,
int w,
int h,
java.lang.String content)
A generic factory for adding Components. |
java.lang.Object |
addComponent(java.lang.String type,
java.lang.String nameStr,
java.lang.Object pos,
java.lang.String content)
A generic factory for adding Components. |
java.lang.Object |
addElement(java.lang.String type,
java.lang.String name,
java.lang.String content,
java.util.Hashtable attribs)
Add a non-component object to the panel or an element of the panel. |
java.lang.Object |
addLayout(java.lang.Object cont,
int type)
Sets a LayoutManager for the panel |
protected java.lang.Object |
buildRegisteredComponent(java.lang.String type,
java.lang.String content)
A generic factory for adding registered components via the ComponentConstructor interface or component factories. |
java.lang.Object |
constructComponent(java.lang.String type,
java.lang.String content)
A generic factory for constructing Components. |
ComponentAdapter |
getComponentAdapter(java.lang.String type)
Lookup the component adapter for the named type |
static java.util.Hashtable |
getFactories()
Get the component factories |
static LayoutHelper |
getLayoutHelper()
Get the layout helper |
java.lang.Object |
getParentComponent()
Get the current parent component |
protected static int |
getTypeCode(java.lang.String typeName)
Get the type constant associated with a type name |
protected java.lang.Object |
instantiate(java.lang.String className)
Instantiate a component using reflection to locate the constructor. |
static void |
registerComponentFactory(java.lang.String name,
ComponentConstructor factory)
Add a componentFactory to the static register of component constructors |
static void |
setLayoutHelper(LayoutHelper newHelper)
Set the layout helper |
void |
setParentComponent(java.lang.Object c)
Change the parent for new components. |
static void |
setRequiresParent(boolean b)
Flags whether or not the component constructors require the parent as an argument. |
void |
setResourceBundle(java.lang.String resourceBundleName)
Set the resource bundle for this component factory. |
protected static void |
setupTypeNames()
Setup a hashtable of type names. |
java.lang.String |
translate(java.lang.String key)
Look up the translation of a key using the current language resource |
static void |
updateComponentFactories()
Notify the component factories that some of their settings may have changed |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int UNKNOWN
public static final int PANEL
public static final int LABEL
public static final int RADIO
public static final int CHECK
public static final int COMBO
public static final int LIST
public static final int IMAGE
public static final int EDIT
public static final int BUTTON
public static final int METACONTENT
public static final int GROUP
public static final int SCROLLPANE
public static final int SCROLLABLEMETACONTENT
public static final int HOTSPOTIMAGE
public static final int TABLE
public static final int WMF
public static final int ANNOTATEDIMAGE
public static final int MENUBAR
public static final int MENU
public static final int MENUITEM
public static final int TEXTAREA
public static final int PASSWORD
public static final int IMAGEMAP
public static final int TABPANEL
public static final int SPLITPANE
protected static java.util.Hashtable componentFactories
protected static java.util.Hashtable typeNames
protected static LayoutHelper layoutHelper
protected static boolean requiresParent
protected java.lang.String basePackageName
protected Translator translator
protected Project currentProject
protected WidgetAdapter adapter
protected java.lang.Object currentMenuBar
protected java.lang.Object currentMenu
protected java.lang.Object parentPanel
protected int parentW
protected int parentH
| Constructor Detail |
|---|
public ComponentFactory(Project proj,
java.lang.String packageName)
proj - The project to which the fctory belongspackageName - the package name for the components| Method Detail |
|---|
public void setResourceBundle(java.lang.String resourceBundleName)
resourceBundleName - the resource bundle name
public java.lang.Object constructComponent(java.lang.String type,
java.lang.String content)
type - a name identifying the type of component to be createdcontent - the component text/content
protected java.lang.Object instantiate(java.lang.String className)
className - the class to instantiate
public java.lang.String translate(java.lang.String key)
key - the key string
public java.lang.Object addComponent(java.lang.String type,
java.lang.String nameStr,
int x,
int y,
int w,
int h,
java.lang.String content)
type - a name identifying the type of component to be createdx - the left coordinatey - the top coordinatew - the widthh - the heightcontent - the component text/content
public java.lang.Object addComponent(java.lang.String type,
java.lang.String nameStr,
java.lang.Object pos,
java.lang.String content)
type - a name identifying the type of component to be createdpos - the constraintcontent - the component text/content
protected java.lang.Object buildRegisteredComponent(java.lang.String type,
java.lang.String content)
type - a name identifying the type of component to be createdcontent - the component text/content
public ComponentAdapter getComponentAdapter(java.lang.String type)
type - a name identifying the type of component to be created
public static void registerComponentFactory(java.lang.String name,
ComponentConstructor factory)
name - the name by which this factory will be known.factory - the new componentFactorypublic static void updateComponentFactories()
public static java.util.Hashtable getFactories()
public java.lang.Object addElement(java.lang.String type,
java.lang.String name,
java.lang.String content,
java.util.Hashtable attribs)
type - the object typename - a name identifying the element to be createdcontent - the component text/contentattribs - the element attributes if any
public java.lang.Object addComponent(java.lang.Object c)
c - the component to add
public java.lang.Object addComponent(java.lang.Object c,
java.lang.Object constraint)
c - the component to addconstraint - the layout manager constraint
public java.lang.Object addLayout(java.lang.Object cont,
int type)
cont - the container whose layout manager is being set or null to set the parent panel's layout managertype - the layout manager as defined in the LayoutHelper class
public void setParentComponent(java.lang.Object c)
c - the new parent, this should be an instance of java.awt.Containerpublic java.lang.Object getParentComponent()
public static LayoutHelper getLayoutHelper()
public static void setLayoutHelper(LayoutHelper newHelper)
newHelper - the new layout helperprotected static int getTypeCode(java.lang.String typeName)
typeName - the type name
protected static void setupTypeNames()
public static void setRequiresParent(boolean b)
b - true to pass the parent to the constructor
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||