org.norther.tammi.leaf.jfc
Class DefaultJFCFactory

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.base.DefaultObjectFactory<Component>
          extended by org.norther.tammi.leaf.jfc.DefaultJFCFactory
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Manageable, MBeanDelegate, ObjectFactory<Component>, JFCFactory

public class DefaultJFCFactory
extends DefaultObjectFactory<Component>
implements JFCFactory

A default implementation of JFCFactory. The factory accepts either an explicit lookup resource bundle or a parent component as the second additional constructor parameter for component resources. Both of them require a widget name as the first constructor parameter to resolve resource names.

Version:
$Id: DefaultJFCFactory.java,v 1.12 2009/09/28 15:08:20 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
static int DEFAULT_SPACING
          The default spacing.
static String TEXT
          The text resource.
static String TITLE
          The title resource.
static String TOOL_TIP_TEXT
          The tool tip text resource.
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Constructor Summary
DefaultJFCFactory()
          Constructs a new factory.
 
Method Summary
 Border createEmptyBorder()
          Creates an empty border of the size of the current spacing.
 Border createEmptyBorder(int top, int left, int bottom, int right)
          Creates an empty border of the specified size.
 Component createFiller(Dimension min, Dimension pref, Dimension max)
          Creates a filler of the specified size.
 Component createGlue()
          Creates glue.
 Component createHorizontalArea(int height)
          Creates a horizontal area of the width of the current spacing.
 Component createHorizontalGlue()
          Creates horizontal glue.
 Component createHorizontalStrut()
          Creates a horizontal strut of the size of the current spacing.
 Component createRigidArea()
          Creates a rigid area of the size of the current spacing.
 Component createRigidArea(Dimension dim)
          Creates a rigid area with the specified dimensions.
 Component createRigidArea(int width, int height)
          Creates a rigid area of the specified size.
 Component createVerticalArea(int width)
          Creates a vertical area of the height of the current spacing.
 Component createVerticalGlue()
          Creates vertical glue.
 Component createVerticalStrut()
          Creates a vertical strut of the size of the current spacing.
protected  Component findComponent(Component root, String name, String path, boolean wildcard, String className)
          Finds the named component of the specified type.
 Component findComponent(Container parent, String path)
          Finds the named component under the specified parent.
 Component findComponent(Container parent, String path, String className)
          Finds the named component of the specified type under the specified parent.
 Component findComponent(String path)
          Finds the named component.
 Component findComponent(String path, String className)
          Finds the named component of the specified type.
 Component getInstance(String className, ObjectName loader, Object[] params, String[] signature)
          Gets an instance of a named class using a specified class loader.
 Component getInstance(String className, ObjectName loader, String name, Container parent)
          Gets a new JFC instance for a specified parent by applying the named class loader.
 Component getInstance(String className, ObjectName loader, String name, Container parent, Object[] params, String[] signature)
          Gets a new JFC instance for a specified parent by applying constructor parameters and the named class loader.
 Component getInstance(String className, ObjectName loader, String name, LookupResourceBundle bundle)
          Gets a new JFC instance with specified resources by applying the named class loader.
 Component getInstance(String className, ObjectName loader, String name, LookupResourceBundle bundle, Object[] params, String[] signature)
          Gets a new JFC instance with specified resources by applying constructor parameters and the named class loader.
 Component getInstance(String className, String name, Container parent)
          Gets a new JFC instance for a specified parent.
 Component getInstance(String className, String name, Container parent, Object[] params, String[] signature)
          Gets a new JFC instance for a specified parent by applying constructor parameters.
 Component getInstance(String className, String name, LookupResourceBundle bundle)
          Gets a new JFC instance with specified resources.
 Component getInstance(String className, String name, LookupResourceBundle bundle, Object[] params, String[] signature)
          Gets a new JFC instance with specified resources by applying constructor parameters.
 String getResource(String resource, Component component, Container parent)
          Gets the specified resource of the named component from the resource hierarchy.
 String getResource(String resource, Component component, LookupResourceBundle bundle)
          Gets the specified resource of the named component from the resource bundle.
 ObjectName getResourceFinderName()
          Gets the the resource finder of this factory.
 int getSpacing()
          Gets the current spacing between components.
