JIDE 3.5.15

com.jidesoft.list
Class GroupList

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JList
                  extended by com.jidesoft.list.GroupList
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class GroupList
extends JList

GroupList is JList that supports the grouping of items. Each group row has a special cell renderer which is different from the regular cell renderer. You can decide through an interface called GroupableListModel to decide which rows are included under which group.

The group rows can have their own cell renderer which can be set by setGroupCellRenderer(javax.swing.ListCellRenderer). Typically, user doesn't want to select the group rows. But if they do want, you can call setGroupCellSelectable(boolean) and set it true.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JList
JList.AccessibleJList, JList.DropLocation
 
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
protected  boolean _groupCellSelectable
          Holds value of property headersSelectable.
static int HORIZONTAL
          Indicates the default layout: one row for each group.
 
Fields inherited from class javax.swing.JList
HORIZONTAL_WRAP, VERTICAL, VERTICAL_WRAP
 
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
GroupList()
          Constructs a GroupList with an empty model.
GroupList(GroupableListModel dataModel)
          Constructs a GroupList that displays the elements in the specified, non-null GroupableListModel.
GroupList(GroupListModel dataModel)
          Constructs a GroupList that displays the elements in the specified, non-null GroupListModel.
GroupList(List<?> listData)
          Constructs a GroupList that displays the elements in the specified List.
GroupList(ListModel dataModel)
          Constructs a GroupList that displays the elements in the specified, non-null ListModel.
GroupList(Map<Object,?> map)
          Creates a GroupList.
GroupList(Object[] listData)
          Constructs a GroupList that displays the elements in the specified array.
 
Method Summary
protected static GroupableListModel createModel(Map<Object,?> map)
          Returns a GroupableListModel wrapping the specified object.
 String getActualUIClassID()
           
 int getColumnCount(int rowIndex)
          Returns the amount of cells in the specified row.
 int[] getGroupCellIndices()
          Gets the group rows indices.
 ListCellRenderer getGroupCellRenderer()
          Returns the object that renders the list headers.
 int getLayoutOrientation()
          Returns the layout orientation property for the list: JList.VERTICAL if the layout is a single column of cells, JList.VERTICAL_WRAP if the layout is "newspaper style" with the content flowing vertically then horizontally, or JList.HORIZONTAL_WRAP if the layout is "newspaper style" with the content flowing horizontally then vertically.
 GroupListModel getModel()
          Returns the data model that holds the list of items displayed by the GroupList component.
 int getPreferredColumnCount()
          Returns the preferred number of columns.
 int getRowCount()
          Returns the number of rows.
 String getToolTipText(MouseEvent event)
          Overrides the method in JList to provide tooltips for group rows through the group cell renderer.
 boolean isGroupCellSelectable()
          Returns true if the group rows are selectable, false otherwise.
 void setGroupCellRenderer(ListCellRenderer cellRenderer)
          Sets the cell renderer for the group cells
 void setGroupCellSelectable(boolean groupCellSelectable)
          Set a new value which represents whether group rows are selectable for this GroupList.
 void setLayoutOrientation(int layoutOrientation)
          Override the method in JList to support a new orientation called HORIZONTAL.
 void setModel(ListModel model)
          Overrides to wrap the model into GroupableListModel if the model itself is not GroupableListModel.
 void setPreferredColumnCount(int preferredColumnCount)
          Sets the preferred number of columns in the list that can be displayed without a scrollbar, as determined by the nearest JViewport ancestor, if any.
 void updateUI()
           
 
Methods inherited from class javax.swing.JList
addListSelectionListener, addSelectionInterval, clearSelection, createSelectionModel, ensureIndexIsVisible, fireSelectionValueChanged, getAccessibleContext, getAnchorSelectionIndex, getCellBounds, getCellRenderer, getDragEnabled, getDropLocation, getDropMode, getFirstVisibleIndex, getFixedCellHeight, getFixedCellWidth, getLastVisibleIndex, getLeadSelectionIndex, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getNextMatch, getPreferredScrollableViewportSize, getPrototypeCellValue, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedIndex, getSelectedIndices, getSelectedValue, getSelectedValues, getSelectionBackground, getSelectionForeground, getSelectionMode, getSelectionModel, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setCellRenderer, setDragEnabled, setDropMode, setFixedCellHeight, setFixedCellWidth, setListData, setListData, setPrototypeCellValue, setSelectedIndex, setSelectedIndices, setSelectedValue, setSelectionBackground, setSelectionForeground, setSelectionInterval, setSelectionMode, setSelectionModel, setUI, setValueIsAdjusting, setVisibleRowCount
 
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, 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
 

Field Detail

HORIZONTAL

public static final int HORIZONTAL
Indicates the default layout: one row for each group.

See Also:
setLayoutOrientation(int), Constant Field Values

_groupCellSelectable

protected boolean _groupCellSelectable
Holds value of property headersSelectable.

Constructor Detail

GroupList

public GroupList()
Constructs a GroupList with an empty model.


GroupList

public GroupList(ListModel dataModel)
Constructs a GroupList that displays the elements in the specified, non-null ListModel. All GroupList constructors delegate to this one.

Parameters:
dataModel - the data model for this list
Throws:
IllegalArgumentException - if dataModel is null

GroupList

public GroupList(Object[] listData)
Constructs a GroupList that displays the elements in the specified array. This constructor just delegates to the ListModel constructor.

