com.taco.swinger.text2gui
Class ComponentAddStrategyProvider

java.lang.Object
  extended by com.taco.swinger.text2gui.ComponentAddStrategyProvider
All Implemented Interfaces:
IComponentAddStrategyProvider

public class ComponentAddStrategyProvider
extends java.lang.Object
implements IComponentAddStrategyProvider

A concrete implementation of IComponentAddStrategyProvider which uses a map from layout classes to component add strategies.


Field Summary
protected static java.util.Map _DEFAULT_LAYOUT_CLASS_TO_ADD_STRATEGY_MAP
          A map from class objects of layout managers to instances of ComponentAddStrategy that specify how to add components to containers with the corresponding layouts.
protected  java.util.Map _layoutClassToAddStrategyMap
          The map from layout classes to component add strategies.
static ComponentAddStrategyProvider DEFAULT_INSTANCE
          The default instance of this class, which uses the zero-argument constructor.
 
Constructor Summary
protected ComponentAddStrategyProvider()
          Construct an instance using the default layout class to component add strategy map.
  ComponentAddStrategyProvider(java.util.Map layoutClassToAddStrategyMap)
          Construct an instance using the argument layout class to component add strategy map.
 
Method Summary
 IComponentAddStrategy getComponentAddStrategy(java.awt.Container container)
          Look up the class of the layout in the map provided to the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_layoutClassToAddStrategyMap

protected final java.util.Map _layoutClassToAddStrategyMap
The map from layout classes to component add strategies.


_DEFAULT_LAYOUT_CLASS_TO_ADD_STRATEGY_MAP

protected static final java.util.Map _DEFAULT_LAYOUT_CLASS_TO_ADD_STRATEGY_MAP
A map from class objects of layout managers to instances of ComponentAddStrategy that specify how to add components to containers with the corresponding layouts.


DEFAULT_INSTANCE

public static final ComponentAddStrategyProvider DEFAULT_INSTANCE
The default instance of this class, which uses the zero-argument constructor.

Constructor Detail

ComponentAddStrategyProvider

protected ComponentAddStrategyProvider()
Construct an instance using the default layout class to component add strategy map. Since such an instance is saved in DEFAULT_INSTANCE and has no state, this constructor is protected.


ComponentAddStrategyProvider

public ComponentAddStrategyProvider(java.util.Map layoutClassToAddStrategyMap)
Construct an instance using the argument layout class to component add strategy map. The argument map is not copied!

Method Detail

getComponentAddStrategy

public IComponentAddStrategy getComponentAddStrategy(java.awt.Container container)

Look up the class of the layout in the map provided to the constructor. If the class is found, return the corresponding strategy. Otherwise, use reflection to compute the superclass of the layout, and repeat.

Specified by:
getComponentAddStrategy in interface IComponentAddStrategyProvider