org.jdesktop.swingx
Class JXTreeTable

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.jdesktop.swingx.JXTable
                      extended by org.jdesktop.swingx.JXTreeTable
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CellEditorListener, javax.swing.event.ListSelectionListener, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener, javax.swing.Scrollable

public class JXTreeTable
extends JXTable

JXTreeTable is a specialized table consisting of a single column in which to display hierarchical data, and any number of other columns in which to display regular data. The interface for the data model used by a JXTreeTable is TreeTableModel. It extends the TreeModel interface to allow access to cell data by column indices within each node of the tree hierarchy.

The most straightforward way create and use a JXTreeTable, is to first create a suitable data model for it, and pass that to a JXTreeTable constructor, as shown below:

  TreeTableModel  treeTableModel = new FileSystemModel(); // any TreeTableModel
  JXTreeTable      treeTable = new JXTreeTable(treeTableModel);
  JScrollPane     scrollpane = new JScrollPane(treeTable);
 
See JTable for an explanation of why putting the treetable inside a scroll pane is necessary.

A single treetable model instance may be shared among more than one JXTreeTable instances. To access the treetable model, always call getTreeTableModel and setTreeTableModel. JXTreeTable wraps the supplied treetable model inside a private adapter class to adapt it to a TableModel. Although the model adapter is accessible through the getModel method, you should avoid accessing and manipulating it in any way. In particular, each model adapter instance is tightly bound to a single table instance, and any attempt to share it with another table (for example, by calling setModel) will throw an IllegalArgumentException!

See Also:
Serialized Form

Nested Class Summary
protected static class JXTreeTable.TreeTableDataAdapter
           
 class JXTreeTable.TreeTableHacker
          Temporary class to have all the hacking at one place.
 class JXTreeTable.TreeTableHackerExt
          Note: currently this class looks a bit funny (only overriding the hit decision method).
protected static class JXTreeTable.TreeTableModelAdapter
           
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.JXTable
JXTable.BooleanEditor, JXTable.BooleanRenderer, JXTable.DateRenderer, JXTable.DoubleRenderer, JXTable.GenericEditor, JXTable.IconRenderer, JXTable.NumberEditor, JXTable.NumberRenderer, JXTable.TableAdapter, JXTable.TableRolloverController<T extends javax.swing.JTable>, JXTable.TableSearchable
 
Nested classes/interfaces inherited from class javax.swing.JTable
javax.swing.JTable.AccessibleJTable, javax.swing.JTable.PrintMode
 
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
static java.lang.String DRAG_HACK_FLAG_KEY
          Key for clientProperty to decide whether to apply hack around #168-jdnc.
 
Fields inherited from class org.jdesktop.swingx.JXTable
AUTO_RESIZE_INTELLI_OFF, dataAdapter, filters, highlighters, HORIZONTALSCROLL_ACTION_COMMAND, isXTableRowHeightSet, MATCH_HIGHLIGHTER, PACKALL_ACTION_COMMAND, PACKSELECTED_ACTION_COMMAND, resetDefaultTableCellRendererHighlighter, searchable, UIPREFIX
 
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
JXTreeTable()
          Constructs a JXTreeTable using a DefaultTreeTableModel.
JXTreeTable(TreeTableModel treeModel)
          Constructs a JXTreeTable using the specified TreeTableModel.
 
Method Summary
 void addTreeExpansionListener(javax.swing.event.TreeExpansionListener tel)
          Adds a listener for TreeExpansion events.
 void addTreeSelectionListener(javax.swing.event.TreeSelectionListener tsl)
          Adds a listener for TreeSelection events.
 void addTreeWillExpandListener(javax.swing.event.TreeWillExpandListener tel)
          Adds a listener for TreeWillExpand events.
protected  void adjustTableRowHeight(int treeRowHeight)
          Forwards treeRowHeight to table.
protected  void adjustTreeRowHeight(int tableRowHeight)
          Forwards tableRowHeight to tree.
