|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.richclient.application.support.ApplicationServicesAccessor
org.springframework.richclient.factory.AbstractControlFactory
org.springframework.richclient.table.support.AbstractObjectTable
public abstract class AbstractObjectTable
This class provides a standard table representation for a set of objects with properties of the objects presented in the columns of the table. The table created offers the following features:
setDoubleClickHandler(ActionCommandExecutor)
.Several I18N messages are needed for proper reporting to a configured status bar. The message keys used are:
Message key | Usage |
modelId.objectName.singular | The singular name of the objects in the table |
modelId.objectName.plural | The plural name of the objects in the table |
[modelId].objectTable.showingAll.message | The message to show when all objects are being shown, that is no objects have been filtered. This is typically something like "Showing all nn contacts". The message takes the number of objects nd the object name (singular or plural) as parameters. |
[modelId].objectTable.showingN.message | The message to show when some of the objects have been filtered from the display. This is typically something like "Showing nn contacts of nn". The message takes the shown count, the total count, and the object name (singular or plural) as parameters. |
[modelId].objectTable.selectedN.message | The message to append to the filter message when the selection is not empty. Typically something like ", nn selected". The message takes the number of selected entries as a parameter. |
Note that the message keys that show the model id in brackets, like this [modelId], indicate that the model id is optional. If no message is found using the model id, then the key will be tried without the model id and the resulting string will be used. This makes it easy to construct one single message property that can be used on numerous tables.
Note: If you are using application events to inform UI components of changes to domain objects, then
instances of this class have to be wired into the event distribution. To do this, you should construct instances (of
concrete subclasses) in the application context. They will automatically be wired into the epplication event
mechanism because this class implements ApplicationListener
.
Field Summary | |
---|---|
static String |
SELECTEDN_MSG_KEY
|
static String |
SHOWINGALL_MSG_KEY
|
static String |
SHOWINGN_MSG_KEY
|
Fields inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor |
---|
logger |
Constructor Summary | |
---|---|
AbstractObjectTable(String modelId,
String[] columnPropertyNames)
Constructor. |
Method Summary | |
---|---|
protected void |
configureTable(JTable table)
Configure the newly created table as needed. |
protected JComponent |
createControl()
Subclasses must override this method to create a new instance of the control that this factory produces. |
protected JPopupMenu |
createPopupContextMenu()
Create the context popup menu, if any, for this table. |
protected JPopupMenu |
createPopupContextMenu(MouseEvent e)
Create the context popup menu, if any, for this table. |
protected GlazedTableModel |
createTableModel(ca.odell.glazedlists.EventList eventList)
Construct the table model for this table. |
protected ca.odell.glazedlists.gui.AbstractTableComparatorChooser |
createTableSorter(JTable table,
ca.odell.glazedlists.SortedList sortedList)
|
ca.odell.glazedlists.EventList |
getBaseEventList()
Get the base event list for the table model. |
String[] |
getColumnPropertyNames()
Get the names of the properties to display in the table columns. |
protected abstract Object[] |
getDefaultInitialData()
Get the default set of objects for this table. |
ActionCommandExecutor |
getDoubleClickHandler()
|
ca.odell.glazedlists.EventList |
getFinalEventList()
Get the event list to be use for constructing the table model. |
Object[] |
getInitialData()
Get the initial data to display. |
protected int |
getInitialSortColumn()
Get the default sort column. |
String |
getModelId()
|
CommandGroup |
getPopupCommandGroup()
|
ListSelectionModel |
getSelectionModel()
Get the selection model. |
protected JTable |
getTable()
Returns the created JTable. |
GlazedTableModel |
getTableModel()
Get the data model for the table. |
protected ca.odell.glazedlists.gui.AbstractTableComparatorChooser |
getTableSorter()
Returns the sorter which is used to sort the content of the table |
protected void |
handleDeletedObject(Object object)
Handle the deletion of an object in this table. |
protected void |
handleNewObject(Object object)
Handle the creation of a new object. |
protected void |
handleUpdatedObject(Object object)
Handle an updated object in this table. |
protected void |
init()
Initialize our internal values. |
protected boolean |
isMultipleColumnSort()
|
void |
onApplicationEvent(ApplicationEvent e)
Handle an application event. |
protected void |
onDoubleClick()
Handle a double click on a row of the table. |
protected void |
runWithReadLock(Runnable runnable)
Executes the runnable with a read lock on the event list. |
protected void |
runWithWriteLock(Runnable runnable)
Executes the runnable with a write lock on the event list. |
void |
setColumnPropertyNames(String[] columnPropertyNames)
Set the names of the properties to display in the table columns. |
void |
setDoubleClickHandler(ActionCommandExecutor doubleClickHandler)
Set the handler (action executor) that should be invoked when a row in the table is double-clicked. |
void |
setFinalEventList(ca.odell.glazedlists.EventList finalEventList)
Set the event list to be used for constructing the table model. |
void |
setInitialData(Object[] initialData)
Set the initial data to display. |
void |
setPopupCommandGroup(CommandGroup popupCommandGroup)
Set the command group that should be used to construct the popup menu when a user initiates the UI gesture to show the context menu. |
void |
setStatusBar(StatusBar statusBar)
Set the status bar associated with this table. |
protected boolean |
shouldHandleEvent(ApplicationEvent event)
Determine if the event should be handled on this table. |
protected void |
updateStatusBar()
Update the status bar with the current display counts. |
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 |
Field Detail |
---|
public static final String SHOWINGALL_MSG_KEY
public static final String SHOWINGN_MSG_KEY
public static final String SELECTEDN_MSG_KEY
Constructor Detail |
---|
public AbstractObjectTable(String modelId, String[] columnPropertyNames)
modelId
- used for generating message keysobjectType
- The type of object held in the tableMethod Detail |
---|
public void setInitialData(Object[] initialData)
initialData
- Array of objects to displaypublic Object[] getInitialData()
getDefaultInitialData()
public ca.odell.glazedlists.EventList getBaseEventList()
public void setFinalEventList(ca.odell.glazedlists.EventList finalEventList)
getBaseEventList()
or this table will not work properly.
event
- list to usepublic ca.odell.glazedlists.EventList getFinalEventList()
public GlazedTableModel getTableModel()
Note: This method returns null unless getTable()
or #createTable()
is called
public String[] getColumnPropertyNames()
public void setColumnPropertyNames(String[] columnPropertyNames)
columnPropertyNames
- public ActionCommandExecutor getDoubleClickHandler()
public void setDoubleClickHandler(ActionCommandExecutor doubleClickHandler)
doubleClickHandler
- the doubleClickHandler to setprotected ca.odell.glazedlists.gui.AbstractTableComparatorChooser getTableSorter()
getTable()
or #createTable()
is not called beforepublic CommandGroup getPopupCommandGroup()
public void setPopupCommandGroup(CommandGroup popupCommandGroup)
popupCommandGroup
- the popupCommandGroup to setpublic void setStatusBar(StatusBar statusBar)
statusBar
- to updatepublic String getModelId()
protected void init()
protected JComponent createControl()
AbstractControlFactory
createControl
in class AbstractControlFactory
protected void configureTable(JTable table)
table
- The table to configureprotected abstract Object[] getDefaultInitialData()
protected JTable getTable()
protected ca.odell.glazedlists.gui.AbstractTableComparatorChooser createTableSorter(JTable table, ca.odell.glazedlists.SortedList sortedList)
protected boolean isMultipleColumnSort()
protected void onDoubleClick()
protected GlazedTableModel createTableModel(ca.odell.glazedlists.EventList eventList)
eventList
- on which to build the model
protected boolean shouldHandleEvent(ApplicationEvent event)
true
is returned (the default), then
the list holding the table data will be scanned for the object and updated appropriately depending on then event
type.
event
- to inspect
handleDeletedObject(Object)
,
handleNewObject(Object)
,
handleUpdatedObject(Object)
protected JPopupMenu createPopupContextMenu()
protected JPopupMenu createPopupContextMenu(MouseEvent e)
e
- the event which contains information about the current context.
protected int getInitialSortColumn()
public ListSelectionModel getSelectionModel()
protected void runWithWriteLock(Runnable runnable)
runnable
- its run method is executed while holding a write lock for
the event list.getFinalEventList()
protected void runWithReadLock(Runnable runnable)
runnable
- its run method is executed while holding a read lock for
the event list.getFinalEventList()
protected void handleNewObject(Object object)
object
- New object to handleprotected void handleUpdatedObject(Object object)
object
- Updated object to handleprotected void handleDeletedObject(Object object)
object
- Updated object being deletedprotected void updateStatusBar()
public void onApplicationEvent(ApplicationEvent e)
onApplicationEvent
in interface ApplicationListener
e
- event to process
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |