org.springframework.richclient.factory
Class AbstractControlFactory

java.lang.Object
  extended by org.springframework.richclient.application.support.ApplicationServicesAccessor
      extended by org.springframework.richclient.factory.AbstractControlFactory
All Implemented Interfaces:
ControlFactory
Direct Known Subclasses:
AbstractApplicationPage, AbstractBinding, AbstractForm, AbstractFormUIProvider, AbstractObjectTable, AbstractView, AlertMessageAreaPane, DefaultMessageAreaPane, DefaultPageComponentPane, DefaultStatusBar, ExceptionDetailsPane, FileChooserComboBox, ListItemUpDownButtonPanel, SelectField, StatusBarProgressMonitor, TitlePane

public abstract class AbstractControlFactory
extends ApplicationServicesAccessor
implements ControlFactory

A skeleton implementation of the ControlFactory interface that only creates it's control when requested.

The factory may operate in singleton mode, which is the default. In this case, the control will be created the first time it is requested and the same instance will be returned for each subsequent request. When operating in non-singleton mode, a new control instance is created each time it is requested.

Author:
Keith Donald

Field Summary
 
Fields inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor
logger
 
Constructor Summary
protected AbstractControlFactory()
          Creates a new uninitialized AbstractControlFactory.
 
Method Summary
protected abstract  JComponent createControl()
          Subclasses must override this method to create a new instance of the control that this factory produces.
protected  void createControlIfNecessary()
          Creates an instance of the control produced by this factory if operating in singleton mode and the control instance has not already been created.
 JComponent getControl()
          Returns an instance of the control that this factory produces.
 boolean isControlCreated()
          Returns true if the control for this factory has been created.
protected  boolean isSingleton()
          Returns true (the default) if this factory is to create a single instance of its control.
protected  void setSingleton(boolean singleton)
          Sets the flag that determines if this factory is to create a single instance of its control.
 
Methods inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor
getActiveWindow, getApplication, getApplicationContext, getApplicationName, getApplicationServices, getCommandConfigurer, getComponentFactory, getConversionService, getIconSource, getImageSource, getMessage, getMessage, getMessage, getMessage, getMessages, getMessageSource, getObjectConfigurer, getService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractControlFactory

protected AbstractControlFactory()
Creates a new uninitialized AbstractControlFactory.

Method Detail

isSingleton

protected final boolean isSingleton()
Returns true (the default) if this factory is to create a single instance of its control.

Returns:
true if this factory returns a singleton instance of its control.

setSingleton

protected final void setSingleton(boolean singleton)
Sets the flag that determines if this factory is to create a single instance of its control. By default, this flag is true.

Parameters:
singleton - The singleton flag.

getControl

public final JComponent getControl()
Returns an instance of the control that this factory produces.

This implementation is a template method, calling the abstract createControl() method if operating in non-singleton mode or if the control has not yet been created when operating in singleton mode.

Specified by:
getControl in interface ControlFactory
Returns:
The control, never null.

isControlCreated

public final boolean isControlCreated()
Returns true if the control for this factory has been created. If this factory is set to non-singleton mode, this method will always return false even if an instance of the control has previously been created.

Returns:
true if operating in singleton mode and an instance of the control has already been created, false otherwise.

createControlIfNecessary

protected void createControlIfNecessary()
Creates an instance of the control produced by this factory if operating in singleton mode and the control instance has not already been created.


createControl

protected abstract JComponent createControl()
Subclasses must override this method to create a new instance of the control that this factory produces.

Returns:
The newly created control, never null.


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.