org.jdesktop.swingx
Class JXList

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 org.jdesktop.swingx.JXList
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable

public class JXList
extends javax.swing.JList

JXList Enabled Rollover/LinkModel handling. Enabled Highlighter support. Added experimental support for filtering/sorting. This feature is disabled by default because it has side-effects which might break "normal" expectations when using a JList: if enabled all row coordinates (including those returned by the selection) are in view coordinates. Furthermore, the model returned from getModel() is a wrapper around the actual data.

Author:
Ramesh Gupta, Jeanette Winzenburg
See Also:
Serialized Form

Nested Class Summary
static class JXList.LinkController
          listens to rollover properties.
protected static class JXList.ListAdapter
           
 class JXList.ListSearchable
           
 
Nested classes/interfaces inherited from class javax.swing.JList
javax.swing.JList.AccessibleJList
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  ComponentAdapter dataAdapter
          The ComponentAdapter for model data access.
static java.lang.String EXECUTE_BUTTON_ACTIONCOMMAND
           
protected  FilterPipeline filters
          The pipeline holding the filters.
protected  HighlighterPipeline highlighters
          The pipeline holding the highlighters.
 
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
JXList()
           
JXList(javax.swing.ListModel dataModel)
           
JXList(java.lang.Object[] listData)
           
JXList(java.util.Vector listData)
           
 
Method Summary
 int convertIndexToModel(int viewIndex)
          Convert row index from view coordinates to model coordinates accounting for the presence of sorters and filters.
 int convertIndexToView(int modelIndex)
          Convert index from model coordinates to view coordinates accounting for the presence of sorters and filters.
protected  JXList.LinkController createLinkController()
           
protected  PipelineListener createPipelineListener()
          creates the listener for changes in filters.
protected  RolloverProducer createRolloverProducer()
          creates and returns the RolloverProducer to use with this tree.
protected  void doFind()
           
 javax.swing.ListCellRenderer getCellRenderer()
           
protected  ComponentAdapter getComponentAdapter()
           
 java.lang.Object getElementAt(int viewIndex)
          returns the element at the given index.
 int getElementCount()
          Returns the number of elements in this list in view coordinates.
protected  PipelineListener getFilterPipelineListener()
          returns the listener for changes in filters.
 FilterPipeline getFilters()
           
 HighlighterPipeline getHighlighters()
           
protected  JXList.LinkController getLinkController()
           
 Searchable getSearchable()
           
 javax.swing.ListModel getWrappedModel()
          returns the underlying model.
 boolean isFilterEnabled()
           
 boolean isRolloverEnabled()
          returns the rolloverEnabled property.
 void setCellRenderer(javax.swing.ListCellRenderer renderer)
           
 void setFilterEnabled(boolean enabled)
          Enables/disables filtering support.
 void setFilters(FilterPipeline pipeline)
          Sets the FilterPipeline for filtering table rows.
 void setHighlighters(HighlighterPipeline pipeline)
          Assigns a HighlighterPipeline to the table.
 void setLinkVisitor(java.awt.event.ActionListener linkVisitor)
           
 void setModel(javax.swing.ListModel model)
          set's the underlying data model.
 void setRolloverEnabled(boolean rolloverEnabled)
          Property to enable/disable rollover support.
 void setSearchable(Searchable searchable)
          sets the Searchable for this editor.
protected  void updateOnFilterContentChanged()
          method called on change notification from filterpipeline.
 void updateUI()
           
 
Methods inherited from class javax.swing.JList
addListSelectionListener, addSelectionInterval, clearSelection, createSelectionModel, ensureIndexIsVisible, fireSelectionValueChanged, getAccessibleContext, getAnchorSelectionIndex, getCellBounds, getDragEnabled, getFirstVisibleIndex, getFixedCellHeight, getFixedCellWidth, getLastVisibleIndex, getLayoutOrientation, getLeadSelectionIndex, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getModel, getNextMatch, getPreferredScrollableViewportSize, getPrototypeCellValue, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedIndex, getSelectedIndices, getSelectedValue, getSelectedValues, getSelectionBackground, getSelectionForeground, getSelectionMode, getSelectionModel, getToolTipText, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setDragEnabled, setFixedCellHeight, setFixedCellWidth, setLayoutOrientation, 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, 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, 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

EXECUTE_BUTTON_ACTIONCOMMAND

public static final java.lang.String EXECUTE_BUTTON_ACTIONCOMMAND
See Also:
Constant Field Values

filters

protected FilterPipeline filters
The pipeline holding the filters.


highlighters

protected HighlighterPipeline highlighters
The pipeline holding the highlighters.


dataAdapter

protected ComponentAdapter dataAdapter
The ComponentAdapter for model data access.

Constructor Detail

JXList

public JXList()

JXList

public JXList(javax.swing.ListModel dataModel)

JXList

public JXList(java.lang.Object[] listData)

JXList

public JXList(java.util.Vector listData)
Method Detail

doFind

protected void doFind()

getSearchable

public Searchable getSearchable()

setSearchable

public void setSearchable(Searchable searchable)
sets the Searchable for this editor. If null, a default searchable will be used.

Parameters:
searchable -

setRolloverEnabled

public void setRolloverEnabled(boolean rolloverEnabled)
Property to enable/disable rollover support. This can be enabled to show "live" rollover behaviour, f.i. the cursor over LinkModel cells. Default is disabled.

Parameters:
rolloverEnabled -

getLinkController

protected JXList.LinkController getLinkController()

createLinkController

protected JXList.LinkController createLinkController()

createRolloverProducer

protected RolloverProducer createRolloverProducer()
creates and returns the RolloverProducer to use with this tree.

Returns:

isRolloverEnabled

public boolean isRolloverEnabled()
returns the rolloverEnabled property.

Returns:

setLinkVisitor

public void setLinkVisitor(java.awt.event.ActionListener linkVisitor)

getElementAt

public java.lang.Object getElementAt(int viewIndex)
returns the element at the given index. The index is in view coordinates which might differ from model coordinates if filtering is enabled and filters/sorters are active.

Parameters:
viewIndex - the index in view coordinates
Returns:
the element at the index
Throws:
java.lang.IndexOutOfBoundsException - if viewIndex < 0 or viewIndex >= getElementCount()

getElementCount

public int getElementCount()
Returns the number of elements in this list in view coordinates. If filters are active this number might be less than the number of elements in the underlying model.

Returns:

convertIndexToModel

public int convertIndexToModel(int viewIndex)
Convert row index from view coordinates to model coordinates accounting for the presence of sorters and filters.

Parameters:
viewIndex - index in view coordinates
Returns:
index in model coordinates
Throws:
java.lang.IndexOutOfBoundsException - if viewIndex < 0 or viewIndex >= getElementCount()

convertIndexToView

public int convertIndexToView(int modelIndex)
Convert index from model coordinates to view coordinates accounting for the presence of sorters and filters. PENDING Filter guards against out of range - should not?

Parameters:
modelIndex - index in model coordinates
Returns:
index in view coordinates if the model index maps to a view coordinate or -1 if not contained in the view.

getWrappedModel

public javax.swing.ListModel getWrappedModel()
returns the underlying model. If !isFilterEnabled this will be the same as getModel().

Returns:

setFilterEnabled

public void setFilterEnabled(boolean enabled)
Enables/disables filtering support. If enabled all row indices - including the selection - are in view coordinates and getModel returns a wrapper around the underlying model. Note: as an implementation side-effect calling this method clears the selection (done in super.setModel). PENDING: cleanup state transitions!! - currently this can be safely applied once only to enable. Internal state is inconsistent if trying to disable again. see Issue #2-swinglabs.

Parameters:
enabled -

isFilterEnabled

public boolean isFilterEnabled()

setModel

public void setModel(javax.swing.ListModel model)
set's the underlying data model. Note that if isFilterEnabled you must call getWrappedModel to access the model given here. In this case getModel returns a wrapper around the data!

Overrides:
setModel in class javax.swing.JList

getFilters

public FilterPipeline getFilters()

setFilters

public void setFilters(FilterPipeline pipeline)
Sets the FilterPipeline for filtering table rows. PRE: isFilterEnabled()

Parameters:
pipeline - the filterPipeline to use.
Throws:
java.lang.IllegalStateException - if !isFilterEnabled()

getFilterPipelineListener

protected PipelineListener getFilterPipelineListener()
returns the listener for changes in filters.


createPipelineListener

protected PipelineListener createPipelineListener()
creates the listener for changes in filters.


updateOnFilterContentChanged

protected void updateOnFilterContentChanged()
method called on change notification from filterpipeline.


getComponentAdapter

protected ComponentAdapter getComponentAdapter()

getHighlighters

public HighlighterPipeline getHighlighters()

setHighlighters

public void setHighlighters(HighlighterPipeline pipeline)
Assigns a HighlighterPipeline to the table.


getCellRenderer

public javax.swing.ListCellRenderer getCellRenderer()
Overrides:
getCellRenderer in class javax.swing.JList

setCellRenderer

public void setCellRenderer(javax.swing.ListCellRenderer renderer)
Overrides:
setCellRenderer in class javax.swing.JList

updateUI

public void updateUI()
Overrides:
updateUI in class javax.swing.JList


Copyright © 2005 Sun Microsystems All Rights Reserved.