Parameters:
listData - the array of Objects to be loaded into the data model

GroupList

public GroupList(List<?> listData)
Constructs a GroupList that displays the elements in the specified List. This constructor just delegates to the ListModel constructor.

Parameters:
listData - the List to be loaded into the data model

GroupList

public GroupList(GroupListModel dataModel)
Constructs a GroupList that displays the elements in the specified, non-null GroupListModel. All GroupList constructors delegate to this one.

Parameters:
dataModel - the data model for this list
Throws:
IllegalArgumentException - if dataModel is null

GroupList

public GroupList(GroupableListModel dataModel)
Constructs a GroupList that displays the elements in the specified, non-null GroupableListModel. All GroupList constructors delegate to this one.

Parameters:
dataModel - the data model for this list
Throws:
IllegalArgumentException - if dataModel is null

GroupList

public GroupList(Map<Object,?> map)
Creates a GroupList.

Parameters:
map - a map from the group object to the elements belong to this group. The elements can be any Collection type or an array.
Method Detail

getActualUIClassID

public String getActualUIClassID()

updateUI

public void updateUI()
Overrides:
updateUI in class JList

createModel

protected static GroupableListModel createModel(Map<Object,?> map)
Returns a GroupableListModel wrapping the specified object. If the object is:then a new root node is created with each of the incoming objects as children. Otherwise, a new root is created with the specified object as its value.

Parameters:
map - the Object used as the foundation for the GroupableListModel
Returns:
a GroupableListModel wrapping the specified object

setModel

public void setModel(ListModel model)
Overrides to wrap the model into GroupableListModel if the model itself is not GroupableListModel.

Overrides:
setModel in class JList
Parameters:
model - the ListModel that provides the list of items for display
Throws:
IllegalArgumentException - if model is null
See Also:
getModel()

getModel

public GroupListModel getModel()
Returns the data model that holds the list of items displayed by the GroupList component.

Overrides:
getModel in class JList
Returns:
the GroupListModel that provides the displayed list of items
See Also:
setModel(javax.swing.ListModel)

isGroupCellSelectable

public boolean isGroupCellSelectable()
Returns true if the group rows are selectable, false otherwise.

Returns:
Value of property headersSelectable.

setGroupCellSelectable

public void setGroupCellSelectable(boolean groupCellSelectable)
Set a new value which represents whether group rows are selectable for this GroupList.

Parameters:
groupCellSelectable - New value of property headersSelectable.

getPreferredColumnCount

public int getPreferredColumnCount()
Returns the preferred number of columns.

Returns:
an integer indicating the preferred number of columns to display without using a scroll bar
See Also:
setPreferredColumnCount(int)

setPreferredColumnCount

public void setPreferredColumnCount(int preferredColumnCount)
Sets the preferred number of columns in the list that can be displayed without a scrollbar, as determined by the nearest JViewport ancestor, if any. The value of this property only affects the value of the JList's preferredScrollableViewportSize.

The default value of this property is 8.

Parameters:
preferredColumnCount - an integer specifying the preferred number of visible columns

getRowCount

public int getRowCount()
Returns the number of rows. In vertical mode, it will be the same as the model size. But in other modes, it could be different.

Returns:
an integer indicating the number of rows to be displayed.

getColumnCount

public int getColumnCount(int rowIndex)
Returns the amount of cells in the specified row. It should return 1 for vertical mode but for other modes, it could return another value.

Parameters:
rowIndex - int
Returns:
the amount of elements in the specified row

getGroupCellRenderer

public ListCellRenderer getGroupCellRenderer()
Returns the object that renders the list headers.

Returns:
the ListCellRenderer which renders the list headers.
See Also:
setGroupCellRenderer(ListCellRenderer), JList.getCellRenderer()

setGroupCellRenderer

public void setGroupCellRenderer(ListCellRenderer cellRenderer)
Sets the cell renderer for the group cells

Parameters:
cellRenderer - the ListCellRenderer that paints group cells
See Also:
getGroupCellRenderer(), JList.setCellRenderer(ListCellRenderer)

setLayoutOrientation

public void setLayoutOrientation(int layoutOrientation)
Override the method in JList to support a new orientation called HORIZONTAL. HORIZONTAL is almost the same as JList.HORIZONTAL_WRAP except it will not wrap. It probably doesn't make too much sense in the normal JList. But in GroupList, it makes sense as it means all items under the same group will not wrap horizontally.

Overrides:
setLayoutOrientation in class JList
Parameters:
layoutOrientation - new layoutOrientation.

getLayoutOrientation

public int getLayoutOrientation()
Returns the layout orientation property for the list: JList.VERTICAL if the layout is a single column of cells, JList.VERTICAL_WRAP if the layout is "newspaper style" with the content flowing vertically then horizontally, or JList.HORIZONTAL_WRAP if the layout is "newspaper style" with the content flowing horizontally then vertically. GroupList also added one more layout orientation called HORIZONTAL. It basically arrange all cell under the same group into one row.

Overrides:
getLayoutOrientation in class JList
Returns:
the value of the layoutOrientation property
See Also:
setLayoutOrientation(int)

getGroupCellIndices

public int[] getGroupCellIndices()
Gets the group rows indices.

Returns:
the group rows indices.

getToolTipText

public String getToolTipText(MouseEvent event)
Overrides the method in JList to provide tooltips for group rows through the group cell renderer.

Overrides:
getToolTipText in class JList

JIDE 3.5.15