protected  java.awt.Component applyRenderer(java.awt.Component component, ComponentAdapter adapter)
          Performs necessary housekeeping before the renderer is actually applied.
 void clearSelection()
          Overridden to ensure that private renderer state is kept in sync with the state of the component.
 void collapseAll()
          Collapses all nodes in the treetable.
 void collapsePath(javax.swing.tree.TreePath path)
          Collapses the node at the specified path in the treetable.
 void collapseRow(int row)
          Collapses the row in the treetable.
protected  JXTreeTable.TreeTableHacker createTreeTableHacker()
           
 boolean editCellAt(int row, int column, java.util.EventObject e)
          Overriden to invoke repaint for the particular location if the column contains the tree.
 void expandAll()
          Expands all nodes in the treetable.
 void expandPath(javax.swing.tree.TreePath path)
          Expands the the node at the specified path in the treetable.
 void expandRow(int row)
          Expands the specified row in the treetable.
protected  ComponentAdapter getComponentAdapter()
          Returns the adapter that knows how to access the component data model.
 int getEditingRow()
          Overridden to provide a workaround for BasicTableUI anomaly.
 java.util.Enumeration getExpandedDescendants(javax.swing.tree.TreePath parent)
          Returns an Enumeration of the descendants of the path parent that are currently expanded.
 boolean getExpandsSelectedPaths()
          Returns the value of the expandsSelectedPaths property.
 javax.swing.tree.TreePath getPathForLocation(int x, int y)
          Returns the TreePath for a given x,y location.
 javax.swing.tree.TreePath getPathForRow(int row)
          Returns the TreePath for a given row.
 int getRowForPath(javax.swing.tree.TreePath path)
          Returns the row for a given TreePath.
 boolean getScrollsOnExpand()
          Returns the value of the scrollsOnExpand property.
protected  SelectionMapper getSelectionMapper()
          Overridden to return a do-nothing mapper.
 boolean getShowsRootHandles()
          Returns the value of the showsRootHandles property.
 int getToggleClickCount()
          Returns the number of mouse clicks needed to expand or close a node.
 java.lang.String getToolTipText(java.awt.event.MouseEvent event)
           
 javax.swing.tree.TreeCellRenderer getTreeCellRenderer()
           
 javax.swing.tree.TreeSelectionModel getTreeSelectionModel()
          Returns the selection model for the tree portion of the this treetable.
protected  JXTreeTable.TreeTableHacker getTreeTableHacker()
           
 TreeTableModel getTreeTableModel()
          Returns the underlying TreeTableModel for this JXTreeTable.
protected  boolean hackAroundDragEnabled(java.awt.event.MouseEvent me)
          decides whether we want to apply the hack for #168-jdnc.
 boolean isCollapsed(int row)
          Returns true if the node at the specified display row is collapsed.
 boolean isCollapsed(javax.swing.tree.TreePath path)
          Returns true if the node identified by path is currently collapsed, this will return false if any of the values in path are currently not being displayed.
 boolean isExpanded(int row)
          Returns true if the node at the specified display row is currently expanded.
 boolean isExpanded(javax.swing.tree.TreePath path)
          Returns true if the node identified by path is currently expanded.
 boolean isHierarchical(int column)
          Determines if the specified column contains hierarchical nodes.
 boolean isLargeModel()
          Returns true if the tree is configured for a large model.
 boolean isRootVisible()
          Returns true if the root node of the tree is displayed.
 boolean isVisible(javax.swing.tree.TreePath path)
          Returns true if the value identified by path is currently viewable, which means it is either the root or all of its parents are expanded.
 java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer, int row, int column)
          Overrides superclass version to provide support for cell decorators.
protected  void processMouseEvent(java.awt.event.MouseEvent e)
          Overridden to enable hit handle detection a mouseEvent which triggered a expand/collapse.
 void removeTreeExpansionListener(javax.swing.event.TreeExpansionListener tel)
          Removes a listener for TreeExpansion events.
 void removeTreeSelectionListener(javax.swing.event.TreeSelectionListener tsl)
          Removes a listener for TreeSelection events.
 void removeTreeWillExpandListener(javax.swing.event.TreeWillExpandListener tel)
          Removes a listener for TreeWillExpand events.
 void scrollPathToVisible(javax.swing.tree.TreePath path)
          Makes sure all the path components in path are expanded (except for the last path component) and scrolls so that the node identified by the path is displayed.
 void setClosedIcon(javax.swing.Icon icon)
          Sets the specified icon as the icon to use for rendering closed container nodes.
 void setCollapsedIcon(javax.swing.Icon icon)
          Sets the specified icon as the icon to use for rendering collapsed nodes.
 void setExpandedIcon(javax.swing.Icon icon)
          Sets the specified icon as the icon to use for rendering expanded nodes.
 void setExpandsSelectedPaths(boolean expand)
          Sets the value of the expandsSelectedPaths property for the tree part.
 void setFilters(FilterPipeline pipeline)
          overridden to do nothing.
 void setLargeModel(boolean newValue)
          Specifies whether the UI should use a large model.
 void setLeafIcon(javax.swing.Icon icon)
          Sets the specified icon as the icon to use for rendering leaf nodes.
 void setModel(javax.swing.table.TableModel tableModel)
          Overrides superclass version to make sure that the specified TableModel is compatible with JXTreeTable before invoking the inherited version.
 void setOpenIcon(javax.swing.Icon icon)
          Sets the specified icon as the icon to use for rendering open container nodes.
 void setRootVisible(boolean visible)
          Determines whether or not the root node from the TreeModel is visible.
 void setRowHeight(int rowHeight)
          Sets the row height for this JXTreeTable and forwards the row height to the renderering tree.
 void setRowHeight(int row, int rowHeight)
          Throws UnsupportedOperationException because variable height rows are not supported.
 void setScrollsOnExpand(boolean scroll)
          Sets the value of the scrollsOnExpand property for the tree part.
 void setSelectionMode(int mode)
          Overridden to ensure that private renderer state is kept in sync with the state of the component.
 void setShowsRootHandles(boolean visible)
          Sets the value of the showsRootHandles property for the tree part.
 void setSortable(boolean sortable)
          overridden to do nothing.
 void setToggleClickCount(int clickCount)
          Sets the number of mouse clicks before a node will expand or close.
 void setTreeCellRenderer(javax.swing.tree.TreeCellRenderer cellRenderer)
          Sets the specified TreeCellRenderer as the Tree cell renderer.
 void setTreeTableModel(TreeTableModel treeModel)
          Sets the data model for this JXTreeTable to the specified TreeTableModel.
 void sizeColumnsToFit(int resizingColumn)
          Overriden to invoke supers implementation, and then, if the receiver is editing a Tree column, the editors bounds is reset.
 void tableChanged(javax.swing.event.TableModelEvent e)
          additionally updates filtered state.
 void updateUI()
          Overridden to message super and forward the method to the tree.
 
