info.joseluismartin.gui
Class PageableTable<T>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by info.joseluismartin.gui.PageableTable<T>
All Implemented Interfaces:
PaginatorListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RowSorterListener

public class PageableTable<T>
extends JPanel
implements RowSorterListener, PaginatorListener

A JPanel with a JTable and paginator.

This table view uses a PageableDataSource to query for data by pages. Has a paginator control to navigate on records and show page info.

You need to configure the PageableDatasource and the ListTableModel before usage.

Author:
Jose Luis Martin - (jlm@joseluismartin.info)
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 inherited from class javax.swing.JComponent
accessibleContext, 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
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
PageableTable()
           
 
Method Summary
 void addChangeListener(ChangeListener l)
           
 void addEditorListener(EditorListener listener)
           
 Icon getCancelIcon()
           
 List<Serializable> getChecked()
           
 PageableDataSource<T> getDataSource()
           
 Window getEditor()
          Get a dialog for editing a row
 Window getEditor(Object toEdit)
           
 String getEditorName()
           
 Object getFilter()
           
 GuiFactory getGuiFactory()
           
 org.springframework.context.MessageSource getMessageSource()
           
 Icon getOkIcon()
           
 Page.Order getOrder()
           
 Paginator getPaginator()
           
 PaginatorView getPaginatorView()
           
 String getSortPropertyName()
           
 ListTableModel getTableModel()
           
 TableService getTableService()
           
 Icon getUserMenuIcon()
           
 Icon getVisibilityMenuIcon()
           
 List<T> getVisibleSelected()
           
 void init()
          Initalize component after properties set.
 boolean isConfigureEditors()
           
 boolean isShowMenu()
           
 boolean isShowPaginator()
           
 void pageChanged(PageChangedEvent event)
          Handle paginators changes.
 void refresh()
           
 void removeChangeListener(ChangeListener l)
           
 void removeEditorListener(EditorListener listener)
           
 void restoreState()
          Restore TableState
 void restoreState(TableState state)
          Restore the column visibility from TableState
 void saveState()
           
 void selectAll()
          Select all posible filtered results.
 void setCancelIcon(Icon cancelIcon)
           
 void setConfigureEditors(boolean configureEditors)
           
 void setDataSource(PageableDataSource<T> dataSource)
           
 void setDefaultRenderer(Class<?> columnClass, TableCellRenderer renderer)
           
 void setEditorName(String editorName)
           
 void setFilter(Object filter)
           
 void setGuiFactory(GuiFactory guiFactory)
           
 void setMessageSource(org.springframework.context.MessageSource messageSource)
           
 void setOkIcon(Icon okIcon)
           
 void setOrder(Page.Order order)
           
 void setPaginatorView(PaginatorView paginatorView)
           
 void setShowMenu(boolean showMenu)
           
 void setShowPaginator(boolean showPaginator)
           
 void setSortPropertyName(String sortPropertyName)
           
 void setTableModel(ListTableModel tableModel)
           
 void setTableService(TableService tableService)
           
 void setUserMenuIcon(Icon userMenuIcon)
           
 void setVisibilityMenuIcon(Icon visibilityMenuIcon)
           
 void sorterChanged(RowSorterEvent e)
          Handle sort changes in model sorter.
 void unSelectAll()
          Un select all selected
 
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, setVisible, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PageableTable

public PageableTable()
Method Detail

init

public void init()
Initalize component after properties set. Normally called by context vía init-method


sorterChanged

public void sorterChanged(RowSorterEvent e)
Handle sort changes in model sorter. Query PageableDataSource for new page with the sort changes

Specified by:
sorterChanged in interface RowSorterListener
See Also:
RowSorterListener.sorterChanged(javax.swing.event.RowSorterEvent)

pageChanged

public void pageChanged(PageChangedEvent event)
Handle paginators changes.

Specified by:
pageChanged in interface PaginatorListener
See Also:
PaginatorListener.pageChanged(info.joseluismartin.dao.PageChangedEvent)

getEditor

public Window getEditor()
Get a dialog for editing a row


getEditor

