org.jdesktop.jdnc.form
Class ComponentMap

java.lang.Object
  extended by org.jdesktop.jdnc.form.ComponentMap

public class ComponentMap
extends java.lang.Object

Choosing strategy for creating components.

Extracted from DefaultFormFactory to have a "pluggable" place for creating custom components. The usage of a ComponentCreator should be viewed as an implementation detail, they don't do much.

The created components have their name property set to metaData.name. This will enable searching for them in a container and facilitates testing.

PENDING: should be factored into an interface and a default implementation.

PENDING: think about task distribution - only visual aspects of the metaData should be handled here.

Author:
Jeanette Winzenburg

Nested Class Summary
static class ComponentMap.BooleanCreator
           
static class ComponentMap.DatePickerCreator
           
static class ComponentMap.EnumerationCreator
           
static class ComponentMap.FormCreator
           
static class ComponentMap.ImagePanelCreator
           
static class ComponentMap.LabelCreator
           
static class ComponentMap.LinkLabelCreator
           
static class ComponentMap.ListCreator
           
 class ComponentMap.NumberCreator
          creates JSpinner if metaData is NumberMetaData, the map's fallback component otherwise.
static class ComponentMap.TableCreator
           
static class ComponentMap.TextCreator
          creates and returns a JTextComponent.
 
Constructor Summary
ComponentMap()
           
 
Method Summary
protected  java.lang.Class checkForArray(java.lang.Class elementClass)
           
 javax.swing.JComponent createComponent(MetaData metaData)
          creates and returns a component based on the given MetaData.
protected  ComponentCreator findByClass(java.lang.Class elementClass)
           
protected  ComponentCreator findByElementClass(java.lang.Class elementClass)
           
protected  ComponentCreator getComponentCreator(MetaData metaData)
          Encapsulates lookup-strategy to find a fitting ComponentCreator.
protected  ComponentCreator getFallBackComponentCreator()
           
static ComponentMap getInstance()
           
protected  void initAssignablesClasses(java.util.List assignables)
           
protected  void initCreators(java.util.Map map)
           
static void setInstance(ComponentMap map)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentMap

public ComponentMap()
Method Detail

getInstance

public static ComponentMap getInstance()

setInstance

public static void setInstance(ComponentMap map)

createComponent

public javax.swing.JComponent createComponent(MetaData metaData)
creates and returns a component based on the given MetaData.

Parameters:
metaData -
Returns:

getComponentCreator

protected ComponentCreator getComponentCreator(MetaData metaData)
Encapsulates lookup-strategy to find a fitting ComponentCreator.

Here:

  1. look-up by metaData.class, if nothing found
  2. look-up by metaData.elementClass, if nothing found
  3. fallback component

Parameters:
metaData -
Returns:
Throws:
java.lang.NullPointerException - if metaData == null

findByElementClass

protected ComponentCreator findByElementClass(java.lang.Class elementClass)

checkForArray

protected java.lang.Class checkForArray(java.lang.Class elementClass)

findByClass

protected ComponentCreator findByClass(java.lang.Class elementClass)

getFallBackComponentCreator

protected ComponentCreator getFallBackComponentCreator()

initCreators

protected void initCreators(java.util.Map map)

initAssignablesClasses

protected void initAssignablesClasses(java.util.List assignables)


Copyright © 2005 Sun Microsystems All Rights Reserved.