Methods inherited from class org.jdesktop.swingx.JXTable
addHighlighter, adjustComponentOrientation, adminSetRowHeight, columnMarginChanged, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, configureViewportBackground, convertRowIndexToModel, convertRowIndexToView, createAndConfigureColumn, createDefaultColumnControl, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultEditors, createDefaultRenderers, createDefaultTableHeader, createLinkController, createPipelineListener, createRolloverProducer, doLayout, getColumn, getColumnControl, getColumnCount, getColumnExt, getColumnExt, getColumnFactory, getColumnMargin, getColumns, getColumns, getComponentAdapter, getFillsViewportHeight, getFilterPipelineListener, getFilters, getHighlighterChangeListener, getHighlighters, getLinkController, getNewDefaultRenderer, getPreferredScrollableViewportSize, getRowCount, getRowModelMapper, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getSearchable, getSelectionMode, getSortController, getSortedColumn, getSortOrder, getSortOrder, getValueAt, getVisibleRowCount, init, initializeColumnPreferredWidth, isAutoStartEditOnKeyStroke, isCellEditable, isColumnControlVisible, isDataChanged, isEditable, isHorizontalScrollEnabled, isRolloverEnabled, isRowHeightEnabled, isSortable, isSortable, isSortable, isStructureChanged, isTerminateEditOnFocusLost, isUpdate, packAll, packColumn, packColumn, packSelected, packTable, prepareEditor, removeColumns, removeHighlighter, resetDefaultTableCellRendererColors, resetSortOrder, rowAtPoint, scrollCellToVisible, scrollColumnToVisible, scrollRowToVisible, setAutoResizeMode, setAutoStartEditOnKeyStroke, setColumnControl, setColumnControlVisible, setColumnFactory, setColumnMargin, setColumnSequence, setComponentOrientation, setDefaultMargins, setEditable, setFillsViewportHeight, setHighlighters, setHorizontalScrollEnabled, setRolloverEnabled, setRowHeightEnabled, setSearchable, setSelectionModel, setSortOrder, setSortOrder, setTerminateEditOnFocusLost, setValueAt, setVisibleRowCount, toggleSortOrder, toggleSortOrder, updateHighlighters, updateHorizontalAction, updateOnFilterContentChanged, updateViewSizeSequence
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, columnAdded, columnAtPoint, columnMoved, convertColumnIndexToModel, convertColumnIndexToView, createDefaultDataModel, createDefaultSelectionModel, createScrollPaneForTable, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPrintable, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getUI, getUIClassID, initializeLocalVars, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, selectAll, setAutoCreateColumnsFromModel, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, sizeColumnsToFit, unconfigureEnclosingScrollPane, 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, 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, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, 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, 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

DRAG_HACK_FLAG_KEY

public static final java.lang.String DRAG_HACK_FLAG_KEY
Key for clientProperty to decide whether to apply hack around #168-jdnc.

See Also:
Constant Field Values
Constructor Detail

JXTreeTable

public JXTreeTable()
Constructs a JXTreeTable using a DefaultTreeTableModel.


JXTreeTable

public JXTreeTable(TreeTableModel treeModel)
Constructs a JXTreeTable using the specified TreeTableModel.

Parameters:
treeModel - model for the JXTreeTable
Method Detail

setSortable

public void setSortable(boolean sortable)
overridden to do nothing. TreeTable is not sortable by default, because Sorters/Filters currently don't work properly.

Overrides:
setSortable in class JXTable
Parameters:
sortable - boolean indicating whether or not this table supports sortable columns
See Also:
TableColumnExt.isSortable()

setFilters

public void setFilters(FilterPipeline pipeline)
overridden to do nothing. TreeTable is not sortable by default, because Sorters/Filters currently don't work properly.

Overrides:
setFilters in class JXTable
Parameters:
pipeline - the FilterPipeline to use, null removes all filters.

editCellAt

public boolean editCellAt(int row,
                          int column,
                          java.util.EventObject e)
Overriden to invoke repaint for the particular location if the column contains the tree. This is done as the tree editor does not fill the bounds of the cell, we need the renderer to paint the tree in the background, and then draw the editor over it. You should not need to call this method directly.

Additionally, there is tricksery involved to expand/collapse the nodes.

Overrides:
editCellAt in class javax.swing.JTable

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e)
Overridden to enable hit handle detection a mouseEvent which triggered a expand/collapse.

Overrides:
processMouseEvent in class javax.swing.JComponent

getTreeTableHacker

protected JXTreeTable.TreeTableHacker getTreeTableHacker()

createTreeTableHacker

protected JXTreeTable.TreeTableHacker createTreeTableHacker()

hackAroundDragEnabled

protected boolean hackAroundDragEnabled(java.awt.event.MouseEvent me)
decides whether we want to apply the hack for #168-jdnc. here: returns true if dragEnabled() and the improved drag handling is not activated (or the system property is not accessible). The given mouseEvent is not analysed. PENDING: Mustang?

