org.springframework.richclient.widget.editor
Class DefaultDataEditorWidget

Show UML class diagram
java.lang.Object
  extended by org.springframework.richclient.application.support.ApplicationServicesAccessor
      extended by org.springframework.richclient.widget.AbstractWidget
          extended by org.springframework.richclient.widget.AbstractTitledWidget
              extended by org.springframework.richclient.widget.editor.AbstractDataEditorWidget
                  extended by org.springframework.richclient.widget.editor.DefaultDataEditorWidget
All Implemented Interfaces:
PropertyChangeListener, EventListener, Observer, BeanNameAware, PropertyChangePublisher, DescriptionConfigurable, Guarded, TitleConfigurable, Messagable, ImageConfigurable, DataProviderListener, SelectionWidget, TitledWidget, Widget
Direct Known Subclasses:
ItemDataEditor, SupplierDataEditor

public class DefaultDataEditorWidget
extends AbstractDataEditorWidget
implements DataProviderListener, PropertyChangeListener

DefaultDataEditorWidget is a basic implementation of a AbstractDataEditorWidget.


Nested Class Summary
protected static class DefaultDataEditorWidget.MaximumRowsExceededMessage
           
 
Field Summary
static String PARAMETER_DEFAULT_SELECTED_OBJECT
          Parameter to provide a default selected object.
static String PARAMETER_FILTER
          Parameter to provide a filter.
static String PARAMETER_MAP
          Constant to be used to embed a dataEditor parameterMap in a command parameterMap.
 
Fields inherited from class org.springframework.richclient.widget.editor.AbstractDataEditorWidget
CREATE_COMMAND_ID, FILL_COLUMN_SPEC, FILL_NOGROW_COLUMN_SPEC, FILL_ROW_SPEC, OFF, ON, tableSelectionObserver, UNSAVEDCHANGES_UNCOMMITTABLE_WARNING_ID, UNSAVEDCHANGES_WARNING_ID, UPDATE_COMMAND_ID
 
Fields inherited from class org.springframework.richclient.widget.AbstractWidget
showing
 
Fields inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor
logger
 
Fields inherited from interface org.springframework.richclient.dialog.Messagable
MESSAGE_PROPERTY
 
Fields inherited from interface org.springframework.richclient.widget.Widget
EMPTY_WIDGET
 
Constructor Summary
DefaultDataEditorWidget()
          Default constructor.
DefaultDataEditorWidget(DataProvider provider, AbstractForm form, TableDescription tableDesc, FilterForm filterForm)
           
DefaultDataEditorWidget(String id, DataProvider provider)
          Constructor with id and DataProvider.
DefaultDataEditorWidget(String id, DataProvider provider, AbstractForm form, TableDescription tableDesc, FilterForm filterForm)
          Constructor allowing to set all major components at once.
 
Method Summary
protected  Object cloneEntity(Object sampleObject)
           
 Widget createDetailWidget()
          Returns only the detail form widget
protected  Object createNewEntity(Object newObject)
           
 void executeFilter()
           
 void executeFilter(Map<String,Object> parameters)
          Executes filter and fills table in specific manner:

set baseCriteria if needed set searchCriteria on filterForm set searchCriteria on worker pass parameter map to worker launch worker to retrieve list from back-end and fill table when done, set list and execute additional code taking the parameters into account

protected  Object getBaseCriteria()
           
 DataProvider getDataProvider()
           
 AbstractForm getDetailForm()
           
 FilterForm getFilterForm()
           
protected  List getList(Object criteria)
          Warning! this can block threads for an extended period, make sure you're aware of this.
 TableWidget getTableWidget()
           
protected  DefaultValidationResultsModel getValidationResults()
           
protected  boolean isAddRowSupported()
           
protected  boolean isCloneRowSupported()
           
protected  boolean isFilterSupported()
           
protected  boolean isRemoveRowsSupported()
           
protected  boolean isUpdateRowSupported()
           
protected  void listWorkerDone(List<Object> rows, Map<String,Object> parameters)
          This method is called on the gui-thread when the worker ends.
