com.isti.quakewatch.guiutil
Class SortedEventJListMgr

java.lang.Object
  extended by com.isti.quakewatch.message.EventListManager
      extended by com.isti.quakewatch.guiutil.SortedEventJListMgr
All Implemented Interfaces:
EventAdderInterface

public class SortedEventJListMgr
extends EventListManager

Class SortedEventJListMgr manages a JList GUI object containing a list of sorted event objects. The events are held in two parallel lists--the 'eventsListTable' in the parent class and the 'quakeListObj' in this class. This is done so the GUI 'quakeListObj' component is always updated via the event-dispatch thread, while the event objects in the 'eventsListTable' are always directly available to any thread. The methods in this class ensure that the two lists are kept in sync. The event objects in the 'eventsListTable' are always sorted by value, ascending. The GUI 'quakeListObj' component defaults to being sorted by ascending values, but may be re-sorted via the 'reSortList()' method (in 'SortedValuesJList'). After this is done, the event-index values of the two lists will no longer correspond.


Nested Class Summary
static interface SortedEventJListMgr.EventSelectionChangeListener
          Interface EventSelectionChangeListener defines a callback listener used when a new event is selected.
 
Field Summary
protected  SortedEventJListMgr.EventSelectionChangeListener eventSelChangeListener
           
protected  boolean inSetSelectedEventFlag
           
protected  java.lang.Object lastManSelTimeSyncObj
           
protected  long lastManualSelectTime
           
protected  boolean quakeListEnabledFlag
           
protected  SortedValuesJList quakeListObj
           
protected  QWEventMsgRecord selectedRecordObj
           
protected  java.lang.Object selectedRecordObjSyncObj
           
protected  java.lang.Object setSelEventMethodSyncObj
           
 
Fields inherited from class com.isti.quakewatch.message.EventListManager
eventsListChangedFlag, eventsListTable, logObj
 
Constructor Summary
SortedEventJListMgr()
          Creates a "dummy" list manager.
SortedEventJListMgr(javax.swing.ListCellRenderer quakeListCellRenderer, LogFile logFileObj, boolean sortDirFlag)
          Creates an event list manager.
SortedEventJListMgr(javax.swing.ListCellRenderer quakeListCellRenderer, LogFile logFileObj, boolean sortDirFlag, int sortType)
          Creates an event list manager.
 
Method Summary
 void addEventToList(QWEventMsgRecord recObj)
          Adds the given event message record object to the table of events, putting it into sorted position.
 void addQuakeListKeyListener(java.awt.event.KeyListener listenerObj)
          Adds the given key listener to the quake list.
 void addQuakeListMouseListener(java.awt.event.MouseListener listenerObj)
          Adds the given mouse listener to the quake list.
 void ensureQuakeListSelectionVisible()
          Ensures that the current quake list selection is visible.
 void fillAndEnableQuakeList()
          Sets up the quake list to use the list model held by this object.
 void fireQuakeListContentsChanged()
          Fires a contents-changed event to the list model for the quake list.
 void fireQuakeListUpdate()
          Updates the quake JList object.
 long getLastManualSelectTime()
          Returns the time of the last "manual" selection change to the list.
 java.awt.Component getQuakeListComponent()
          Returns the quake-list display component object.
 java.awt.Component getQuakeListObj()
          Returns the quake-list 'JList' component object.
 java.lang.Object getQuakeListSelectedValue()
          Returns the currently selected value on the quake list.
protected  int getSelectedIndex()
          Returns the index for the current selected event record.
 QWEventMsgRecord getSelectedRecordObj()
          Returns the selected event message record object.
protected  void processQuakeListSelChange(java.lang.Object keyObj)
          Processes a selection-change event from the JList.
 java.lang.Object quakeListlocationToValue(java.awt.Point pointObj)
          Returns the quake list object associated with the cell closest to the given location.
 java.lang.Object removeEventForIndex(int idx)
          Removes the event message record object for the given index value from the table of events.
 void removeEventFromList(java.lang.String keyStr)
          Removes the given event message record object from the table of events.
 void requestQuakeListFocus()
          Requests that the quake list have the keyboard focus.
 void selectLastEventInList()
          Selects the last event on the list.
 void selectLastEventInList(boolean autoSelFlag)
          Selects the last event on the list.
 boolean selectProductsFromList(java.lang.String name)
          Selects the previous or next event with products.
 void setEventSelectionChangeListener(SortedEventJListMgr.EventSelectionChangeListener listenerObj)
          Sets the callback listener to be used when a new event is selected.
 void setQuakeListListenersEnabled(boolean flgVal)
          Sets whether or not 'ListDataListener' objects attached to the list model for the quake list are called when changes occur.
 void setSelectedEventKeyStr(java.lang.String keyStr)
          Sets the selected event message record object.
 void setSelectedEventKeyStr(java.lang.String keyStr, boolean autoSelFlag)
          Sets the selected event message record object.