Parameters:
me - the mouseEvent that triggered a editCellAt
Returns:
true if the hack should be applied.

getEditingRow

public int getEditingRow()
Overridden to provide a workaround for BasicTableUI anomaly. Make sure the UI never tries to resize the editor. The UI currently uses different techniques to paint the renderers and editors. So, overriding setBounds() is not the right thing to do for an editor. Returning -1 for the editing row in this case, ensures the editor is never painted.

Overrides:
getEditingRow in class javax.swing.JTable

setTreeTableModel

public void setTreeTableModel(TreeTableModel treeModel)
Sets the data model for this JXTreeTable to the specified TreeTableModel. The same data model may be shared by any number of JXTreeTable instances.

Parameters:
treeModel - data model for this JXTreeTable

getTreeTableModel

public TreeTableModel getTreeTableModel()
Returns the underlying TreeTableModel for this JXTreeTable.

Returns:
the underlying TreeTableModel for this JXTreeTable

setModel

public final void setModel(javax.swing.table.TableModel tableModel)

Overrides superclass version to make sure that the specified TableModel is compatible with JXTreeTable before invoking the inherited version.

Because JXTreeTable internally adapts an TreeTableModel to make it a compatible TableModel, this method should never be called directly. Use setTreeTableModel instead.

While it is possible to obtain a reference to this adapted version of the TableModel by calling JTable.getModel(), any attempt to call setModel() with that adapter will fail because the adapter might have been bound to a different JXTreeTable instance. If you want to extract the underlying TreeTableModel, which, by the way, can be shared, use getTreeTableModel instead

.

Overrides:
setModel in class JXTable
Parameters:
tableModel - must be a TreeTableModelAdapter
Throws:
java.lang.IllegalArgumentException - if the specified tableModel is not an instance of TreeTableModelAdapter

tableChanged

public void tableChanged(javax.swing.event.TableModelEvent e)
Description copied from class: JXTable
additionally updates filtered state.

Specified by:
tableChanged in interface javax.swing.event.TableModelListener
Overrides:
tableChanged in class JXTable

getSelectionMapper

protected SelectionMapper getSelectionMapper()
Overridden to return a do-nothing mapper.

Overrides:
getSelectionMapper in class JXTable
Returns:
SelectionMapper

setRowHeight

public final void setRowHeight(int row,
                               int rowHeight)
Throws UnsupportedOperationException because variable height rows are not supported.

Overrides:
setRowHeight in class JXTable
Parameters:
row - ignored
rowHeight - ignored
Throws:
java.lang.UnsupportedOperationException - because variable height rows are not supported
See Also:
JXTable.isRowHeightEnabled()

setRowHeight

public void setRowHeight(int rowHeight)
Sets the row height for this JXTreeTable and forwards the row height to the renderering tree.

Overrides:
setRowHeight in class JXTable
Parameters:
rowHeight - height of a row.

adjustTreeRowHeight

protected void adjustTreeRowHeight(int tableRowHeight)
Forwards tableRowHeight to tree.

Parameters:
tableRowHeight - height of a row.

adjustTableRowHeight

protected void adjustTableRowHeight(int treeRowHeight)
Forwards treeRowHeight to table. This is for completeness only: the rendering tree is under our total control, so we don't expect any external call to tree.setRowHeight.

Parameters:
treeRowHeight - height of a row.

setSelectionMode

public void setSelectionMode(int mode)

Overridden to ensure that private renderer state is kept in sync with the state of the component. Calls the inherited version after performing the necessary synchronization. If you override this method, make sure you call this version from your version of this method.

This version maps the selection mode used by the renderer to match the selection mode specified for the table. Specifically, the modes are mapped as follows:

  ListSelectionModel.SINGLE_INTERVAL_SELECTION: TreeSelectionModel.CONTIGUOUS_TREE_SELECTION;
  ListSelectionModel.MULTIPLE_INTERVAL_SELECTION: TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION;
  any other (default): TreeSelectionModel.SINGLE_TREE_SELECTION;
 