protected  void loadResources(Object wid, String name, List<LookupResourceBundle> bundles)
          Loads resources of the specified widget.
 void postmanaged()
          This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.
 void resetSystemLookAndFeel()
          Resets the system specific look-and-feel.
 void setResourceFinderName(ObjectName finder)
          Sets the resource finder of this factory.
 void setSpacing(int space)
          Sets the current spacing between components.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
 
Methods inherited from class org.norther.tammi.core.base.DefaultObjectFactory
getInstance, getInstance, getInstance, isLoaderSupported
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.base.ObjectFactory
getInstance, getInstance, getInstance, isLoaderSupported
 

Field Detail

TITLE

public static final String TITLE
The title resource.

See Also:
Constant Field Values

TEXT

public static final String TEXT
The text resource.

See Also:
Constant Field Values

TOOL_TIP_TEXT

public static final String TOOL_TIP_TEXT
The tool tip text resource.

See Also:
Constant Field Values

DEFAULT_SPACING

public static final int DEFAULT_SPACING
The default spacing.

See Also:
Constant Field Values
Constructor Detail

DefaultJFCFactory

public DefaultJFCFactory()
Constructs a new factory.

Method Detail

postmanaged

public void postmanaged()
Description copied from interface: Manageable
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.

Specified by:
postmanaged in interface Manageable
Overrides:
postmanaged in class Adaptee

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Overrides:
unmanaged in class Adaptee
Throws:
Exception - if the adaptee refused to be unmanaged.

getResourceFinderName

public ObjectName getResourceFinderName()
Description copied from interface: JFCFactory
Gets the the resource finder of this factory.

Specified by:
getResourceFinderName in interface JFCFactory
Returns:
the object name of the resource finder or a query.

setResourceFinderName

public void setResourceFinderName(ObjectName finder)
Description copied from interface: JFCFactory
Sets the resource finder of this factory. If it is not set, the default one will be used.

Specified by:
setResourceFinderName in interface JFCFactory
Parameters:
finder - the object name of the resource finder or a query.

getResource

public String getResource(String resource,
                          Component component,
                          LookupResourceBundle bundle)
Description copied from interface: JFCFactory
Gets the specified resource of the named component from the resource bundle.

Specified by:
getResource in interface JFCFactory
Parameters:
resource - the name of the resource.
component - the named component.
bundle - the resource bundle.
Returns:
the resource string or null.

getResource

public String getResource(String resource,
                          Component component,
                          Container parent)
Description copied from interface: JFCFactory
Gets the specified resource of the named component from the resource hierarchy.

Specified by:
getResource in interface JFCFactory
Parameters:
resource - the name of the resource.
component - the named component.
parent - the parent of the component.
Returns:
the resource string or null.

getInstance

public Component getInstance(String className,
                             String name,
                             Container parent)
                      throws ConstructionException
Description copied from interface: JFCFactory
Gets a new JFC instance for a specified parent.

Specified by:
getInstance in interface JFCFactory
Parameters:
className - the class name of the component.
name - the name of the component.
parent - the parent of the component.
Returns:
the new instance.
Throws:
ConstructionException - if construction fails.

getInstance

public Component getInstance(String className,
                             String name,
                             LookupResourceBundle bundle)
                      throws ConstructionException
Description copied from interface: JFCFactory
Gets a new JFC instance with specified resources.

Specified by:
getInstance in interface JFCFactory
Parameters:
className - the class name of the component.
name - the name of the component.
bundle - the resource bundle.
Returns:
the new instance.
Throws:
ConstructionException - if construction fails.

getInstance

public Component getInstance(String className,
                             String name,
                             Container parent,
                             Object[] params,
                             String[] signature)
                      throws ConstructionException
Description copied from interface: JFCFactory
Gets a new JFC instance for a specified parent by applying constructor parameters.

Specified by:
getInstance in interface JFCFactory
Parameters:
className - the class name of the component.
name - the name of the component.
parent - the parent of the component.
params - the parameters.
signature - the signature.
Returns:
the new instance.
Throws:
ConstructionException - if construction fails.

getInstance

public Component getInstance(String className,
                             String name,
                             LookupResourceBundle bundle,
                             Object[] params,
                             String[] signature)
                      throws ConstructionException
Description copied from interface: JFCFactory
Gets a new JFC instance with specified resources by applying constructor parameters.

Specified by:
getInstance in interface JFCFactory
Parameters:
className - the class name of the component.
name - the name of the component.
bundle - the resource bundle.
params - the parameters.
signature - the signature.
Returns:
the new instance.
Throws:
ConstructionException - if construction fails.

