Class AbstractContainerList<M extends AbstractContainerManager,C extends AbstractContainer>
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.visualization.container.AbstractContainerList<M,C>
-
- Type Parameters:
M
- the type of container manager to useC
- the type of container to use
- All Implemented Interfaces:
CleanUpHandler
,DataChangeListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,ListSelectionListener
,TableModelListener
- Direct Known Subclasses:
InstanceContainerList
,ReportContainerList
,SpreadSheetRowContainerList
,TimeseriesContainerList
,XYSequenceContainerList
public class AbstractContainerList<M extends AbstractContainerManager,C extends AbstractContainer> extends BasePanel implements CleanUpHandler, TableModelListener, ListSelectionListener, DataChangeListener
An abstract panel that lists containers in a JTable.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected JLabel
m_LabelTitle
the title label.protected HashSet<ListSelectionListener>
m_ListSelectionListeners
the list selection listeners to manage.protected SearchPanel
m_PanelSearch
the panel for searching the entry names.protected ContainerListPopupMenuSupplier<M,C>
m_PopupMenuSupplier
the popup menu supplier.protected ContainerTable<M,C>
m_Table
the table for displaying the containers.protected HashSet<TableModelListener>
m_TableModelListeners
the table model listeners to manage.protected String
m_Title
the title string.-
Fields inherited from class adams.gui.core.BasePanel
m_FileChooser
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description AbstractContainerList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListSelectionListener(ListSelectionListener l)
Adds the given listener to the internal list.void
addTableModelListener(TableModelListener l)
Adds the given listener to the internal list.void
cleanUp()
Cleans up data structures, frees up memory.protected void
configureModel(ContainerModel<M,C> model)
Configures the model.protected ContainerModel<M,C>
createModel(M manager)
Creates a new model.protected ContainerTable<M,C>
createTable()
Creates a new table.void
dataChanged(DataChangeEvent e)
Gets called if the data of the container list has changed.boolean
getAllowSearch()
Returns whether the entry list is searchable.AbstractContainerTableColumnNameGenerator
getColumnNameGenerator()
Returns the current generator for the column names.ContainerModel<M,C>
getContainerModel()
Returns the underlying container model.boolean
getDisplayDatabaseID()
Returns whether the database ID column will be displayed where possible.AbstractContainerDisplayStringGenerator
getDisplayStringGenerator()
Returns the current display string generator.boolean
getDisplayVisibility()
Returns whether the visibility column will be displayed where possible.M
getManager()
Returns the current manager, can be null.ContainerListPopupMenuSupplier<M,C>
getPopupMenuSupplier()
Returns the current popup menu supplier.int
getSelectionMode()
Returns the selection mode.ContainerTable<M,C>
getTable()
Returns the table.String
getTitle()
Returns the title.boolean
hasTitle()
Returns whether a title has been set.protected void
initGUI()
For initializing the GUI.protected void
initialize()
Initializes the members.protected ContainerModel<M,C>
newModel(M manager)
Creates a new model.void
removeListSelectionListener(ListSelectionListener l)
Removes the given listener from the internal list.void
removeTableModelListener(TableModelListener l)
Removes the given listener from the internal list.void
setAllowSearch(boolean value)
Sets whether the entry list is searchable.void
setColumnNameGenerator(AbstractContainerTableColumnNameGenerator value)
Sets the generator for the column names.void
setDisplayDatabaseID(boolean value)
Whether to display the database ID column (if possible).void
setDisplayStringGenerator(AbstractContainerDisplayStringGenerator value)
Sets the display string generator.void
setDisplayVisibility(boolean value)
Whether to display the visibility column (if possible).void
setManager(M value)
Sets the manager with the containers to use for display.void
setPopupMenuSupplier(ContainerListPopupMenuSupplier<M,C> value)
Sets the popup menu supplier, if the user right-clicks on the table cells.void
setSelectionMode(int value)
Sets the selection mode of the table.void
setTitle(String value)
Sets the title of the container list.void
tableChanged(TableModelEvent e)
Gets called when the underlying data model changes.protected void
updateTableColumnWidths()
Gets called when the table data changes.protected void
updateTitle()
Updates the title, including the number of containers in the list.void
valueChanged(ListSelectionEvent e)
Called whenever the value of the selection changes.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, finishInit, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
m_Table
protected ContainerTable<M extends AbstractContainerManager,C extends AbstractContainer> m_Table
the table for displaying the containers.
-
m_PopupMenuSupplier
protected ContainerListPopupMenuSupplier<M extends AbstractContainerManager,C extends AbstractContainer> m_PopupMenuSupplier
the popup menu supplier.
-
m_LabelTitle
protected JLabel m_LabelTitle
the title label.
-
m_Title
protected String m_Title
the title string.
-
m_TableModelListeners
protected HashSet<TableModelListener> m_TableModelListeners
the table model listeners to manage.
-
m_ListSelectionListeners
protected HashSet<ListSelectionListener> m_ListSelectionListeners
the list selection listeners to manage.
-
m_PanelSearch
protected SearchPanel m_PanelSearch
the panel for searching the entry names.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classBasePanel
-
createTable
protected ContainerTable<M,C> createTable()
Creates a new table.- Returns:
- the new table
-
createModel
protected ContainerModel<M,C> createModel(M manager)
Creates a new model.- Parameters:
manager
- the manager to use for the model- Returns:
- the new model
-
configureModel
protected void configureModel(ContainerModel<M,C> model)
Configures the model.- Parameters:
model
- the model to configure
-
newModel
protected ContainerModel<M,C> newModel(M manager)
Creates a new model.- Parameters:
manager
- the manager to base the model on- Returns:
- the model
-
getContainerModel
public ContainerModel<M,C> getContainerModel()
Returns the underlying container model.- Returns:
- the container model, null if of different type
-
setManager
public void setManager(M value)
Sets the manager with the containers to use for display.- Parameters:
value
- the manager
-
getManager
public M getManager()
Returns the current manager, can be null.- Returns:
- the manager or null if not set
-
getTable
public ContainerTable<M,C> getTable()
Returns the table.- Returns:
- the table
-
setSelectionMode
public void setSelectionMode(int value)
Sets the selection mode of the table.- Parameters:
value
- the mode- See Also:
ListSelectionModel.setSelectionMode(int)
-
getSelectionMode
public int getSelectionMode()
Returns the selection mode.- Returns:
- the mode
- See Also:
ListSelectionModel.getSelectionMode()
-
setDisplayStringGenerator
public void setDisplayStringGenerator(AbstractContainerDisplayStringGenerator value)
Sets the display string generator.- Parameters:
value
- the new generator
-
getDisplayStringGenerator
public AbstractContainerDisplayStringGenerator getDisplayStringGenerator()
Returns the current display string generator.- Returns:
- the generator
-
setColumnNameGenerator
public void setColumnNameGenerator(AbstractContainerTableColumnNameGenerator value)
Sets the generator for the column names.- Parameters:
value
- the new generator
-
getColumnNameGenerator
public AbstractContainerTableColumnNameGenerator getColumnNameGenerator()
Returns the current generator for the column names.- Returns:
- the generator
-
setPopupMenuSupplier
public void setPopupMenuSupplier(ContainerListPopupMenuSupplier<M,C> value)
Sets the popup menu supplier, if the user right-clicks on the table cells.- Parameters:
value
- the supplier, can be null to turn off menu
-
getPopupMenuSupplier
public ContainerListPopupMenuSupplier<M,C> getPopupMenuSupplier()
Returns the current popup menu supplier.- Returns:
- the supplier, can be null if turned off
-
setDisplayVisibility
public void setDisplayVisibility(boolean value)
Whether to display the visibility column (if possible).- Parameters:
value
- if true then the column will be displayed where possible
-
getDisplayVisibility
public boolean getDisplayVisibility()
Returns whether the visibility column will be displayed where possible.- Returns:
- true if the column will be displayed where possible
-
setDisplayDatabaseID
public void setDisplayDatabaseID(boolean value)
Whether to display the database ID column (if possible).- Parameters:
value
- if true then the column will be displayed where possible
-
getDisplayDatabaseID
public boolean getDisplayDatabaseID()
Returns whether the database ID column will be displayed where possible.- Returns:
- true if the column will be displayed where possible
-
hasTitle
public boolean hasTitle()
Returns whether a title has been set.- Returns:
- true if a title was set
-
setTitle
public void setTitle(String value)
Sets the title of the container list.- Parameters:
value
- the title, use empty string or null to remove
-
updateTitle
protected void updateTitle()
Updates the title, including the number of containers in the list.
-
getTitle
public String getTitle()
Returns the title.- Returns:
- the title, null if none set
-
updateTableColumnWidths
protected void updateTableColumnWidths()
Gets called when the table data changes. Re-calculates the column widths of the table.- See Also:
tableChanged(TableModelEvent)
-
tableChanged
public void tableChanged(TableModelEvent e)
Gets called when the underlying data model changes.
Default implementation notifies all the TableModelListener with the even that this method receives.- Specified by:
tableChanged
in interfaceTableModelListener
- Parameters:
e
- the event- See Also:
m_TableModelListeners
-
addTableModelListener
public void addTableModelListener(TableModelListener l)
Adds the given listener to the internal list.- Parameters:
l
- the listener to add
-
removeTableModelListener
public void removeTableModelListener(TableModelListener l)
Removes the given listener from the internal list.- Parameters:
l
- the listener to remove
-
valueChanged
public void valueChanged(ListSelectionEvent e)
Called whenever the value of the selection changes.
Default implementation forwards the event to all managed list selection listeners.- Specified by:
valueChanged
in interfaceListSelectionListener
- Parameters:
e
- the event that characterizes the change.- See Also:
m_ListSelectionListeners
-
addListSelectionListener
public void addListSelectionListener(ListSelectionListener l)
Adds the given listener to the internal list.- Parameters:
l
- the listener to add
-
removeListSelectionListener
public void removeListSelectionListener(ListSelectionListener l)
Removes the given listener from the internal list.- Parameters:
l
- the listener to remove
-
dataChanged
public void dataChanged(DataChangeEvent e)
Gets called if the data of the container list has changed.- Specified by:
dataChanged
in interfaceDataChangeListener
- Parameters:
e
- the event that the container list sent
-
setAllowSearch
public void setAllowSearch(boolean value)
Sets whether the entry list is searchable.- Parameters:
value
- true if to make the list searchable
-
getAllowSearch
public boolean getAllowSearch()
Returns whether the entry list is searchable.- Returns:
- true if list is searchable
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
-