|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.xoetrope.xui.XComponentFactory
public class XComponentFactory
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 XPanel 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 XComponentConstructors. 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 XPage so as to make referencing the constants easier in the client code (subclasses of XPage). 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) Xoetrope Ltd., 2002-2003
License: see license.txt
$Revision: 2.21 $
| Field Summary | |
|---|---|
protected WidgetAdapter |
adapter
The adapter used for the current package's widgets |
protected java.lang.String |
basePackageName
The package to which the widgets belong |
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 XProject |
currentProject
The project that owns this factory |
protected static LayoutHelper |
layoutHelper
A helper to construct various layout managers |
protected int |
parentH
|
protected java.lang.Object |
parentPanel
The parent panel to which components are added |
protected int |
parentW
|
protected static boolean |
requiresParent
A flag indicating is the components require the parent object to be passed as an argumnet to the constructor. |
protected XTranslator |
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 |
XANNOTATEDIMAGE
A constant used internally to identify an annotated image component. |
static int |
XBUTTON
A constant used internally to identify a push buttob. |
static int |
XCHECK
A constant used internally to identify a Checkbox. |
static int |
XCOMBO
A constant used internally to identify a Combo Box. |
static int |
XEDIT
A constant used internally to identify a Edit field. |
static int |
XGROUP
A constant used internally to identify a RadioButton group. |
static int |
XHOTSPOTIMAGE
A constant used internally to identify a hotspot image. |
static int |
XIMAGE
A constant used internally to identify an image component. |
static int |
XIMAGEMAP
A constant used internally to identify an image map. |
static int |
XLABEL
A static text |
static int |
XLIST
A constant used internally to identify a List. |
static int |
XMENU
A constant used internally to identify a Menu. |
static int |
XMENUBAR
A constant used internally to identify a MenuBar. |
static int |
XMENUITEM
A constant used internally to identify a Menu item. |
static int |
XMETACONTENT
A constant used internally to identify a container for tagged content. |
static int |
XPANEL
A panel / container |
static int |
XPASSWORD
A constant used internally to identify a password field. |
static int |
XRADIO
A constant used internally to identify a RadioButton. |
static int |
XSCROLLABLEMETACONTENT
A constant used internally to identify a scrollable meta content. |
static int |
XSCROLLPANE
A constant used internally to identify a scroll panel. |
static int |
XSPLITPANE
A constant used internally to identify a splitter. |
static int |
XTABLE
A constant used internally to identify a table component. |
static int |
XTABPANEL
A constant used internally to identify a tab panel. |
static int |
XTEXTAREA
A constant used internally to identify a multiline text edit component. |
static int |
XUNKNOWN
A component of a type that is unknown to XUI (i.e. not one of the built in types) |
static int |
XWMF
A constant used internally to identify a vector image component. |
| Constructor Summary | |
|---|---|
XComponentFactory(XProject proj,
java.lang.String packageName)
Constructs a component factory |
|
| Method Summary | |
|---|---|
void |
addComponent(java.lang.Object c)
Add a component to the panel. |
void |
addComponent(java.lang.Object c,
java.lang.Object constraint)
Add a component to the panel. |
java.lang.Object |
addComponent(java.lang.String type,
int x,
int y,
int w,
int h,
java.lang.String content)
A generic factory for adding XComponents. |
java.lang.Object |
addComponent(java.lang.String type,
java.lang.Object pos,
java.lang.String content)
A generic factory for adding XComponents. |
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 XComponentConstructor interface or component factories. |
java.lang.Object |
constructComponent(java.lang.String type,
java.lang.String content)
A generic factory for constructing XComponents. |
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,
XComponentConstructor 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 XUNKNOWN
public static final int XPANEL
public static final int XLABEL
public static final int XRADIO
public static final int XCHECK
public static final int XCOMBO
public static final int XLIST
public static final int XIMAGE
public static final int XEDIT
public static final int XBUTTON
public static final int XMETACONTENT
public static final int XGROUP
public static final int XSCROLLPANE
public static final int XSCROLLABLEMETACONTENT
public static final int XHOTSPOTIMAGE
public static final int XTABLE
public static final int XWMF
public static final int XANNOTATEDIMAGE
public static final int XMENUBAR
public static final int XMENU
public static final int XMENUITEM
public static final int XTEXTAREA
public static final int XPASSWORD
public static final int XIMAGEMAP
public static final int XTABPANEL
public static final int XSPLITPANE
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 XTranslator translator
protected XProject 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 XComponentFactory(XProject 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,
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.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,
XComponentConstructor 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 void addComponent(java.lang.Object c)
c - the component to add
public void 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 XLayoutHelper 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 | |||||||||