Overrides:
setSelectionMode in class javax.swing.JTable
Parameters:
mode - any of the table selection modes

prepareRenderer

public java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer,
                                          int row,
                                          int column)
Overrides superclass version to provide support for cell decorators.

Overrides:
prepareRenderer in class JXTable
Parameters:
renderer - the TableCellRenderer to prepare
row - the row of the cell to render, where 0 is the first row
column - the column of the cell to render, where 0 is the first column
Returns:
the Component used as a stamp to render the specified cell
See Also:
Highlighter

applyRenderer

protected java.awt.Component applyRenderer(java.awt.Component component,
                                           ComponentAdapter adapter)
Performs necessary housekeeping before the renderer is actually applied.

Parameters:
component -
adapter - component data adapter
Throws:
java.lang.NullPointerException - if the specified component or adapter is null

setTreeCellRenderer

public void setTreeCellRenderer(javax.swing.tree.TreeCellRenderer cellRenderer)
Sets the specified TreeCellRenderer as the Tree cell renderer.

Parameters:
cellRenderer - to use for rendering tree cells.

getTreeCellRenderer

public javax.swing.tree.TreeCellRenderer getTreeCellRenderer()

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
Overrides:
getToolTipText in class javax.swing.JTable

setCollapsedIcon

public void setCollapsedIcon(javax.swing.Icon icon)
Sets the specified icon as the icon to use for rendering collapsed nodes.

Parameters:
icon - to use for rendering collapsed nodes

setExpandedIcon

public void setExpandedIcon(javax.swing.Icon icon)
Sets the specified icon as the icon to use for rendering expanded nodes.

Parameters:
icon - to use for rendering expanded nodes

setOpenIcon

public void setOpenIcon(javax.swing.Icon icon)
Sets the specified icon as the icon to use for rendering open container nodes.

Parameters:
icon - to use for rendering open nodes

setClosedIcon

public void setClosedIcon(javax.swing.Icon icon)
Sets the specified icon as the icon to use for rendering closed container nodes.

Parameters:
icon - to use for rendering closed nodes

setLeafIcon

public void setLeafIcon(javax.swing.Icon icon)
Sets the specified icon as the icon to use for rendering leaf nodes.

Parameters:
icon - to use for rendering leaf nodes

clearSelection

public void clearSelection()
Overridden to ensure that private renderer state is kept in sync with the state of the component. Calls the inherited version after performing the necessary synchronization. If you override this method, make sure you call this version from your version of this method.

Overrides:
clearSelection in class javax.swing.JTable

collapseAll

public void collapseAll()
Collapses all nodes in the treetable.


expandAll

public void expandAll()
Expands all nodes in the treetable.


collapsePath

public void collapsePath(javax.swing.tree.TreePath path)
Collapses the node at the specified path in the treetable.

Parameters:
path - path of the node to collapse

expandPath

public void expandPath(javax.swing.tree.TreePath path)
Expands the the node at the specified path in the treetable.

Parameters:
path - path of the node to expand

scrollPathToVisible

public void scrollPathToVisible(javax.swing.tree.TreePath path)
Makes sure all the path components in path are expanded (except for the last path component) and scrolls so that the node identified by the path is displayed. Only works when this JTree is contained in a JScrollPane. (doc copied from JTree) PENDING: JW - where exactly do we want to scroll? Here: the scroll is in vertical direction only. Might need to show the tree column?

Parameters:
path - the TreePath identifying the node to bring into view

collapseRow

public void collapseRow(int row)
Collapses the row in the treetable. If the specified row index is not valid, this method will have no effect.


expandRow

public void expandRow(int row)
Expands the specified row in the treetable. If the specified row index is not valid, this method will have no effect.


isVisible