public Window getEditor(Object toEdit)
Parameters:
toEdit - model to edit
Returns:
model editor.

restoreState

public void restoreState()
Restore TableState


restoreState

public void restoreState(TableState state)
Restore the column visibility from TableState

Parameters:
state - the table state

saveState

public void saveState()

addChangeListener

public void addChangeListener(ChangeListener l)

removeChangeListener

public void removeChangeListener(ChangeListener l)

getPaginatorView

public PaginatorView getPaginatorView()
Returns:
the paginatorView

setPaginatorView

public void setPaginatorView(PaginatorView paginatorView)
Parameters:
paginatorView - the paginatorView to set

getDataSource

public PageableDataSource<T> getDataSource()
Returns:
the dataSource

setDataSource

public void setDataSource(PageableDataSource<T> dataSource)
Parameters:
dataSource - the dataSource to set

getPaginator

public Paginator getPaginator()

getTableModel

public ListTableModel getTableModel()
Returns:
the tableModel

setTableModel

public void setTableModel(ListTableModel tableModel)
Parameters:
tableModel - the tableModel to set

getVisibilityMenuIcon

public Icon getVisibilityMenuIcon()

setVisibilityMenuIcon

public void setVisibilityMenuIcon(Icon visibilityMenuIcon)

getOkIcon

public Icon getOkIcon()

setOkIcon

public void setOkIcon(Icon okIcon)

getCancelIcon

public Icon getCancelIcon()

setCancelIcon

public void setCancelIcon(Icon cancelIcon)

getGuiFactory

public GuiFactory getGuiFactory()

setGuiFactory

public void setGuiFactory(GuiFactory guiFactory)

getEditorName

public String getEditorName()

setEditorName

public void setEditorName(String editorName)

refresh

public void refresh()

getFilter

public Object getFilter()
Returns:
the filter

setFilter

public void setFilter(Object filter)
Parameters:
filter - the filter to set

setDefaultRenderer

public void setDefaultRenderer(Class<?> columnClass,
                               TableCellRenderer renderer)
Parameters:
columnClass -
renderer -
See Also:
JTable.setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer)

getSortPropertyName

public String getSortPropertyName()

setSortPropertyName

public void setSortPropertyName(String sortPropertyName)

getOrder

public Page.Order getOrder()

setOrder

public void setOrder(Page.Order order)

getTableService

public TableService getTableService()
Returns:
the tableService

setTableService

public void setTableService(TableService tableService)
Parameters:
tableService - the tableService to set

getUserMenuIcon

public Icon getUserMenuIcon()
Returns:
the userMenuIcon

setUserMenuIcon

public void setUserMenuIcon(Icon userMenuIcon)
Parameters:
userMenuIcon - the userMenuIcon to set

getMessageSource

public org.springframework.context.MessageSource getMessageSource()
Returns:
the messageSource

setMessageSource

@Autowired
public void setMessageSource(org.springframework.context.MessageSource messageSource)
Parameters:
messageSource - the messageSource to set

isShowMenu

public boolean isShowMenu()
Returns:
the showMenu

setShowMenu

public void setShowMenu(boolean showMenu)
Parameters:
showMenu - the showMenu to set

getChecked

public List<Serializable> getChecked()
Returns:
List of checked keys

getVisibleSelected

public List<T> getVisibleSelected()
Returns:
model selected and visible in current page

selectAll

public void selectAll()
Select all posible filtered results.


unSelectAll

public void unSelectAll()
Un select all selected


isConfigureEditors

public boolean isConfigureEditors()
Returns:
the configureEditors

setConfigureEditors

public void setConfigureEditors(boolean configureEditors)
Parameters:
configureEditors - the configureEditors to set

addEditorListener

public void addEditorListener(EditorListener listener)

removeEditorListener

public void removeEditorListener(EditorListener listener)

isShowPaginator

public boolean isShowPaginator()
Returns:
the showPaginator

setShowPaginator

public void setShowPaginator(boolean showPaginator)
Parameters:
showPaginator - the showPaginator to set


Copyright © 2013 JDAL. All Rights Reserved.