org.springframework.richclient.form.binding.swing.editor
Class AbstractLookupBinding

Show UML class diagram
java.lang.Object
  extended by org.springframework.richclient.application.support.ApplicationServicesAccessor
      extended by org.springframework.richclient.factory.AbstractControlFactory
          extended by org.springframework.richclient.form.binding.support.AbstractBinding
              extended by org.springframework.richclient.form.binding.support.CustomBinding
                  extended by org.springframework.richclient.form.binding.swing.editor.AbstractLookupBinding
All Implemented Interfaces:
ControlFactory, Binding

public abstract class AbstractLookupBinding
extends CustomBinding


Nested Class Summary
protected static class AbstractLookupBinding.TabKeyListener
          Helper class to build a KeyListener that reacts on tabs.
 
Field Summary
static int AUTOPOPUPDIALOG_ALWAYS
          Always pop-up.
static int AUTOPOPUPDIALOG_MULTIPLE_MATCH
          Pop-up dataEditor when multiple matches are found.
static int AUTOPOPUPDIALOG_NO_MATCH
          Pop-up dataEditor when no match is found.
static int AUTOPOPUPDIALOG_NO_UNIQUE_MATCH
          Pop-up if no unique match is found.
static int AUTOPOPUPDIALOG_UNIQUE_MATCH
          Pop-up dataEditor when unique match is found.
static String DEFAULT_SELECTDIALOG_COMMAND_ID
          Default id to configure the command.
static String DEFAULT_SELECTDIALOG_ID
          Default id to configure the dialog.
static String NO_INITIALIZE_DATA_EDITOR
          Parameter used to pass to the dataEditorCommand in order to skip initialization of the dataEditor.
static Boolean OFF
          Standard off option to use with parameters.
static Boolean ON
          Standard on option to use with parameters.
static String ON_ABOUT_TO_CHANGE
           
 
Fields inherited from class org.springframework.richclient.form.binding.support.AbstractBinding
fieldMetadata, formModel, formPropertyPath
 
Fields inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor
logger
 
Constructor Summary
AbstractLookupBinding(DefaultDataEditorWidget dataEditor, FormModel formModel, String formPropertyPath)
           
 
Method Summary
protected  ActionCommand createDataEditorCommand()
          Create the dataEditorCommand.
protected abstract  Object createFilterFromString(String textFieldValue)
          Create an empty referable that is used to pass onto the dataEditor search method and that is used to set onto the valueModel if this binding is set to not revert upon yielding a null search result.
protected  FocusListener createFocusListener()
          Create a focus listener to attach to the textComponent and dataEditorButton that will decide what happens with the changed value.
protected  JComponent createKeyComponent()
           
protected  AbstractLookupBinding.TabKeyListener createKeyListener()
          Create a keyListener that reacts on tabs.
protected  JTextField createTextComponent()
          Deprecated. move implementation to createKeyComponent() when removing this method.
protected  JComponent doBindControl()
           
protected  void enabledChanged()
          Called when the enabled state of the bound property changes.
protected  boolean evaluateFocusLost(FocusEvent e)
           
protected  int getAutoPopupDialog()
          Returns the mask defining the behavior of the pop-up.
protected  DefaultDataEditorWidget getDataEditor()
          Return the dataEditor used to select a referable.
protected  AbstractButton getDataEditorButton()
          Get/create the button to open the dataEditor in selection mode
protected  ActionCommand getDataEditorCommand()
          Return the dataEditorCommand.
 String getDataEditorViewCommandId()
          Returns the id used to configure the viewCommand.
 Dimension getDialogSize()
           
 Object getFilter()
           
protected  JComponent getKeyComponent()
           
protected  String getKeyComponentText()
          Return the text that is shown on the keyComponent and that should be used to lookup the referable.
abstract  String getObjectLabel(Object o)
           
protected  JTextComponent getOrCreateKeyTextComponent()
          Deprecated. use getKeyComponent() instead or to access the text directly, use getKeyComponentText() and setKeyComponentText(String).
protected  Map<Object,Object> getParameters()
          Returns the parameter map that is passed to the dataEditor command.
protected  String getSelectDialogCommandId()
          Returns the id for the command that shows the dialog.
protected  String getSelectDialogId()
          Returns the id for the TitledApplicationDialog that shows up when pressing the button.
protected  Object initializeDataEditor()
          Initialize the dataEditor by passing the search referable as search parameter.
 boolean isEnableViewCommand()
          Returns true if the viewCommand should be shown.
 boolean isLoadDetailedObject()
           
protected  boolean onFinish()
          When a value is selected, set it on the valueModel.
protected  void readOnlyChanged()
          Called when the read only state of the bound property changes.