protected  void setSelectedEventKeyStr(java.lang.String keyStr, boolean autoSelFlag, boolean inProcListSelChangeFlag)
          Sets the selected event message record object.
 void updateQuakeListColors(java.awt.Color foregroundColor, java.awt.Color backgroundColor, java.awt.Color selForegroundColor, java.awt.Color selBackgroundColor, boolean directFlag)
          Updates the quake list colors.
 
Methods inherited from class com.isti.quakewatch.message.EventListManager
clearEventsListChangedFlag, getEventsListChangedFlag, getEventsListIterator, getEventsListSize, getEventsListSyncObj, getEventsListValuesVec, getIndexOfEventKey, getLastEventInList, getRecordObjForIndex, getRecordObjForKeyStr, isEventKeyInList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

quakeListObj

protected final SortedValuesJList quakeListObj

quakeListEnabledFlag

protected boolean quakeListEnabledFlag

selectedRecordObj

protected QWEventMsgRecord selectedRecordObj

selectedRecordObjSyncObj

protected final java.lang.Object selectedRecordObjSyncObj

setSelEventMethodSyncObj

protected final java.lang.Object setSelEventMethodSyncObj

inSetSelectedEventFlag

protected boolean inSetSelectedEventFlag

eventSelChangeListener

protected SortedEventJListMgr.EventSelectionChangeListener eventSelChangeListener

lastManualSelectTime

protected long lastManualSelectTime

lastManSelTimeSyncObj

protected final java.lang.Object lastManSelTimeSyncObj
Constructor Detail

SortedEventJListMgr

public SortedEventJListMgr(javax.swing.ListCellRenderer quakeListCellRenderer,
                           LogFile logFileObj,
                           boolean sortDirFlag)
Creates an event list manager.

Parameters:
quakeListCellRenderer - the list-cell renderer to use with the quake JList.
logFileObj - log file object to use.
sortDirFlag - true for ascending sort order, false for descending.

SortedEventJListMgr

public SortedEventJListMgr(javax.swing.ListCellRenderer quakeListCellRenderer,
                           LogFile logFileObj,
                           boolean sortDirFlag,
                           int sortType)
Creates an event list manager.

Parameters:
quakeListCellRenderer - the list-cell renderer to use with the quake JList.
logFileObj - log file object to use.
sortDirFlag - true for ascending sort order, false for descending.
sortType - the sort type.

SortedEventJListMgr

public SortedEventJListMgr()
Creates a "dummy" list manager.

Method Detail

setEventSelectionChangeListener

public void setEventSelectionChangeListener(SortedEventJListMgr.EventSelectionChangeListener listenerObj)
Sets the callback listener to be used when a new event is selected. Only one callback listener may be installed at a time. Calling this method with a 'null' parameter will clear the listener. This method should not be called at any time that a selection change may be in progress.

Parameters:
listenerObj - the callback listener to use.

fillAndEnableQuakeList

public void fillAndEnableQuakeList()
Sets up the quake list to use the list model held by this object.


addEventToList

public void addEventToList(QWEventMsgRecord recObj)
Adds the given event message record object to the table of events, putting it into sorted position.

Specified by:
addEventToList in interface EventAdderInterface
Overrides:
addEventToList in class EventListManager
Parameters:
recObj - the event message record object to add.

removeEventFromList

public void removeEventFromList(java.lang.String keyStr)
Removes the given event message record object from the table of events.

Overrides:
removeEventFromList in class EventListManager
Parameters:
keyStr - the event-ID string for the message record to be removed.

removeEventForIndex

public java.lang.Object removeEventForIndex(int idx)
Removes the event message record object for the given index value from the table of events.

Overrides:
removeEventForIndex in class EventListManager
Parameters:
idx - the index of the event message record object to be removed.
Returns:
The "key" object for the removed record, or null if a record for the given index could not be found.

setSelectedEventKeyStr

public void setSelectedEventKeyStr(java.lang.String keyStr,
                                   boolean autoSelFlag)
Sets the selected event message record object.

Parameters:
keyStr - the ID key string of event message record to select, or null to have none selected.
autoSelFlag - true if event is being "automatically" selected; false if event is being "manually" selected.

setSelectedEventKeyStr

public void setSelectedEventKeyStr(java.lang.String keyStr)
Sets the selected event message record object.

Parameters:
keyStr - the ID key string of event message record to select, or null to have none selected.

