com.taco.swinger.text2gui
Class DispatchingComponentConverter

java.lang.Object
  extended by com.taco.text.AbstractInterpolatingStringToObjectConverter
      extended by com.taco.text.InterpolatingConverter
          extended by com.taco.text.DispatchingConverter
              extended by com.taco.swinger.text2gui.DispatchingComponentConverter
All Implemented Interfaces:
IInterpolatingConverter, IInterpolatingStringToObjectConverter, IStringToObjectConverter, IInterpolatingResourceBundleToObjectConverter, java.io.Serializable, java.lang.Cloneable

public class DispatchingComponentConverter
extends DispatchingConverter

A converter from resource bundles or strings to components. Because there exists a wide variety of components, this class acts as a dispatcher to installed string to component. The first word of a string is used to select the appropriate component converter for the entire string. By itself, this class supports the following types of components: JApplet, JFrame, JDialog, JWindow, JOptionPane, JPanel, Box, JLayeredPane, JDesktopPane, JSplitPane, JTabbedPane, JScrollPane, JInternalFrame, JLayeredPane, JDesktopPane, JButton, JRadioButton, JCheckBox, JMenu, JMenuItem, JCheckBoxMenuItem, JRadioButtonMenuItem, JLabel, JToolBar, JTextField, JPasswordTextField, JFormattedTextField, JTextArea, JEditorPane, JComboBox, JSlider, JSpinner, JProgressBar, JScrollBar, JList, JTable, JTree, glue, rigid area, and filler.

Additional types of components can be installed with installConverter().

See Also:
Serialized Form

Field Summary
protected  IComponentAddStrategyProvider _componentAddStrategyProvider
          The provider of strategies for adding components to a container.
static DispatchingComponentConverter DEFAULT_INSTANCE
          The default instance of this class, which uses the default component add strategy provider.
 
Fields inherited from class com.taco.text.DispatchingConverter
_suffixToTypeMap, _typeToConfigurerMap, _typeToConverterMap
 
Fields inherited from class com.taco.text.InterpolatingConverter
_BAD_OBJECT_MAPPER, _IGNORE_PROPERTY_VALUE, _IMPORTS, _STATIC_IMPORTS, _TO_OBJECT_MAPPER_CONVERTER
 
Fields inherited from class com.taco.text.AbstractInterpolatingStringToObjectConverter
_defArgMap, _defBundle
 
Constructor Summary
DispatchingComponentConverter()
          Create a new instance which uses the default instance of ComponentAddStrategyProvider.
DispatchingComponentConverter(IComponentAddStrategyProvider provider)
          Create a new instance which uses provider to provide component adders for layouts.
DispatchingComponentConverter(IComponentAddStrategyProvider provider, java.util.ResourceBundle bundle, INoReturnMap argMap)
          Create a new instance which uses provider to provide component adders for layouts.
 
Method Summary
protected  void _installSuffixToTypeMappings()
          Install mappings from resource bundle key suffixes to dispatch types, in case the ".dispatchType" subkey is not present.
 IComponentAddStrategyProvider getComponentAddStrategyProvider()
          Return the provider of component add strategies.
static java.awt.Window getDisplayWindow(java.lang.Object obj, java.lang.String title)
          Return a window suitable for displaying the argument object.
static void main(java.lang.String[] args)
          A simple test program.
 void setComponentAddStrategyProvider(IComponentAddStrategyProvider componentAddStrategyProvider)
          Set the provider of component add strategies.
 java.awt.Component toComponent(java.util.ResourceBundle bundle, java.lang.String baseKey, INoReturnMap argMap)
          Return the result of converting the bundle key to a component.
 
Methods inherited from class com.taco.text.DispatchingConverter
_getTypeForSuffix, _guessType, _literalToObject, _toObject, clone, configureComposite, getConfigurerForType, getConverterForType, installConfigurer, installConverter, installTypeForSuffix, name
 
Methods inherited from class com.taco.text.InterpolatingConverter
_argMapReferenceToObject, _getStandardImports, _getStandardStaticImports, _literalResultToObject, _scriptSnippetToObject, _toObjectMapper, toObject, toObject, toObject
 
Methods inherited from class com.taco.text.AbstractInterpolatingStringToObjectConverter
toObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_componentAddStrategyProvider

protected IComponentAddStrategyProvider _componentAddStrategyProvider
The provider of strategies for adding components to a container.


DEFAULT_INSTANCE

public static final DispatchingComponentConverter DEFAULT_INSTANCE
The default instance of this class, which uses the default component add strategy provider.

Constructor Detail

DispatchingComponentConverter

public DispatchingComponentConverter()
Create a new instance which uses the default instance of ComponentAddStrategyProvider. The instance's implementation of IStringToObjectConverter is incapable of resolving references.


DispatchingComponentConverter

public DispatchingComponentConverter(IComponentAddStrategyProvider provider)
Create a new instance which uses provider to provide component adders for layouts. The instance's implementation of IStringToObjectConverter is incapable of resolving references.


DispatchingComponentConverter

public DispatchingComponentConverter(IComponentAddStrategyProvider provider,
                                     java.util.ResourceBundle bundle,
                                     INoReturnMap argMap)
Create a new instance which uses provider to provide component adders for layouts. The instance's implementation of IStringToObjectConverter uses the specified resource bundle and argument map to resolve references.

Method Detail

getComponentAddStrategyProvider

public IComponentAddStrategyProvider getComponentAddStrategyProvider()
Return the provider of component add strategies.


setComponentAddStrategyProvider

public void setComponentAddStrategyProvider(IComponentAddStrategyProvider componentAddStrategyProvider)
Set the provider of component add strategies.


main

public static void main(java.lang.String[] args)
A simple test program.


getDisplayWindow

public static final java.awt.Window getDisplayWindow(java.lang.Object obj,
                                                     java.lang.String title)
Return a window suitable for displaying the argument object. The window will have the argument title if possible.


_installSuffixToTypeMappings

protected void _installSuffixToTypeMappings()
Install mappings from resource bundle key suffixes to dispatch types, in case the ".dispatchType" subkey is not present. For each converter and configurer type, see if it begins with 'j'. If so, use the part after the 'j' as the suffix, and map the suffix to the type.


toComponent

public final java.awt.Component toComponent(java.util.ResourceBundle bundle,
                                            java.lang.String baseKey,
                                            INoReturnMap argMap)
                                     throws java.text.ParseException,
                                            java.util.MissingResourceException
Return the result of converting the bundle key to a component. Cast the result to JComponent before returning it. This a convenience method intended to be called by the user.

Throws:
java.text.ParseException
java.util.MissingResourceException