protected  Object loadEntityDetails(Object baseObject, boolean forceLoad)
          Fetch the detailed object from the back-end.
 Object loadSimpleEntity(Object baseObject)
           
protected  void newRow(Object newClone)
           
 void onAboutToHide()
          Hook method called before moving the component to the background (=hiding)
 void onAboutToShow()
          Hook method called before showing the component on screen.
 void propertyChange(PropertyChangeEvent evt)
           
 void refreshSelectedObject()
           
protected  void registerListeners()
           
protected  void removeEntity(Object objectToRemove)
           
protected  Object saveEntity(Object dirtyObject)
           
protected  void setDataProvider(DataProvider provider)
          Set the provider to use for data manipulation.
protected  void setDetailForm(AbstractForm detailForm)
          Set the form that will handle one detail item.
protected  void setFilterForm(FilterForm filterForm)
          Set the form to use as filter.
 void setFilterModel(Object model)
           
protected  void setRows(List dataSet)
          Internal fill method of the datatable

WARNING: not threadsafe, please call me on the EDT!

 Object setSelectedSearch(Object criteria)
          note: differs from previous method to allow setting of formObject on filterForm.
protected  void setTableWidget(TableDescription tableDescription)
          Create a GlazedListTableWidget based on the given TableDescription to be used as listView.
protected  void setTableWidget(TableWidget tableWidget)
          Set the listView of this dataEditor.
 void setTitle(String title)
          Sets the title.
protected  void unRegisterListeners()
           
 void update(Observable o, Object arg)
           
 
Methods inherited from class org.springframework.richclient.widget.editor.AbstractDataEditorWidget
addDataProviderListener, canClose, createAddRowCommand, createClearFilterCommand, createCloneRowCommand, createCreateCommand, createDataEditorWidget, createEditRowCommand, createEmptyFilterCommand, createExecuteFilterCommand, createListSelectionObserver, createQuickAddCheckBox, createRefreshCommand, createRemoveRowCommand, createUpdateCommand, createWidgetContent, doCreate, doUpdate, getAddRowCommand, getClearFilterCommand, getCloneRowCommand, getCommands, getCommitCommand, getCommitComponent, getControlCommands, getCopySelectedRowsToClipboardCommand, getCreateCommand, getDetailPanel, getEditButtons, getEditRowCommand, getEmptyFilterCommand, getExecuteFilterCommand, getFilterCriteria, getHelpCommand, getRefreshCommand, getRemoveRowsCommand, getRevertCommand, getSearchString, getSelectCommand, getSelectedRowObject, getSelection, getTableFilterControlCommands, getTableFilterPanel, getTablePopupMenuCommandGroup, getTableResizeWeight, getToggleDetailCommand, getToggleFilterCommand, getUpdateCommand, isSelectMode, loadEntityDetails, newSingleLineResultsReporter, onRowSelection, removeDataProviderListener, removeRows, removeSelectionCommand, replaceRowObject, setDataProviderEventSources, setMultipleSelectionInSelectMode, setSearchString, setSelectedRowObject, setSelectionCommand, setSelectMode
 
Methods inherited from class org.springframework.richclient.widget.AbstractTitledWidget
addPropertyChangeListener, addPropertyChangeListener, getComponent, getDescription, getId, isEnabled, removePropertyChangeListener, removePropertyChangeListener, setBeanName, setCaption, setDescription, setEnabled, setId, setImage, setMessage
 
Methods inherited from class org.springframework.richclient.widget.AbstractWidget
isShowing
 
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.widget.TitledWidget
getId
 
Methods inherited from interface org.springframework.richclient.core.Guarded
isEnabled, setEnabled
 
Methods inherited from interface org.springframework.richclient.dialog.Messagable
setMessage
 
Methods inherited from interface org.springframework.binding.value.PropertyChangePublisher
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface org.springframework.richclient.image.config.ImageConfigurable
setImage
 
Methods inherited from interface org.springframework.richclient.core.DescriptionConfigurable
setCaption, setDescription
 
Methods inherited from interface org.springframework.beans.factory.BeanNameAware
setBeanName
 
Methods inherited from interface org.springframework.richclient.widget.Widget
getComponent, isShowing
 

Field Detail

PARAMETER_MAP

public static final String PARAMETER_MAP
Constant to be used to embed a dataEditor parameterMap in a command parameterMap.

See Also:
Constant Field Values

PARAMETER_FILTER

public static final String PARAMETER_FILTER
Parameter to provide a filter.

See Also:
Constant Field Values

PARAMETER_DEFAULT_SELECTED_OBJECT

public static final String PARAMETER_DEFAULT_SELECTED_OBJECT
Parameter to provide a default selected object.

See Also:
Constant Field Values
Constructor Detail

DefaultDataEditorWidget

public DefaultDataEditorWidget()
Default constructor. Add id, DataProvider, Forms and listView later.

See Also:
setDataProvider(DataProvider), setDetailForm(AbstractForm), setFilterForm(FilterForm), AbstractTitledWidget.setId(String), setTableWidget(TableDescription), setTableWidget(TableWidget)

DefaultDataEditorWidget

public DefaultDataEditorWidget(String id,
                               DataProvider provider)
Constructor with id and DataProvider. Add Forms and listView later.

Parameters:
id - used to fetch messages/icons.
provider - provides the data manipulation and possible CRUD options.
See Also:
setDetailForm(AbstractForm), setFilterForm(FilterForm), setTableWidget(TableDescription), setTableWidget(TableWidget)

DefaultDataEditorWidget

public DefaultDataEditorWidget(DataProvider provider,
                               AbstractForm form,
                               TableDescription tableDesc,
                               FilterForm filterForm)

DefaultDataEditorWidget

public DefaultDataEditorWidget(String id,
                               DataProvider provider,
                               AbstractForm form,
                               TableDescription tableDesc,
                               FilterForm filterForm)
Constructor allowing to set all major components at once.

Parameters:
id - used to fetch messages/icons.
provider - provides the data manipulation and possible CRUD options.
form - used to display and edit one row detail.
tableDesc - describes the columns of the table to build.
filterForm - optional form used to filter the data.
Method Detail

listWorkerDone

protected void listWorkerDone(List<Object> rows,
                              Map<String,Object> parameters)
This method is called on the gui-thread when the worker ends. As default it will check for the PARAMETER_DEFAULT_SELECTED_OBJECT parameter in the map.

Parameters:
rows - fetched by the listWorker.
parameters - a map of parameters specific to this listWorker instance.

setTitle

public void setTitle(String title)
Description copied from interface: TitleConfigurable
Sets the title.

Specified by:
setTitle in interface TitleConfigurable
Overrides:
setTitle in class AbstractTitledWidget
Parameters:
title - the title

createDetailWidget

public Widget createDetailWidget()
Returns only the detail form widget

Specified by:
createDetailWidget in class AbstractDataEditorWidget

setDetailForm

protected void setDetailForm(AbstractForm detailForm)
Set the form that will handle one detail item.


getDetailForm

public AbstractForm getDetailForm()
Specified by:
getDetailForm in class AbstractDataEditorWidget

setFilterForm

protected void setFilterForm(FilterForm filterForm)
Set the form to use as filter.

See Also:
DataProvider.supportsFiltering()

getFilterForm

public FilterForm getFilterForm()
Specified by:
getFilterForm in class AbstractDataEditorWidget

setFilterModel

public void setFilterModel(Object model)

setTableWidget

protected void setTableWidget(TableDescription tableDescription)
Create a GlazedListTableWidget based on the given TableDescription to be used as listView.

Parameters:
tableDescription - description of columns used to create the table.

setTableWidget

protected void setTableWidget(TableWidget tableWidget)
Set the listView of this dataEditor.


getTableWidget

public TableWidget getTableWidget()
Specified by:
getTableWidget in class AbstractDataEditorWidget

setDataProvider

protected void setDataProvider(DataProvider provider)
Set the provider to use for data manipulation.