setSelectedEventKeyStr

protected void setSelectedEventKeyStr(java.lang.String keyStr,
                                      boolean autoSelFlag,
                                      boolean inProcListSelChangeFlag)
Sets the selected event message record object.

Parameters:
keyStr - the ID key string of event message record to select, or null to have none selected.
autoSelFlag - true if event is being "automatically" selected; false if event is being "manually" selected.
inProcListSelChangeFlag - true if method called from 'processQuakeListSelChange()'.

selectLastEventInList

public void selectLastEventInList(boolean autoSelFlag)
Selects the last event on the list.

Parameters:
autoSelFlag - true if event is being "automatically" selected; false if event is being "manually" selected.

selectLastEventInList

public void selectLastEventInList()
Selects the last event on the list.


getSelectedRecordObj

public QWEventMsgRecord getSelectedRecordObj()
Returns the selected event message record object.


selectProductsFromList

public boolean selectProductsFromList(java.lang.String name)
Selects the previous or next event with products.

Parameters:
name - the name of the menu item.
Returns:
true if a different event with products was selected, false if none was found.

fireQuakeListUpdate

public void fireQuakeListUpdate()
Updates the quake JList object.


getSelectedIndex

protected int getSelectedIndex()
Returns the index for the current selected event record.

Returns:
The index for the current selected event record, or -1 if no event is selected.

processQuakeListSelChange

protected void processQuakeListSelChange(java.lang.Object keyObj)
Processes a selection-change event from the JList.

Parameters:
keyObj - the key for the newly selected event.

setQuakeListListenersEnabled

public void setQuakeListListenersEnabled(boolean flgVal)
Sets whether or not 'ListDataListener' objects attached to the list model for the quake list are called when changes occur.

Overrides:
setQuakeListListenersEnabled in class EventListManager
Parameters:
flgVal - true to enable calling of 'ListDataListener' objects, false to disable.

fireQuakeListContentsChanged

public void fireQuakeListContentsChanged()
Fires a contents-changed event to the list model for the quake list.

Overrides:
fireQuakeListContentsChanged in class EventListManager

ensureQuakeListSelectionVisible

public void ensureQuakeListSelectionVisible()
Ensures that the current quake list selection is visible.

Overrides:
ensureQuakeListSelectionVisible in class EventListManager

requestQuakeListFocus

public void requestQuakeListFocus()
Requests that the quake list have the keyboard focus.


updateQuakeListColors

public void updateQuakeListColors(java.awt.Color foregroundColor,
                                  java.awt.Color backgroundColor,
                                  java.awt.Color selForegroundColor,
                                  java.awt.Color selBackgroundColor,
                                  boolean directFlag)
Updates the quake list colors.

Parameters:
foregroundColor - the foreground color to set, or null to leave the color unchanged.
backgroundColor - the background color to set, or null to leave the color unchanged.
selForegroundColor - the selection foreground color to set, or null to leave the color unchanged.
selBackgroundColor - the selection background color to set, or null to leave the color unchanged.
directFlag - if true then the color setting is always done immediately; if false and the thread calling this method is not the event-dispatch thread then the action is queued and invoked later by the event-dispatch thread.

quakeListlocationToValue

public java.lang.Object quakeListlocationToValue(java.awt.Point pointObj)
Returns the quake list object associated with the cell closest to the given location.

Parameters:
pointObj - the coordinates to use, relative to the quake list.
Returns:
The quake list object associated with the cell closest to the given location, or null if none found.

getQuakeListSelectedValue

public java.lang.Object getQuakeListSelectedValue()
Returns the currently selected value on the quake list.

Returns:
The currently selected value on the quake list, or null if none currently selected.

addQuakeListMouseListener

public void addQuakeListMouseListener(java.awt.event.MouseListener listenerObj)
Adds the given mouse listener to the quake list.

Parameters:
listenerObj - the mouse listener object to use.

addQuakeListKeyListener

public void addQuakeListKeyListener(java.awt.event.KeyListener listenerObj)
Adds the given key listener to the quake list.

Parameters:
listenerObj - the key listener object to use.

getQuakeListObj

public java.awt.Component getQuakeListObj()
Returns the quake-list 'JList' component object.

Returns:
The quake-list 'JList' component object.

getQuakeListComponent

public java.awt.Component getQuakeListComponent()
Returns the quake-list display component object. Sub-classes may override this method to return a hosting panel instead of the 'JList' object itself.

Returns:
The quake-list display component object.

getLastManualSelectTime

public long getLastManualSelectTime()
Returns the time of the last "manual" selection change to the list.

Returns:
The time of the last "manual" selection change to the list, or 0 if none have occurred.