protected  boolean revertValueOnFocusLost()
          Return true if the value should be reverted when focus is lost and no value is selected.
 void setAutoPopupdialog(int autoPopupDialog)
          Set the mask defining the pop-up behavior.
 void setDataEditorViewCommandId(String dataEditorViewCommandId)
          Set the id used to configure the viewCommand.
 void setEnableViewCommand(boolean enableViewCommand)
          Enable the viewCommand that switches the view to the dataEditor of this referable.
 void setFilter(Object filter)
           
protected  void setKeyComponentText(String text)
          Set the text of the referable label on the key component (normally the textField).
 void setLoadDetailedObject(boolean loadDetailedObject)
           
 void setRevertValueOnFocusLost(boolean revertValueOnFocusLost)
          Set to true if the value should be reverted when focus is lost and no value is selected.
 void setSelectDialogCommandId(String selectDialogCommandId)
          Set the id for the command that shows the dialog.
 void setSelectDialogId(String selectDialogId)
          Set the id for the TitledApplicationDialog that shows up when pressing the button.
protected  void valueModelChanged(Object newValue)
          Called when the underlying property's value model value changes.
 
Methods inherited from class org.springframework.richclient.form.binding.support.CustomBinding
controlValueChanged, isReadOnly, setReadOnly
 
Methods inherited from class org.springframework.richclient.form.binding.support.AbstractBinding
createControl, getFieldFace, getFormModel, getProperty, getPropertyType, getValue, getValueModel, isEnabled
 
Methods inherited from class org.springframework.richclient.factory.AbstractControlFactory
createControlIfNecessary, getControl, isControlCreated, isSingleton, setSingleton
 
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
 
Methods inherited from interface org.springframework.richclient.form.binding.Binding
getControl
 

Field Detail

ON_ABOUT_TO_CHANGE

public static final String ON_ABOUT_TO_CHANGE
See Also:
Constant Field Values

NO_INITIALIZE_DATA_EDITOR

public static final String NO_INITIALIZE_DATA_EDITOR
Parameter used to pass to the dataEditorCommand in order to skip initialization of the dataEditor.

See Also:
Constant Field Values

AUTOPOPUPDIALOG_UNIQUE_MATCH

public static final int AUTOPOPUPDIALOG_UNIQUE_MATCH
Pop-up dataEditor when unique match is found.

See Also:
Constant Field Values

AUTOPOPUPDIALOG_NO_MATCH

public static final int AUTOPOPUPDIALOG_NO_MATCH
Pop-up dataEditor when no match is found.

See Also:
Constant Field Values

AUTOPOPUPDIALOG_MULTIPLE_MATCH

public static final int AUTOPOPUPDIALOG_MULTIPLE_MATCH
Pop-up dataEditor when multiple matches are found.

See Also:
Constant Field Values

AUTOPOPUPDIALOG_ALWAYS

public static final int AUTOPOPUPDIALOG_ALWAYS
Always pop-up.

See Also:
Constant Field Values

AUTOPOPUPDIALOG_NO_UNIQUE_MATCH

public static final int AUTOPOPUPDIALOG_NO_UNIQUE_MATCH
Pop-up if no unique match is found. This is considered to be the sensible default.

See Also:
Constant Field Values

ON

public static final Boolean ON
Standard on option to use with parameters.


OFF

public static final Boolean OFF
Standard off option to use with parameters.


DEFAULT_SELECTDIALOG_ID

public static final String DEFAULT_SELECTDIALOG_ID
Default id to configure the dialog.

See Also:
Constant Field Values

DEFAULT_SELECTDIALOG_COMMAND_ID

public static final String DEFAULT_SELECTDIALOG_COMMAND_ID
Default id to configure the command.

See Also:
Constant Field Values
Constructor Detail

AbstractLookupBinding

public AbstractLookupBinding(DefaultDataEditorWidget dataEditor,
                             FormModel formModel,
                             String formPropertyPath)
Method Detail

getParameters

protected Map<Object,Object> getParameters()
Returns the parameter map that is passed to the dataEditor command. This allows for eg turning initialization of the dataEditor on/off.


getSelectDialogId

protected String getSelectDialogId()
Returns the id for the TitledApplicationDialog that shows up when pressing the button.


setSelectDialogId

public void setSelectDialogId(String selectDialogId)
Set the id for the TitledApplicationDialog that shows up when pressing the button.


getSelectDialogCommandId

protected String getSelectDialogCommandId()
Returns the id for the command that shows the dialog.


setSelectDialogCommandId

public void setSelectDialogCommandId(String selectDialogCommandId)
Set the id for the command that shows the dialog.


getAutoPopupDialog

protected int getAutoPopupDialog()
Returns the mask defining the behavior of the pop-up.


setAutoPopupdialog

public void setAutoPopupdialog(int autoPopupDialog)
Set the mask defining the pop-up behavior.

