org.openpermis.editor.policy.gui.checklist
Class CheckList<T>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by org.openpermis.editor.policy.gui.checklist.CheckList<T>
Type Parameters:
T - type of the items in the check list.
All Implemented Interfaces:
ComponentListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, AncestorListener, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable

public class CheckList<T>
extends JTable
implements AncestorListener, ComponentListener

GUI component that provides a list with checkboxes on the left side.

The checklist is in fact a typed editor for two observable lists, the first being the list of all choices and the second containing the checked items.

See Also:
Serialized Form
Since:
0.1.0

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode
 
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.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
 
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
CheckList()
          Creates a new unbound check list.
CheckList(org.jdesktop.observablecollections.ObservableList<T> pool, org.jdesktop.observablecollections.ObservableList<T> selection)
          Creates a new checklist for the specified pool and selection list.
 
Method Summary
 void ancestorAdded(AncestorEvent event)
           
 void ancestorMoved(AncestorEvent event)
           
 void ancestorRemoved(AncestorEvent event)
           
 void bind(org.jdesktop.observablecollections.ObservableList<T> pool, org.jdesktop.observablecollections.ObservableList<T> selection)
          Binds the check list to the specified pool and selection list.
 void componentHidden(ComponentEvent e)
           
 void componentMoved(ComponentEvent e)
           
 void componentResized(ComponentEvent e)
          Called if the size of the enclosing viewport changes.
 void componentShown(ComponentEvent e)
           
protected  void configureEnclosingScrollPane()
          Disables the header view of this table.
 void doLayout()
          Overrides the default layout strategy to automatically adjust column widths.
 boolean editCellAt(int row, int column, EventObject e)
           
 T getActivePart()
           
 TableCellRenderer getCellRenderer(int row, int column)
           
protected  int getColumnWidth(int column)
          Calculates the maximum width of the specified column.
protected  JScrollPane getEnclosingScrollPane()
          Returns the enclosing scroll pane or null if there is none.
protected  JViewport getEnclosingViewport()
          Returns the enclosing viewport or null if there is none.
 CheckListModel<T> getModel()
           
protected  int getViewportWidth()
          Returns the view of the enclosing viewport or the width of this table.
protected  void layoutColumns()
          Modifies the column widths according to the data in the table.
 void scrollRectToVisible(Rectangle rect)
           
 void setDoubleClickAction(Action action)
          Sets the action to be executed if a double click is performed on a non-check column.
protected  void setEnclosingHorizontalScrollBarEnabled(boolean enabled)
          Configures the horizontal scroll bar policy of the enclosing scroll pane (if any).
 void setItemRenderer(TableCellRenderer itemRenderer)
          Sets the renderer to be used for check list items.
 void setModel(TableModel dataModel)
           
 void setVisibleRowCount(int rows)
          Sets the number of visible rows that the list shows by preference.
 void unbind()
          Removes the current check list binding and sets and empty model.
protected  void unconfigureEnclosingScrollPane()
           
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, tableChanged, updateUI, valueChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, 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, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, 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, 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

CheckList

public CheckList()
Creates a new unbound check list.

See Also:
bind(ObservableList, ObservableList)
Since:
0.1.0

CheckList

public CheckList(org.jdesktop.observablecollections.ObservableList<T> pool,
                 org.jdesktop.observablecollections.ObservableList<T> selection)
Creates a new checklist for the specified pool and selection list.

Parameters:
pool - the available list items shown.
selection - the list of selected items from the pool.
Since:
0.1.0
Method Detail

setItemRenderer

public void setItemRenderer(TableCellRenderer itemRenderer)
Sets the renderer to be used for check list items.

Parameters:
itemRenderer - the item renderer.
Since:
0.1.0

setDoubleClickAction

public void setDoubleClickAction(Action action)
Sets the action to be executed if a double click is performed on a non-check column.

Parameters:
action - the action to be executed.
Since:
0.1.0

bind

public void bind(org.jdesktop.observablecollections.ObservableList<T> pool,
                 org.jdesktop.observablecollections.ObservableList<T> selection)
Binds the check list to the specified pool and selection list.

Parameters:
pool - the available list items shown.
selection - the list of selected items from the pool.
Since:
0.1.0

unbind

public void unbind()
Removes the current check list binding and sets and empty model.

Since:
0.9.0

setVisibleRowCount

public void setVisibleRowCount(int rows)
Sets the number of visible rows that the list shows by preference.