getInstance

public Component getInstance(String className,
                             ObjectName loader,
                             String name,
                             Container parent)
                      throws ConstructionException
Description copied from interface: JFCFactory
Gets a new JFC instance for a specified parent by applying the named class loader.

Specified by:
getInstance in interface JFCFactory
Parameters:
className - the class name of the component.
loader - the class loader to apply.
name - the name of the component.
parent - the parent of the component.
Returns:
the new instance.
Throws:
ConstructionException - if construction fails.

getInstance

public Component getInstance(String className,
                             ObjectName loader,
                             String name,
                             LookupResourceBundle bundle)
                      throws ConstructionException
Description copied from interface: JFCFactory
Gets a new JFC instance with specified resources by applying the named class loader.

Specified by:
getInstance in interface JFCFactory
Parameters:
className - the class name of the component.
loader - the class loader to apply.
name - the name of the component.
bundle - the resource bundle.
Returns:
the new instance.
Throws:
ConstructionException - if construction fails.

getInstance

public Component getInstance(String className,
                             ObjectName loader,
                             String name,
                             Container parent,
                             Object[] params,
                             String[] signature)
                      throws ConstructionException
Description copied from interface: JFCFactory
Gets a new JFC instance for a specified parent by applying constructor parameters and the named class loader.

Specified by:
getInstance in interface JFCFactory
Parameters:
className - the class name of the component.
loader - the class loader to apply.
name - the name of the component.
parent - the parent of the component.
params - the parameters.
signature - the signature.
Returns:
the new instance.
Throws:
ConstructionException - if construction fails.

getInstance

public Component getInstance(String className,
                             ObjectName loader,
                             String name,
                             LookupResourceBundle bundle,
                             Object[] params,
                             String[] signature)
                      throws ConstructionException
Description copied from interface: JFCFactory
Gets a new JFC instance with specified resources by applying constructor parameters and the named class loader.

Specified by:
getInstance in interface JFCFactory
Parameters:
className - the class name of the component.
loader - the class loader to apply.
name - the name of the component.
bundle - the resource bundle.
params - the parameters.
signature - the signature.
Returns:
the new instance.
Throws:
ConstructionException - if construction fails.

getSpacing

public int getSpacing()
Description copied from interface: JFCFactory
Gets the current spacing between components.

Specified by:
getSpacing in interface JFCFactory
Returns:
the spacing.

setSpacing

public void setSpacing(int space)
Description copied from interface: JFCFactory
Sets the current spacing between components.

Specified by:
setSpacing in interface JFCFactory
Parameters:
space - the spacing.

createEmptyBorder

public Border createEmptyBorder()
Description copied from interface: JFCFactory
Creates an empty border of the size of the current spacing.

Specified by:
createEmptyBorder in interface JFCFactory
Returns:
an empty border.

createEmptyBorder

public Border createEmptyBorder(int top,
                                int left,
                                int bottom,
                                int right)
Description copied from interface: JFCFactory
Creates an empty border of the specified size.

Specified by:
createEmptyBorder in interface JFCFactory
Parameters:
top - the top width.
left - the left width.
bottom - the bottom width.
right - the right width.
Returns:
an empty border.

createHorizontalStrut

public Component createHorizontalStrut()
Description copied from interface: JFCFactory
Creates a horizontal strut of the size of the current spacing.

Specified by:
createHorizontalStrut in interface JFCFactory
Returns:
the horizontal strut.

createVerticalStrut

public Component createVerticalStrut()
Description copied from interface: JFCFactory
Creates a vertical strut of the size of the current spacing.

Specified by:
createVerticalStrut in interface JFCFactory
Returns:
the vertical strut.

createRigidArea

public Component createRigidArea()
Description copied from interface: JFCFactory
Creates a rigid area of the size of the current spacing.

Specified by:
createRigidArea in interface JFCFactory
Returns:
the rigid area.

createRigidArea

public Component createRigidArea(Dimension dim)
Description copied from interface: JFCFactory
Creates a rigid area with the specified dimensions.

Specified by:
createRigidArea in interface JFCFactory
Parameters:
dim - the dimensions.
Returns:
the rigid area.

createRigidArea

public Component createRigidArea(int width,
                                 int height)
Description copied from interface: JFCFactory
Creates a rigid area of the specified size.