getDataProvider

public DataProvider getDataProvider()

isUpdateRowSupported

protected boolean isUpdateRowSupported()
Specified by:
isUpdateRowSupported in class AbstractDataEditorWidget

isAddRowSupported

protected boolean isAddRowSupported()
Specified by:
isAddRowSupported in class AbstractDataEditorWidget

isCloneRowSupported

protected boolean isCloneRowSupported()
Specified by:
isCloneRowSupported in class AbstractDataEditorWidget

isFilterSupported

protected boolean isFilterSupported()
Specified by:
isFilterSupported in class AbstractDataEditorWidget

isRemoveRowsSupported

protected boolean isRemoveRowsSupported()
Specified by:
isRemoveRowsSupported in class AbstractDataEditorWidget

executeFilter

public void executeFilter(Map<String,Object> parameters)
Executes filter and fills table in specific manner:

Specified by:
executeFilter in class AbstractDataEditorWidget
Parameters:
parameters - a number of parameters that can influence this run. Should be a non-modifiable map or a specific instance.

executeFilter

public void executeFilter()
Specified by:
executeFilter in class AbstractDataEditorWidget
See Also:
executeFilter(Map)

getList

protected List getList(Object criteria)
Warning! this can block threads for an extended period, make sure you're aware of this.

Alternative: executeFilter() will launch separate worker and fills table.

Parameters:
criteria -
Returns:

setRows

protected void setRows(List dataSet)
Internal fill method of the datatable

WARNING: not threadsafe, please call me on the EDT!


getBaseCriteria

protected Object getBaseCriteria()

loadEntityDetails

protected Object loadEntityDetails(Object baseObject,
                                   boolean forceLoad)
Description copied from class: AbstractDataEditorWidget
Fetch the detailed object from the back-end. If the baseObject is already detailed, the baseObject can be returned directly if and only if no forceLoad is requested. This logic is also apparent in the DataProvider class.

Specified by:
loadEntityDetails in class AbstractDataEditorWidget
Parameters:
baseObject - object containing enough information to fetch a detailed version.
forceLoad - if true always load the detailed object from the back-end, if false a shortcut can be implemented by returning the baseObject directly.
Returns:
the detailed object

loadSimpleEntity

public Object loadSimpleEntity(Object baseObject)

saveEntity

protected Object saveEntity(Object dirtyObject)
Specified by:
saveEntity in class AbstractDataEditorWidget

newRow

protected void newRow(Object newClone)
Overrides:
newRow in class AbstractDataEditorWidget

createNewEntity

protected Object createNewEntity(Object newObject)
Specified by:
createNewEntity in class AbstractDataEditorWidget

cloneEntity

protected Object cloneEntity(Object sampleObject)
Specified by:
cloneEntity in class AbstractDataEditorWidget

removeEntity

protected void removeEntity(Object objectToRemove)
Specified by:
removeEntity in class AbstractDataEditorWidget

update

public void update(Observable o,
                   Object arg)
Specified by:
update in interface Observer

onAboutToShow

public void onAboutToShow()
Hook method called before showing the component on screen.

Specified by:
onAboutToShow in interface Widget
Overrides:
onAboutToShow in class AbstractWidget

onAboutToHide

public void onAboutToHide()
Hook method called before moving the component to the background (=hiding)

Specified by:
onAboutToHide in interface Widget
Overrides:
onAboutToHide in class AbstractWidget

registerListeners

protected void registerListeners()

unRegisterListeners

protected void unRegisterListeners()

setSelectedSearch

public Object setSelectedSearch(Object criteria)
note: differs from previous method to allow setting of formObject on filterForm. Will probably end up in refactoring of dataeditorwidget.

Specified by:
setSelectedSearch in class AbstractDataEditorWidget
Parameters:
criteria - formObject to set on FilterForm.
Returns:

refreshSelectedObject

public void refreshSelectedObject()

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

getValidationResults

protected final DefaultValidationResultsModel getValidationResults()
Specified by:
getValidationResults in class AbstractDataEditorWidget


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