Parameters:
rows - the number of rows requested.
Since:
0.1.0

getColumnWidth

protected int getColumnWidth(int column)
Calculates the maximum width of the specified column.

Parameters:
column - the column for which to determine the maximum width.
Returns:
the width requested.
Since:
0.1.0

getEnclosingScrollPane

protected JScrollPane getEnclosingScrollPane()
Returns the enclosing scroll pane or null if there is none.

Returns:
the enclosing scroll pane or null if there is none.
Since:
0.9.0

getEnclosingViewport

protected JViewport getEnclosingViewport()
Returns the enclosing viewport or null if there is none.

Returns:
the enclosing viewport or null if there is none.
Since:
0.9.0

getViewportWidth

protected int getViewportWidth()
Returns the view of the enclosing viewport or the width of this table.

Returns:
the width currently showing.
Since:
0.1.0

setEnclosingHorizontalScrollBarEnabled

protected void setEnclosingHorizontalScrollBarEnabled(boolean enabled)
Configures the horizontal scroll bar policy of the enclosing scroll pane (if any).

We have to manage the scroll bar policy on our own, the ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED policy will not work since we are adjusting our size on-the-fly according to the viewport width to simulate a list.

Parameters:
enabled - true to show the scroll bar, false to hide it.
Since:
0.9.0

layoutColumns

protected void layoutColumns()
Modifies the column widths according to the data in the table.

Adjusts all columns to their preferred with (i.e. the width of the largest item contained) and optionally stretches the last column to fill the remaining slack space (to simulate the looks of a list).

The horizontal scroll bar of the enclosing scroll pane is configured according to the total width of all columns calculated. It is either completely disabled (if not required) or constantly enabled (if total width is heigher than viewport width).

See Also:
setEnclosingHorizontalScrollBarEnabled(boolean)
Since:
0.1.0

getActivePart

public T getActivePart()
Since:
0.1.0

setModel

public void setModel(TableModel dataModel)
Overrides:
setModel in class JTable
Since:
0.1.0

getModel

public CheckListModel<T> getModel()
Overrides:
getModel in class JTable
Since:
0.1.0

getCellRenderer

public TableCellRenderer getCellRenderer(int row,
                                         int column)
Overrides:
getCellRenderer in class JTable
Since:
0.1.0

doLayout

public void doLayout()
Overrides the default layout strategy to automatically adjust column widths.

Overrides:
doLayout in class JTable
See Also:
layoutColumns()
Since:
0.1.0

editCellAt

public boolean editCellAt(int row,
                          int column,
                          EventObject e)
Overrides:
editCellAt in class JTable
Since:
0.1.0

configureEnclosingScrollPane

protected void configureEnclosingScrollPane()
Disables the header view of this table.

Overrides:
configureEnclosingScrollPane in class JTable
Since:
0.1.0

unconfigureEnclosingScrollPane

protected void unconfigureEnclosingScrollPane()
Overrides:
unconfigureEnclosingScrollPane in class JTable
Since:
0.1.0

scrollRectToVisible

public void scrollRectToVisible(Rectangle rect)
Overrides:
scrollRectToVisible in class JComponent
Since:
0.1.0

ancestorAdded

public void ancestorAdded(AncestorEvent event)
Specified by:
ancestorAdded in interface AncestorListener
Since:
0.1.0

ancestorMoved

public void ancestorMoved(AncestorEvent event)
Specified by:
ancestorMoved in interface AncestorListener
Since:
0.1.0

ancestorRemoved

public void ancestorRemoved(AncestorEvent event)
Specified by:
ancestorRemoved in interface AncestorListener
Since:
0.1.0

componentHidden

public void componentHidden(ComponentEvent e)
Specified by:
componentHidden in interface ComponentListener
Since:
0.1.0

componentMoved

public void componentMoved(ComponentEvent e)
Specified by:
componentMoved in interface ComponentListener
Since:
0.1.0

componentResized

public void componentResized(ComponentEvent e)
Called if the size of the enclosing viewport changes.

We will adjust our column sizes to match the viewport size and show/hide the scroll bar of the enclosing scroll pane as needed here.

Specified by:
componentResized in interface ComponentListener
Since:
0.1.0

componentShown

public void componentShown(ComponentEvent e)
Specified by:
componentShown in interface ComponentListener
Since:
0.1.0


OpenPermis Role Based Access Control 0.9.0 (Build 16)
2009/08/13 07:17:21
Copyright (c) 2002-2007 Ergon Informatik AG