See Also:
AUTOPOPUPDIALOG_ALWAYS, AUTOPOPUPDIALOG_UNIQUE_MATCH, AUTOPOPUPDIALOG_MULTIPLE_MATCH, AUTOPOPUPDIALOG_NO_MATCH, AUTOPOPUPDIALOG_NO_UNIQUE_MATCH

revertValueOnFocusLost

protected boolean revertValueOnFocusLost()
Return true if the value should be reverted when focus is lost and no value is selected.


setRevertValueOnFocusLost

public void setRevertValueOnFocusLost(boolean revertValueOnFocusLost)
Set to true if the value should be reverted when focus is lost and no value is selected.


valueModelChanged

protected void valueModelChanged(Object newValue)
Called when the underlying property's value model value changes. Sets the textComponent to reflect the label of the object

Specified by:
valueModelChanged in class CustomBinding

getObjectLabel

public abstract String getObjectLabel(Object o)

doBindControl

protected JComponent doBindControl()
Specified by:
doBindControl in class AbstractBinding

getOrCreateKeyTextComponent

@Deprecated
protected JTextComponent getOrCreateKeyTextComponent()
Deprecated. use getKeyComponent() instead or to access the text directly, use getKeyComponentText() and setKeyComponentText(String).

Returns a JTextComponent to display the key, creates it if necessary.


getKeyComponent

protected JComponent getKeyComponent()

createKeyComponent

protected JComponent createKeyComponent()

createTextComponent

@Deprecated
protected JTextField createTextComponent()
Deprecated. move implementation to createKeyComponent() when removing this method.

Create the textComponent.


getKeyComponentText

protected String getKeyComponentText()
Return the text that is shown on the keyComponent and that should be used to lookup the referable. Most commonly this string contains the label of the referable.


setKeyComponentText

protected void setKeyComponentText(String text)
Set the text of the referable label on the key component (normally the textField).


createKeyListener

protected AbstractLookupBinding.TabKeyListener createKeyListener()
Create a keyListener that reacts on tabs. Pop-up the dialog as defined in the getAutoPopupDialog() mask.


createFocusListener

protected FocusListener createFocusListener()
Create a focus listener to attach to the textComponent and dataEditorButton that will decide what happens with the changed value. Here a revert can be done if no value is selected or a new value can be created as needed.

Returns:
a focus listener.

evaluateFocusLost

protected boolean evaluateFocusLost(FocusEvent e)

readOnlyChanged

protected void readOnlyChanged()
Description copied from class: AbstractBinding
Called when the read only state of the bound property changes.

Specified by:
readOnlyChanged in class AbstractBinding
See Also:
FormPropertyState

enabledChanged

protected void enabledChanged()
Description copied from class: AbstractBinding
Called when the enabled state of the bound property changes.

Specified by:
enabledChanged in class AbstractBinding
See Also:
FormPropertyState

initializeDataEditor

protected Object initializeDataEditor()
Initialize the dataEditor by passing the search referable as search parameter.

Returns:
a single object if the search has an unique match, a list if multiple matches occurred or null if nothing was found.

createFilterFromString

protected abstract Object createFilterFromString(String textFieldValue)
Create an empty referable that is used to pass onto the dataEditor search method and that is used to set onto the valueModel if this binding is set to not revert upon yielding a null search result.

Parameters:
textFieldValue - the value of the textComponent.
Returns:
a Referable that represents the state of this binding when no real object is available.

getDataEditorButton

protected AbstractButton getDataEditorButton()
Get/create the button to open the dataEditor in selection mode


getDataEditorCommand

protected final ActionCommand getDataEditorCommand()
Return the dataEditorCommand.


createDataEditorCommand

protected ActionCommand createDataEditorCommand()
Create the dataEditorCommand.


getDataEditor

protected DefaultDataEditorWidget getDataEditor()
Return the dataEditor used to select a referable.


onFinish

protected boolean onFinish()
When a value is selected, set it on the valueModel.

Returns:
true if successful.

setDataEditorViewCommandId

public void setDataEditorViewCommandId(String dataEditorViewCommandId)
Set the id used to configure the viewCommand.


getDataEditorViewCommandId

public String getDataEditorViewCommandId()
Returns the id used to configure the viewCommand.


setEnableViewCommand

public void setEnableViewCommand(boolean enableViewCommand)
Enable the viewCommand that switches the view to the dataEditor of this referable.


isEnableViewCommand

public boolean isEnableViewCommand()
Returns true if the viewCommand should be shown. Default value is false.


isLoadDetailedObject

public boolean isLoadDetailedObject()

setLoadDetailedObject

public void setLoadDetailedObject(boolean loadDetailedObject)

setFilter

public void setFilter(Object filter)

getFilter

public Object getFilter()

getDialogSize

public Dimension getDialogSize()


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