Specified by:
createRigidArea in interface JFCFactory
Parameters:
width - the width.
height - the height.
Returns:
the rigid area.

createHorizontalArea

public Component createHorizontalArea(int height)
Description copied from interface: JFCFactory
Creates a horizontal area of the width of the current spacing.

Specified by:
createHorizontalArea in interface JFCFactory
Parameters:
height - the height of the area.
Returns:
the horizontal area.

createVerticalArea

public Component createVerticalArea(int width)
Description copied from interface: JFCFactory
Creates a vertical area of the height of the current spacing.

Specified by:
createVerticalArea in interface JFCFactory
Parameters:
width - the width of the area.
Returns:
the vertical area.

createFiller

public Component createFiller(Dimension min,
                              Dimension pref,
                              Dimension max)
Description copied from interface: JFCFactory
Creates a filler of the specified size.

Specified by:
createFiller in interface JFCFactory
Parameters:
min - the minimum size.
pref - the preferred size.
max - the maximum size.
Returns:
the filler.

createGlue

public Component createGlue()
Description copied from interface: JFCFactory
Creates glue.

Specified by:
createGlue in interface JFCFactory
Returns:
the glue.

createHorizontalGlue

public Component createHorizontalGlue()
Description copied from interface: JFCFactory
Creates horizontal glue.

Specified by:
createHorizontalGlue in interface JFCFactory
Returns:
the horizontal glue.

createVerticalGlue

public Component createVerticalGlue()
Description copied from interface: JFCFactory
Creates vertical glue.

Specified by:
createVerticalGlue in interface JFCFactory
Returns:
the vertical glue.

getInstance

public Component getInstance(String className,
                             ObjectName loader,
                             Object[] params,
                             String[] signature)
                      throws ConstructionException
Description copied from interface: ObjectFactory
Gets an instance of a named class using a specified class loader. Parameters for its constructor are given as an array of objects, primitive types must be wrapped with a corresponding class.

Class loaders are supported only if the isLoaderSupported method returns true. Otherwise the loader parameter is ignored.

Specified by:
getInstance in interface ObjectFactory<Component>
Overrides:
getInstance in class DefaultObjectFactory<Component>
Parameters:
className - the name of the class.
loader - the class loader.
params - an array containing the parameters of the constructor.
signature - an array containing the signature of the constructor.
Returns:
the instance.
Throws:
ConstructionException - if construction fails.

findComponent

public Component findComponent(String path)
Description copied from interface: JFCFactory
Finds the named component.

Specified by:
findComponent in interface JFCFactory
Parameters:
path - the name path of the component.
Returns:
the found component or null.

findComponent

public Component findComponent(String path,
                               String className)
Description copied from interface: JFCFactory
Finds the named component of the specified type.

Specified by:
findComponent in interface JFCFactory
Parameters:
path - the name path of the component.
className - the class name of the component.
Returns:
the found component or null.

findComponent

public Component findComponent(Container parent,
                               String path)
Description copied from interface: JFCFactory
Finds the named component under the specified parent.

Specified by:
findComponent in interface JFCFactory
Parameters:
parent - the parent of the component.
path - the name path of the component.
Returns:
the found component or null.

findComponent

public Component findComponent(Container parent,
                               String path,
                               String className)
Description copied from interface: JFCFactory
Finds the named component of the specified type under the specified parent.

Specified by:
findComponent in interface JFCFactory
Parameters:
parent - the parent of the component.
path - the name path of the component.
className - the class name of the component.
Returns:
the found component or null.

resetSystemLookAndFeel

public void resetSystemLookAndFeel()
Description copied from interface: JFCFactory
Resets the system specific look-and-feel.

Specified by:
resetSystemLookAndFeel in interface JFCFactory

findComponent

protected Component findComponent(Component root,
                                  String name,
                                  String path,
                                  boolean wildcard,
                                  String className)
Finds the named component of the specified type.

Parameters:
root - the root component.
name - the name of the component.
path - the name path of the parent.
wildcard - the wildcard option.
className - the class name of the component.
Returns:
the found component or null.

loadResources

protected void loadResources(Object wid,
                             String name,
                             List<LookupResourceBundle> bundles)
Loads resources of the specified widget.

Parameters:
wid - the widget.
name - the name of the widget.
bundles - a list of resource bundles of the widget.


Copyright © 2004 The Norther Organization. All rights reserved.