public boolean isVisible(javax.swing.tree.TreePath path)
Returns true if the value identified by path is currently viewable, which means it is either the root or all of its parents are expanded. Otherwise, this method returns false.

Returns:
true, if the value identified by path is currently viewable; false, otherwise

isExpanded

public boolean isExpanded(javax.swing.tree.TreePath path)
Returns true if the node identified by path is currently expanded. Otherwise, this method returns false.

Parameters:
path - path
Returns:
true, if the value identified by path is currently expanded; false, otherwise

isExpanded

public boolean isExpanded(int row)
Returns true if the node at the specified display row is currently expanded. Otherwise, this method returns false.

Parameters:
row - row
Returns:
true, if the node at the specified display row is currently expanded. false, otherwise

isCollapsed

public boolean isCollapsed(javax.swing.tree.TreePath path)
Returns true if the node identified by path is currently collapsed, this will return false if any of the values in path are currently not being displayed.

Parameters:
path - path
Returns:
true, if the value identified by path is currently collapsed; false, otherwise

isCollapsed

public boolean isCollapsed(int row)
Returns true if the node at the specified display row is collapsed.

Parameters:
row - row
Returns:
true, if the node at the specified display row is currently collapsed. false, otherwise

getExpandedDescendants

public java.util.Enumeration getExpandedDescendants(javax.swing.tree.TreePath parent)
Returns an Enumeration of the descendants of the path parent that are currently expanded. If parent is not currently expanded, this will return null. If you expand/collapse nodes while iterating over the returned Enumeration this may not return all the expanded paths, or may return paths that are no longer expanded.

Parameters:
parent - the path which is to be examined
Returns:
an Enumeration of the descendents of parent, or null if parent is not currently expanded

getPathForLocation

public javax.swing.tree.TreePath getPathForLocation(int x,
                                                    int y)
Returns the TreePath for a given x,y location.

Parameters:
x - x value
y - y value
Returns:
the TreePath for the givern location.

getPathForRow

public javax.swing.tree.TreePath getPathForRow(int row)
Returns the TreePath for a given row.

Parameters:
row -
Returns:
the TreePath for the given row.

getRowForPath

public int getRowForPath(javax.swing.tree.TreePath path)
Returns the row for a given TreePath.

Parameters:
path -
Returns:
the row for the given TreePath.

setRootVisible

public void setRootVisible(boolean visible)
Determines whether or not the root node from the TreeModel is visible.

Parameters:
visible - true, if the root node is visible; false, otherwise

isRootVisible

public boolean isRootVisible()
Returns true if the root node of the tree is displayed.

Returns:
true if the root node of the tree is displayed

setScrollsOnExpand

public void setScrollsOnExpand(boolean scroll)
Sets the value of the scrollsOnExpand property for the tree part. This property specifies whether the expanded paths should be scrolled into view. In a look and feel in which a tree might not need to scroll when expanded, this property may be ignored.

Parameters:
scroll - true, if expanded paths should be scrolled into view; false, otherwise

getScrollsOnExpand

public boolean getScrollsOnExpand()
Returns the value of the scrollsOnExpand property.

Returns:
the value of the scrollsOnExpand property

setShowsRootHandles

public void setShowsRootHandles(boolean visible)
Sets the value of the showsRootHandles property for the tree part. This property specifies whether the node handles should be displayed. If handles are not supported by a particular look and feel, this property may be ignored.

Parameters:
visible - true, if root handles should be shown; false, otherwise

getShowsRootHandles

public boolean getShowsRootHandles()
Returns the value of the showsRootHandles property.

Returns:
the value of the showsRootHandles property

setExpandsSelectedPaths

public void setExpandsSelectedPaths(boolean expand)
Sets the value of the expandsSelectedPaths property for the tree part. This property specifies whether the selected paths should be expanded.

Parameters:
expand - true, if selected paths should be expanded; false, otherwise

getExpandsSelectedPaths

public boolean getExpandsSelectedPaths()
Returns the value of the expandsSelectedPaths property.

Returns:
the value of the expandsSelectedPaths property

getToggleClickCount

public int getToggleClickCount()
Returns the number of mouse clicks needed to expand or close a node.

Returns:
number of mouse clicks before node is expanded

setToggleClickCount

public void setToggleClickCount(int clickCount)
Sets the number of mouse clicks before a node will expand or close. The default is two.

Parameters:
clickCount - the number of clicks required to expand/collapse a node.

isLargeModel

public boolean isLargeModel()
Returns true if the tree is configured for a large model. The default value is false.

Returns:
true if a large model is suggested
See Also:
setLargeModel(boolean)

setLargeModel

public void setLargeModel(boolean newValue)
Specifies whether the UI should use a large model. (Not all UIs will implement this.)

NOTE: this method is exposed for completeness - currently it's not recommended to use a large model because there are some issues (not yet fully understood), namely issue #25-swingx, and probably #270-swingx.

Parameters:
newValue - true to suggest a large model to the UI

addTreeExpansionListener

public void addTreeExpansionListener(javax.swing.event.TreeExpansionListener tel)
Adds a listener for TreeExpansion events. TODO (JW): redirect event source to this.

Parameters:
tel - a TreeExpansionListener that will be notified when a tree node is expanded or collapsed

removeTreeExpansionListener

public void removeTreeExpansionListener(javax.swing.event.TreeExpansionListener tel)
Removes a listener for TreeExpansion events.

Parameters:
tel - the TreeExpansionListener to remove

addTreeSelectionListener

public void addTreeSelectionListener(javax.swing.event.TreeSelectionListener tsl)
Adds a listener for TreeSelection events. TODO (JW): redirect event source to this.

Parameters:
tsl - a TreeSelectionListener that will be notified when a tree node is selected or deselected

removeTreeSelectionListener

public void removeTreeSelectionListener(javax.swing.event.TreeSelectionListener tsl)
Removes a listener for TreeSelection events.

Parameters:
tsl - the TreeSelectionListener to remove

addTreeWillExpandListener

public void addTreeWillExpandListener(javax.swing.event.TreeWillExpandListener tel)
Adds a listener for TreeWillExpand events. TODO (JW): redirect event source to this.

Parameters:
tel - a TreeWillExpandListener that will be notified when a tree node will be expanded or collapsed

removeTreeWillExpandListener

public void removeTreeWillExpandListener(javax.swing.event.TreeWillExpandListener tel)
Removes a listener for TreeWillExpand events.

Parameters:
tel - the TreeWillExpandListener to remove

getTreeSelectionModel

public javax.swing.tree.TreeSelectionModel getTreeSelectionModel()
Returns the selection model for the tree portion of the this treetable.

Returns:
selection model for the tree portion of the this treetable

sizeColumnsToFit

public void sizeColumnsToFit(int resizingColumn)
Overriden to invoke supers implementation, and then, if the receiver is editing a Tree column, the editors bounds is reset. The reason we have to do this is because JTable doesn't think the table is being edited, as getEditingRow returns -1, and therefore doesn't automaticly resize the editor for us.

Overrides:
sizeColumnsToFit in class javax.swing.JTable

updateUI

public void updateUI()
Overridden to message super and forward the method to the tree. Since the tree is not actually in the component hieachy it will never receive this unless we forward it in this manner.

Overrides:
updateUI in class JXTable

isHierarchical

public boolean isHierarchical(int column)
Determines if the specified column contains hierarchical nodes.

Overrides:
isHierarchical in class JXTable
Parameters:
column - zero-based index of the column
Returns:
true if the class of objects in the specified column implement the TreeNode interface; false otherwise.

getComponentAdapter

protected ComponentAdapter getComponentAdapter()
Returns the adapter that knows how to access the component data model. The component data adapter is used by filters, sorters, and highlighters.

Overrides:
getComponentAdapter in class JXTable
Returns:
the adapter that knows how to access the component data model