JIDE 3.5.15

com.jidesoft.grid
Class TreeTable

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 com.jidesoft.grid.JideTable
                      extended by com.jidesoft.grid.ContextSensitiveTable
                          extended by com.jidesoft.grid.NavigableTable
                              extended by com.jidesoft.grid.CellStyleTable
                                  extended by com.jidesoft.grid.CellSpanTable
                                      extended by com.jidesoft.grid.CategorizedTable
                                          extended by com.jidesoft.grid.SortableTable
                                              extended by com.jidesoft.grid.TreeTable
All Implemented Interfaces:
IndexChangeListener, SortListener, TableAdapter, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable
Direct Known Subclasses:
GroupTable, NavigationTreeTable, PropertyTable

public class TreeTable
extends SortableTable

TreeTable is a combination of a tree and a table -- a component capable of both expanding and contracting rows, as well as showing multiple columns of data. Tree and table work on different data structure. The former is used to display hierarchical data. The latter is used to disable a flat tabular data. So in order to make the data works in TreeTable, we need to hierarchize the flat tabular data. To make the design simple, we make the following assumption

If the data can be used in TreeTable, it must be row-oriented, meaning each row in the table can be represented as one data structure. Based on this assumption, we introduce several concepts (they are all Interfaces) to make TreeTable possible.

It will be simple to understand this using an example. A typical TreeTable example is the file system. In file system, there are files and folders. Using the concepts above, each file will be a Row; each folder will be an ExpandableRow. Folder (ExpandableRow) can have children which can be either files (Row) or other folders (ExpandableRow).

The table model used by TreeTable is TreeTableModel. It extends AbstractTableModel. However it's essentially a list of ExpandableRows or Rows. TreeTableModel is an abstract class. The only method you has to implement is TableModel.getColumnCount(). You might want to override AbstractTableModel.getColumnName(int). Otherwise, it will use "A", "B" etc as default names. You also need to make the columns match with the value you returned in Row.getValueAt(int). Once we create a java.util.List of the Rows, you call

 TreeTableModel model = new MyTreeTableModel(list);
 TreeTable table = new TreeTable(model);
 
Now you get a TreeTable instance.

TreeTable uses a special cell renderer on the first column to paint +/- icon as well as tree line. If the row is expandable, you will see +/- icon. Clicking on it will expand the row. Clicking again will collapse it. You can also use keyboard to expand/collapse a row. Right arrow key will expand the selected row and left arrow key will collapse it. If the selected row doesn't have children or it is collapsed already, it will change the selection to its parent. If you try it, you will find it is very convenient to navigate in the tree table using arrow keys.

Since the first columns are used to paint +/- icon and tree lines, it'd better you make the first column of the table not editable. There should be workaround for this limitation, such as using dialog to edit the first cell or rearranging the table columns to use a non-editable column as the first one.

We used the same +/- icons used in JTree so it will change based on different LookAndFeels. You can also define your own icons by calling CategorizedTable.setExpandedIcon(javax.swing.Icon) and CategorizedTable.setCollapsedIcon(javax.swing.Icon). The tree lines can be turn on or off using setShowTreeLines(boolean). The line color can be set by setTreeLineColor(java.awt.Color). By default, it will use the JTree's tree line color which is UIManagerLookup.getColor("Tree.hash").

There are several keystrokes you can use to expand or collapse rows. If the current cell is the first cell, you can use right or left arrow keys to expand or collapse the selected row respectively. You can also use "+", "-", "*", "/" key on Numpad to expand, collapse, expand all, collapse all respectively. So if your tree table has a huge number or unlimited number of children nodes, you should disable expand all operation because it will never end. This is important because Numpad "*" will trigger expand all. If you didn't disable expand all, user might press Numpad "*" key by mistake and freeze the GUI.

See Also:
Serialized Form

Nested Class Summary
protected  class TreeTable.DelegateExpandMouseInputListener
           
protected  class TreeTable.ExpandMouseListener
           
protected static class TreeTable.TreeTableAction
           
 
Nested classes/interfaces inherited from class com.jidesoft.grid.CellSpanTable
CellSpanTable.DelegateAction
 
Nested classes/interfaces inherited from class com.jidesoft.grid.JideTable
JideTable.NonContiguousTransferHandler
 
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
static String CLIENT_PROPERTY_DO_NOT_PAINT_CELL_CONTENT_BACKGROUND
           
static String PROPERTY_DOUBLE_CLICK_ENABLED
           
static String PROPERTY_EXPANDABLE_COLUMN
           
static String PROPERTY_SELECT_ROW_WHEN_TOGGLING
           
static String PROPERTY_SHOW_LEAF_NODE_TREE_LINES
           
static String PROPERTY_SHOW_TREE_LINES
           
static String PROPERTY_TREE_LINE_COLOR
           
 
Fields inherited from class com.jidesoft.grid.SortableTable
MULTICOLUMN_SORTABLE_PROPERTY, PROPERTY_SHOW_SORT_ORDER_NUMBER, SORTABLE_PROPERTY
 
Fields inherited from class com.jidesoft.grid.CategorizedTable
DEFAULT_ASCENDING_ICON, DEFAULT_DESCENDING_ICON, PROPERTY_EXPAND_ICON_VISIBLE
 
Fields inherited from class com.jidesoft.grid.CellSpanTable
AUTO_CELL_MERGE_COLUMNS, AUTO_CELL_MERGE_COLUMNS_LIMITED, AUTO_CELL_MERGE_OFF, AUTO_CELL_MERGE_ROWS, AUTO_CELL_MERGE_ROWS_LIMITED, PROPERTY_AUTO_CONVERT_CELL_SPAN, PROPERTY_PAINT_CELL_SPAN_AS_SELECTED
 
Fields inherited from class com.jidesoft.grid.CellStyleTable
_cellStyleList, PROPERTY_FILLS_SELECTION, PROPERTY_FILLS_VIEWPORT_WITH_STRIPE
 
Fields inherited from class com.jidesoft.grid.JideTable
_batchProcessing, _cellChangeEvent, _clickCountToStart, _columnAutoResizer, _columnResizer, _headerDraggingMouseMotionListener, _rolloverCellEditor, _rolloverCellEditorListener, _rolloverColumn, _rolloverEditorComp, _rolloverEditorRemover, _rolloverRow, _rowHeights, _rowResizer, ACTION_NAME_CANCEL_EDITING, AUTO_RESIZE_ALL_COLUMNS_FILL, AUTO_RESIZE_FILL, AUTO_RESIZE_LAST_COLUMN_FILL, AUTO_RESIZE_NEXT_COLUMN_FILL, AUTO_RESIZE_SUBSEQUENT_COLUMNS_FILL, CLIENT_PROPERTY_LAZY_CALCULATE_ROW_HEIGHT, EDITOR_AUTO_COMPLETION_MODE_COLUMN, EDITOR_AUTO_COMPLETION_MODE_NONE, EDITOR_AUTO_COMPLETION_MODE_ROW, EDITOR_AUTO_COMPLETION_MODE_TABLE, PROPERTY_CLEAR_SELECTION_ON_TABLE_DATA_CHANGES, PROPERTY_EDITOR_AUTO_COMPLETION_MODE, PROPERTY_FILLS_BOTTOM, PROPERTY_FILLS_GRIDS, PROPERTY_FILLS_RIGHT, PROPERTY_LOAD_SELECTION_ON_TABLE_DATA_CHANGES, PROPERTY_NON_CONTIGUOUS_CELL_SELECTION, PROPERTY_ROW_AUTO_RESIZES, PROPERTY_SCROLL_ROW_WHEN_ROW_HEIGHT_CHANGES, PROPERTY_TABLE_SELECTION_MODEL, ROW_AUTO_RESIZES_PROPERTY
 
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
TreeTable()
           
TreeTable(int numRows, int numColumns)
           
TreeTable(Object[][] rowData, Object[] columnNames)
           
TreeTable(TableModel dm)
           
TreeTable(TableModel dm, TableColumnModel cm)
           
TreeTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
           
TreeTable(Vector<?> rowData, Vector<?> columnNames)
           
 
Method Summary
 void addSelectedRow(Row row)
          Adds the specified Row.
 void addSelectedRows(Row[] rows)
          Adds the specified rows.
 void addTreeExpansionListener(TreeExpansionListener tel)
          Adds a listener for TreeExpansion events.
 void addTreeWillExpandListener(TreeWillExpandListener tel)
          Adds a listener for TreeWillExpand events.
 boolean alwaysCalculateCellRect()
          A boolean flag to determine if the rect should always be calculated when painting the grid line and cells.
 void collapseAll()
          Collapses all so that all non-top level rows are invisible.
 void collapseFirstLevel()
          Collapses all top level rows only.
 void collapseLastLevel()
          Collapses all top level rows only.
protected  TableCellRenderer createCellRenderer()
          Creates the special cell renderer for the first column which paints +/- icon and tree line.
protected  Action createDelegateAction(Action action, KeyStroke keyStroke)
           
protected  MouseInputListener createExpandMouseInputListener(MouseInputListener listener)
          Creates the mouse listener used to handle mouse click on +/- icon.
protected  MouseInputListener createExpandMouseListener()
          Creates the mouse listener used to handle mouse click on +/- icon.
protected  ISortableTableModel createSortableTableModel(TableModel model)
          Override the method in SortableTable to create a special sortable table model for TreeTable.
 Row expandableRowAtPoint(Point p)
          If the point falls into the expand icon (+/- icon), this method will return the Row.
 void expandAll()
          Expands all so that all rows are visible.
 void expandFirstLevel()
          Expands all top level rows.
 void expandNextLevel()
          Expands one more level of rows.
 boolean expandRow(int rowIndex, boolean expanded)
          Expands or collapses the row at the specified rowIndex.
 void fireTreeCollapsed(TreePath path)
          Notifies all listeners that have registered interest for notification on this event type.
 void fireTreeExpanded(TreePath path)
          Notifies all listeners that have registered interest for notification on this event type.
 void fireTreeWillCollapse(TreePath path)
          Notifies all listeners that have registered interest for notification on this event type.
 void fireTreeWillExpand(TreePath path)
          Notifies all listeners that have registered interest for notification on this event type.
 TableCellRenderer getActualCellRenderer(int rowIndex, int columnIndex)
           
 String getActualUIClassID()
          Returns a string that specifies the name of the L&F class that renders this component.
protected  Point getCellAt(Point p)
           
protected  Rectangle getCellRect(Point p)
          Gets the cell rect which contains point p.
 TableCellRenderer getCellRenderer(int rowIndex, int columnIndex)
          Returns an appropriate renderer for the cell specified by this row and column.
 int getDragExpandDelay()
          Get the delay time while dragging to expand a row.
 Rectangle getEditorCellRect(int rowIndex, int columnIndex)
          In TreeTable and HierarchicalTable case, the cell rect for cell editor should consider the +/- icon size so the cell editor doesn't cover the +/- icon.
 int getExpandableColumn()
          Gets the expandable column.
 int getExpandableColumnViewIndex()
          Gets the expandable column view index.
 int getHorizontalLegPosition(int cellHeight)
          Gets the horizontal leg y position.
 int getIndent()
          Gets the indent of child level, in pixels.
protected  int getIndent(Row row)
          Get the indent specificall for this row in the TreeTable.
 int getLeftMargin()
          Gets the left margin of first level, in pixels.
 Row getRowAt(int rowIndex)
          Gets the Row from the underlying table model.
 int getRowIndex(Row row)
           
 boolean getShowsRootHandles()
          Returns the value of the showsRootHandles property.
 TreeExpansionListener[] getTreeExpansionListeners()
          Returns an array of all the TreeExpansionListeners added to this TreeTable with addTreeExpansionListener().
 Color getTreeLineColor()
          Gets the line color used to pain the tree line.
protected  TableModel getTreeTableModel()
           
 TreeWillExpandListener[] getTreeWillExpandListeners()
          Returns an array of all the TreeWillExpandListeners added to this JTree with addTreeWillExpandListener().
 int getVerticalLineStartPosition(int cellHeight)
          Gets the vertical line start position.
protected  void handleMouseEvent(MouseEvent e)
          Handles the mouse event.
 boolean isCompareCurrentSelection()
          Get the flag indicating if comparing with the current selection before loading selection.
 boolean isDoubleClickEnabled()
          Checks if the double click is enabled.
 boolean isExpandable()
          Whether allowing the rows to be expanded and collapsed by the users.
 boolean isExpandAllAllowed()
          Is expand all or collapse all operations are allowed.
 boolean isExportCollapsedRowsToExcel()
          Get the flag indicating if collapsed rows would be exported to excel while exporting.
 boolean isRespectRenderPreferredHeight()
          Gets the flag if the renderer's preferred height is respected.
 boolean isSelectParentRowWhenCollapsing()
          Gets the flag indicating if the parent row should be selected when it's collapsed and one of its child row is already selected.
 boolean isSelectRowWhenToggling()
          Gets the value of selectRowWhenToggling property.
 boolean isShowLeafNodeTreeLines()
          Checks if the tree lines are visible.
 boolean isShowTreeLines()
          Checks if the tree lines are visible.
protected  void muteDefaultKeyStroke()
           
 void removeNotify()
           
 void removeSelectedRow(Row row)
          Removes the selection on the specified Row.
 void removeSelectedRows(Row[] rows)
          Removes the specified rows.
 void removeTreeExpansionListener(TreeExpansionListener tel)
          Removes a listener for TreeExpansion events.
 void removeTreeWillExpandListener(TreeWillExpandListener tel)
          Removes a listener for TreeWillExpand events.
 void setCompareCurrentSelection(boolean compareCurrentSelection)
          Set the flag indicating if comparing with the current selection before loading selection.
 void setDoubleClickEnabled(boolean doubleClickEnabled)
          Enables double click on the row to expand/collapse the row.
 void setDragExpandDelay(int dragExpandDelay)
          Set the delay time while dragging to expand a row.
 void setExpandable(boolean expandable)
          Sets the flag if the rows are allowed to be expanded and collapsed by the users.
 void setExpandableColumn(int expandableColumn)
          Sets the expandable column.
 void setExpandAllAllowed(boolean expandAllAllowed)
          Sets if expand all or collapse all are allowed.
 void setExportCollapsedRowsToExcel(boolean exportCollapsedRowsToExcel)
          Set the flag indicating if collapsed rows would be exported to excel while exporting.
 void setIndent(int indent)
          Sets the indent of child level, in pixels.
 void setLeftMargin(int leftMargin)
          Sets the left margin of first level, in pixels.
 void setModel(TableModel tableModel)
          Sets the data model for this table to newModel and registers with it for listener notifications from the new data model.
 void setRespectRenderPreferredHeight(boolean respectRenderPreferredHeight)
          Sets the flag if the renderer's preferred height is respected.
 void setSelectedRow(Row row)
          Selects the specified Row.
 void setSelectedRows(Row[] rows)
          Selects the specified rows.
 void setSelectParentRowWhenCollapsing(boolean selectParentRowWhenCollapsing)
          Sets the flag indicating if the parent row should be selected when it's collapsed and one of its child row is already selected.
 void setSelectRowWhenToggling(boolean selectRowWhenToggling)
          Sets the selectRowWhenToggling flag.
 void setShowLeafNodeTreeLines(boolean showLeafNodeTreeLines)
          Sets the tree lines visible or not.
 void setShowsRootHandles(boolean showRootHandles)
          Sets the value of the showsRootHandles property, which specifies whether the node handles should be displayed.
 void setShowTreeLines(boolean showTreeLines)
          Sets the tree lines visible or not.
 void setTreeLineColor(Color treeLineColor)
          Sets the tree line color.
 boolean shouldDisplayExpandIcon(Row row)
          Check if the expand icon should be displayed for a row.
 boolean shouldPaintHorizontalLeg(int rowIndex)
          Check if TreeTable should paint the horizontal leg for the row.
 void tableChanged(TableModelEvent e)
          Invoked when this table's TableModel generates a TableModelEvent.
protected  boolean toggleRow(Row row)
           
 void updateUI()
          Resets the UI property to a value from the current look and feel.
 
Methods inherited from class com.jidesoft.grid.SortableTable
createDefaultTableHeader, createSortableTableHeaderMouseListener, createSortIcon, getActualRowAt, getSortableHeaderMouseListener, getSortableTableModel, getSortArrowForeground, getSortedRowAt, getSortOrderForeground, isAutoResort, isEnsureSelectedRowVisibleOnTogglingSort, isMultiColumnSortable, isOptimized, isPreserveSelectionsAfterSorting, isReusable, isShowSortOrderNumber, isSortable, isSortingEnabled, resort, setAutoResort, setEnsureSelectedRowVisibleOnTogglingSort, setMultiColumnSortable, setOptimized, setPreserveSelectionsAfterSorting, setShowSortOrderNumber, setSortable, setSortArrowForeground, setSortingEnabled, setSortOrderForeground, sortChanged, sortChanging, sortColumn, sortColumn, sortColumn, sortColumn, sortColumn, sortColumn, unsort
 
Methods inherited from class com.jidesoft.grid.CategorizedTable
getAscendingIcon, getCategoryCollapsedIcon, getCategoryExpandedIcon, getCollapsedIcon, getCollapsedIcon, getDescendingIcon, getDisabledBackground, getDisabledForeground, getExpandedIcon, getExpandedIcon, getMarginBackground, isExpandIconVisible, isPaintMarginBackground, isUseLnfDefaultSortIcon, isUseTableRendererForCategoryRow, setAscendingIcon, setCategoryCollapsedIcon, setCategoryExpandedIcon, setCollapsedIcon, setDescendingIcon, setDisabledBackground, setDisabledForeground, setExpandedIcon, setExpandIconVisible, setMarginBackground, setPaintMarginBackground, setUseLnfDefaultSortIcon, setUseTableRendererForCategoryRow
 
Methods inherited from class com.jidesoft.grid.CellSpanTable
binarySearch, calculateRowHeight, calculateRowHeight, calculateRowHeights, columnAdded, columnAtPoint, columnMoved, columnRemoved, convertModelCellSpanToView, convertViewCellSpanToModel, createCellSpanCache, editCellAt, getActualRowHeight, getAutoCellMerge, getCache, getCacheEmpty, getCellEditor, getCellRect, getCellSpanAt, getCellSpanAt, getCellSpanFromAutoCellMerge, getCellSpanFromSpanModel, getDirtyRegion, getScrollableUnitIncrement, getSpanModel, getValueAt, invalidateCellSpanCache, isAutoConvertCellSpan, isCellFocused, isCellSelected, isCellSpanCacheEnabled, isCellSpanOn, isKeepColumnAtPoint, isKeepRowAtPoint, isPaintCellSpanAsSelected, originalColumnAtPoint, originalGetCellRect, originalRowAtPoint, prepareEditor, replaceAction, replaceAction, restoreAction, restoreAction, rolloverCellAt, rowAtPoint, setAutoCellMerge, setAutoConvertCellSpan, setCellSpanCacheEnabled, setKeepColumnAtPoint, setKeepRowAtPoint, setPaintCellSpanAsSelected, shouldCellBePaintedAsFocused, shouldCellBePaintedAsSelected, valueChanged, verifyCellSpan, verifyCellSpan
 
Methods inherited from class com.jidesoft.grid.CellStyleTable
addCellStyleCustomizer, clearCellStyleCustomizers, collectCellStyles, configureEditorComponent, configureRendererComponent, customizeEditorComponent, customizeRendererComponent, getCellStyleAt, getCellStyleCustomizers, getCellStyleProvider, getCellStyles, getFocusCellStyle, getNextStyleModel, getStyleModel, getTableStyleProvider, isFillsSelection, isFillsViewportWithStripe, mergeCellStyle, mergeCellStyles, needPaintStripedBackground, paintCellOverlay, paintCellUnderlay, paintComponent, prepareRenderer, releaseRendererComponent, removeCellStyleCustomizer, setCellStyleProvider, setFillsSelection, setFillsViewportWithStripe, setFocusCellStyle, setTableStyleProvider
 
Methods inherited from class com.jidesoft.grid.NavigableTable
changeSelection, findNearestNavigableCellInColumn, findNearestNavigableCellInRow, findNextNavigableCell, findNextNavigableCellInColumn, findNextNavigableCellInRow, findNextNavigableCellVertically, findPreviousNavigableCell, findPreviousNavigableCellInColumn, findPreviousNavigableCellInRow, findPreviousNavigableCellVertically, getNavigableModel, getNextNavigableModel, isCellNavigable, isNavigationKey, processKeyBinding
 
Methods inherited from class com.jidesoft.grid.ContextSensitiveTable
convertElementToString, createDefaultTransferHandler, getCellClassAt, getCellEditorFromManager, getCellRendererFromManager, getConverterContextAt, getDefaultCellRenderer, getEditorContextAt, invalidateCellRendererCache, isCellEditorManagerEnabled, isCellRendererManagerEnabled, setCellEditorManagerEnabled, setCellRendererManagerEnabled, setDefaultCellRenderer
 
Methods inherited from class com.jidesoft.grid.JideTable
addCellEditorListener, addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, addRowValidator, addUndo, addUndoableEditListener, addValidator, adjustSelectionWhenColumnMoved, calculateAutoResizedRowHeights, calculateAutoResizedRowHeights, clearSelection, clearSelectionPermanently, columnSelectionChanged, configureEnclosingScrollPaneExplicitly, convertRowIndexToModel, convertRowIndexToView, createCellAutoCompletion, createDefaultColumnsFromModel, createDefaultSelectionModel, createDefaultTableSelectionModel, createRowAutoScrollingListener, createRowHeights, createSortHeaderRenderer, editingCanceled, editingStopped, fireEditingCanceled, fireEditingStarted, fireEditingStarting, fireEditingStopped, fireEditingStopping, getCellEditorListeners, getClickCountToStart, getDefaultRenderer, getEditorAutoCompletionMode, getEditorAutoCompletionMode, getGridColor, getGridColorProvider, getRolloverCellEditor, getRolloverColumn, getRolloverRow, getRowHeight, getRowHeights, getRowValidator, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getTableColumnWidthKeeper, getTableHeaderToolTipText, getTableHeaderToolTipText, getTableSelectionModel, getTextComponentForEditorComponent, getToolTipText, getUndoManager, getValidator, getVerticalGridColor, indexChanged, initTable, isAdjustEditorLocationOnModelChanged, isAlwaysRequestFocusForEditor, isAutoResizeFillMode, isAutoSelectTextWhenStartsEditing, isAutoStartCellEditing, isAutoStartCellEditingKey, isBatchProcessing, isCalculateRowHeightsOnWidthChange, isCellContentVisible, isClearPropertyAtStructureChange, isClearSelectionOnTableDataChanges, isColumnAutoResizable, isColumnResizable, isColumnSelected, isEnableIgnored, isFillBottom, isFillGrids, isFillRight, isFillsBottom, isFillsGrids, isFillsGridsBottom, isFillsGridsRight, isFillsRight, isKeepRowHeights, isLoadSelectionOnTableDataChanged, isNestedTableHeader, isNonContiguousCellSelection, isRollover, isRowAutoResizes, isRowHeightChanged, isRowResizable, isRowSelected, isScrollRowWhenRowHeightChanges, isSelectInsertedRows, isTablePrinting, isValidCellEditingKey, isVariousRowHeights, loadTableRowSettings, paintFillHeader, removeCellEditorListener, removeColumn, removeColumnSelectionInterval, removeEditor, removeRolloverEditor, removeRowSelectionInterval, removeRowValidator, removeUndoableEditListener, removeValidator, resetTransferHandler, saveTableRowSettings, scrollRowToVisible, selectAll, setAdjustEditorLocationOnModelChanged, setAlwaysRequestFocusForEditor, setAutoResizeMode, setAutoSelectTextWhenStartsEditing, setAutoStartCellEditing, setBatchProcessing, setCalculateRowHeightsOnWidthChange, setCellContentVisible, setClearPropertyAtStructureChange, setClearSelectionOnTableDataChanges, setClickCountToStart, setColumnAutoResizable, setColumnResizable, setColumnSelectionAllowed, setColumnSelectionInterval, setEditorAutoCompletionMode, setEnabled, setEnableIgnored, setFillBottom, setFillGrids, setFillRight, setFillsBottom, setFillsGrids, setFillsRight, setGridColorProvider, setKeepRowHeights, setLoadSelectionOnTableDataChanged, setNestedTableHeader, setNonContiguousCellSelection, setPreferredSize, setRowAutoResizes, setRowHeight, setRowHeight, setRowHeights, setRowResizable, setRowSelectionAllowed, setRowSelectionInterval, setScrollRowWhenRowHeightChanges, setSelectInsertedRows, setSortTableHeaderRenderer, setTableColumnWidthKeeper, setTableHeader, setTablePrinting, setTableSelectionModel, setVariousRowHeights, startCellEditing, validate, validateRow
 
Methods inherited from class javax.swing.JTable
columnMarginChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createScrollPaneForTable, doLayout, editCellAt, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getUI, getUIClassID, getUpdateSelectionOnSort, initializeLocalVars, isCellEditable, isEditing, moveColumn, paramString, print, print, print, print, print, resizeAndRepaint, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setCellEditor, setCellSelectionEnabled, setColumnModel, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowMargin, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, unconfigureEnclosingScrollPane
 
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, 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, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, 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
 
Methods inherited from interface com.jidesoft.grid.TableAdapter
getCellSelectionEnabled, getColumnClass, getColumnCount, getColumnName, getColumnSelectionAllowed, getRowCount, getRowSelectionAllowed, isCellEditable, setCellSelectionEnabled, setValueAt
 

Field Detail

PROPERTY_SHOW_TREE_LINES

public static final String PROPERTY_SHOW_TREE_LINES
See Also:
Constant Field Values

PROPERTY_SHOW_LEAF_NODE_TREE_LINES

public static final String PROPERTY_SHOW_LEAF_NODE_TREE_LINES
See Also:
Constant Field Values

PROPERTY_TREE_LINE_COLOR

public static final String PROPERTY_TREE_LINE_COLOR
See Also:
Constant Field Values

PROPERTY_DOUBLE_CLICK_ENABLED

public static final String PROPERTY_DOUBLE_CLICK_ENABLED
See Also:
Constant Field Values

PROPERTY_EXPANDABLE_COLUMN

public static final String PROPERTY_EXPANDABLE_COLUMN
See Also:
Constant Field Values

PROPERTY_SELECT_ROW_WHEN_TOGGLING

public static final String PROPERTY_SELECT_ROW_WHEN_TOGGLING
See Also:
Constant Field Values

CLIENT_PROPERTY_DO_NOT_PAINT_CELL_CONTENT_BACKGROUND

public static final String CLIENT_PROPERTY_DO_NOT_PAINT_CELL_CONTENT_BACKGROUND
See Also:
Constant Field Values
Constructor Detail

TreeTable

public TreeTable()

TreeTable

public TreeTable(int numRows,
                 int numColumns)

TreeTable

public TreeTable(TableModel dm)

TreeTable

public TreeTable(Object[][] rowData,
                 Object[] columnNames)

TreeTable

public TreeTable(Vector<?> rowData,
                 Vector<?> columnNames)

TreeTable

public TreeTable(TableModel dm,
                 TableColumnModel cm)

TreeTable

public TreeTable(TableModel dm,
                 TableColumnModel cm,
                 ListSelectionModel sm)
Method Detail

updateUI

public void updateUI()
Resets the UI property to a value from the current look and feel.

Overrides:
updateUI in class CategorizedTable
See Also:
JComponent.updateUI()

getActualUIClassID

public String getActualUIClassID()
Returns a string that specifies the name of the L&F class that renders this component.

Overrides:
getActualUIClassID in class CellSpanTable
Returns:
the string "TreeTableUI"
See Also:
UIDefaults.getUI(javax.swing.JComponent)

createCellRenderer

protected TableCellRenderer createCellRenderer()
Creates the special cell renderer for the first column which paints +/- icon and tree line.

Returns:
an instance of TreeTableCellRenderer. The same instance will be used to paint the cell of all rows in TreeTable.

muteDefaultKeyStroke

protected void muteDefaultKeyStroke()
Overrides:
muteDefaultKeyStroke in class CellSpanTable

setModel

public void setModel(TableModel tableModel)
Sets the data model for this table to newModel and registers with it for listener notifications from the new data model.

If the table is in editing mode, it will stop cell editing first.

TreeTable only supports TreeTableModel. If newModel is null or tableModel is not an instance of TreeTableModel. An empty TreeTableModel will be created and used.

Overrides:
setModel in class SortableTable
Parameters:
tableModel - the new data source for this table. It must be an instance of TreeTableModel
See Also:
JTable.getModel()

handleMouseEvent

protected void handleMouseEvent(MouseEvent e)
Handles the mouse event. It does two things. If single mouse clicks on the +/- icon will expand/collapse the row. If isDoubleClickEnabled() is true, double click on the row any place other than +/- icon will expand/collapse the row as well.

Please note, since 1.9.4.10 release, we change the signature of this method to return boolean. If you override this method before, you will get a compile error. Simply change the overridden method to return boolean will fix it.

Parameters:
e - the mouse event

toggleRow

protected boolean toggleRow(Row row)

getRowAt

public Row getRowAt(int rowIndex)
Gets the Row from the underlying table model.

Parameters:
rowIndex - the row index
Returns:
Row at the specified row index.

getRowIndex

public int getRowIndex(Row row)

expandRow

public boolean expandRow(int rowIndex,
                         boolean expanded)
Expands or collapses the row at the specified rowIndex.

Parameters:
rowIndex - rowIndex to be expanded.
expanded - true to expand and false to collapse.
Returns:
true if the row is expanded.

isSelectRowWhenToggling

public boolean isSelectRowWhenToggling()
Gets the value of selectRowWhenToggling property. If true, the row will be selected when when a row is expanded or collapsed. If false, the old selection will be kept when a row is expanded or collapsed.

Returns:
true or false.

setSelectRowWhenToggling

public void setSelectRowWhenToggling(boolean selectRowWhenToggling)
Sets the selectRowWhenToggling flag.

Parameters:
selectRowWhenToggling - true or false. If true, the row will be selected when when a row is expanded or collapsed. If false, the old selection will be kept when a row is expanded or collapsed.

setSelectedRow

public void setSelectedRow(Row row)
Selects the specified Row. In TreeTable, a Row could be at any row index when expand/collapse state changes. The old way to select a row using selection model won't work. This method will make it easier to select a row by passing in the Row which you usually know.

If the Row is not visible, it will expand its parents to make it visible.

Parameters:
row - the row

addSelectedRow

public void addSelectedRow(Row row)
Adds the specified Row. In TreeTable, a Row could be at any row index when expand/collapse state changes. The old way to select a row using selection model won't work. This method will make it easier to select a row by passing in the Row which you usually know.

If the Row is not visible, it will expand its parents to make it visible.

Parameters:
row - the row

removeSelectedRow

public void removeSelectedRow(Row row)
Removes the selection on the specified Row. In TreeTable, a Row could be at any row index when expand/collapse state changes. The old way to de-select a row using selection model won't work. This method will make it easier to de-select a row by passing in the Row which you usually know.

Parameters:
row - the row

setSelectedRows

public void setSelectedRows(Row[] rows)
Selects the specified rows. In TreeTable, a Row could be at any row index when expand/collapse state changes. The old way to select rows using selection model won't work. This method will make it easier to select rows by passing in the rows which you usually know.

If the rows are not visible, it will expand their parents to make them visible.

Parameters:
rows - the rows

addSelectedRows

public void addSelectedRows(Row[] rows)
Adds the specified rows. In TreeTable, a Row could be at any row index when expand/collapse state changes. The old way to select rows using selection model won't work. This method will make it easier to select rows by passing in the rows which you usually know.

If the rows are not visible, it will expand their parents to make them visible.

Parameters:
rows - the rows

removeSelectedRows

public void removeSelectedRows(Row[] rows)
Removes the specified rows. In TreeTable, a Row could be at any row index when expand/collapse state changes. The old way to de-select rows using selection model won't work. This method will make it easier to de-select rows by passing in the rows which you usually know.

Parameters:
rows - the rows

expandAll

public void expandAll()
Expands all so that all rows are visible.


expandFirstLevel

public void expandFirstLevel()
Expands all top level rows.


expandNextLevel

public void expandNextLevel()
Expands one more level of rows.


collapseAll

public void collapseAll()
Collapses all so that all non-top level rows are invisible.


collapseFirstLevel

public void collapseFirstLevel()
Collapses all top level rows only. The children level rows are still expanded if they were. But they can't be seen anymore as the root rows are collapsed. If you expand the root rows after this call, you will see the children rows remain expanded.


collapseLastLevel

public void collapseLastLevel()
Collapses all top level rows only. The children level rows are still expanded if they were. But they can't be seen anymore as the root rows are collapsed. If you expand the root rows after this call, you will see the children rows remain expanded.


getCellRect

protected Rectangle getCellRect(Point p)
Gets the cell rect which contains point p.

Parameters:
p - the point
Returns:
cell rectangle

getCellAt

protected Point getCellAt(Point p)

getActualCellRenderer

public TableCellRenderer getActualCellRenderer(int rowIndex,
                                               int columnIndex)

tableChanged

public void tableChanged(TableModelEvent e)
Description copied from class: JideTable
Invoked when this table's TableModel generates a TableModelEvent. The TableModelEvent should be constructed in the coordinate system of the model; the appropriate mapping to the view coordinate system is performed by this JTable when it receives the event.

Application code will not use these methods explicitly, they are used internally by JTable.

Specified by:
tableChanged in interface TableModelListener
Overrides:
tableChanged in class CellSpanTable

removeNotify

public void removeNotify()
Overrides:
removeNotify in class JideTable

getCellRenderer

public TableCellRenderer getCellRenderer(int rowIndex,
                                         int columnIndex)
Description copied from class: ContextSensitiveTable
Returns an appropriate renderer for the cell specified by this row and column. First, it will check if defaultCellRenderer is set using ContextSensitiveTable.getDefaultCellRenderer() method. If null, it will check is ContextSensitiveTable.isCellRendererManagerEnabled() is true. If true, it will look for the cell renderer that assigned to the specific column. Only if the renderer is still null, it will use the EditorContext information from ContextSensitiveTableModel and get the correct CellRedenerer from the CellRendererManager. In any case, if we can't determine a cell renderer, we will call super.getCellRenderer(row, column) just like regular JTable.

Overrides:
getCellRenderer in class CellSpanTable
Parameters:
rowIndex - the row of the cell to render, where 0 is the first row
columnIndex - the column of the cell to render, where 0 is the first column
Returns:
the renderer for the column and row.

createDelegateAction

protected Action createDelegateAction(Action action,
                                      KeyStroke keyStroke)
Overrides:
createDelegateAction in class CellSpanTable

isCompareCurrentSelection

public boolean isCompareCurrentSelection()
Get the flag indicating if comparing with the current selection before loading selection.

Returns:
the flag.
See Also:
setCompareCurrentSelection(boolean)

setCompareCurrentSelection

public void setCompareCurrentSelection(boolean compareCurrentSelection)
Set the flag indicating if comparing with the current selection before loading selection.

Parameters:
compareCurrentSelection - if current selection will be compared with the selection to load. By default, the value is false for performance reason. You could turn this flag to true if you care more about the selection events.

isExportCollapsedRowsToExcel

public boolean isExportCollapsedRowsToExcel()
Get the flag indicating if collapsed rows would be exported to excel while exporting.

The default value of this flag is false. The reason is that we have to updateUI() to export the collapsed rows. You could set it to true. However, you will have to consider put the exporting task to EDT, which could freeze the UI in large amount of data.

Returns:
true if collapsed rows would be exported to excel. Otherwise false.

setExportCollapsedRowsToExcel

public void setExportCollapsedRowsToExcel(boolean exportCollapsedRowsToExcel)
Set the flag indicating if collapsed rows would be exported to excel while exporting.

Parameters:
exportCollapsedRowsToExcel - the flag
See Also:
isExportCollapsedRowsToExcel()

getIndent

protected int getIndent(Row row)
Get the indent specificall for this row in the TreeTable. By default, we will just invoke getIndent() to return. If you want to customize the indent behavior for specific rows, please override this method.

Parameters:
row - the row
Returns:
the indent for the row comparing its parent row.

getDragExpandDelay

public int getDragExpandDelay()
Get the delay time while dragging to expand a row.

The default value of the delay time is 200ms. Since the drag functionality was introduced since JDK 1.6, this method will only take effect since JDK 1.6 as well.

Returns:
the delay time in milliseconds.
See Also:
JTable.setDragEnabled(boolean), JTable.setDropMode(javax.swing.DropMode), JComponent.setTransferHandler(javax.swing.TransferHandler)

setDragExpandDelay

public void setDragExpandDelay(int dragExpandDelay)
Set the delay time while dragging to expand a row.

Parameters:
dragExpandDelay - the delay time in milliseconds
See Also:
getDragExpandDelay()

isSelectParentRowWhenCollapsing

public boolean isSelectParentRowWhenCollapsing()
Gets the flag indicating if the parent row should be selected when it's collapsed and one of its child row is already selected.

Returns:
true if parent row should be selected. Otherwise false.
Since:
3.5.9
See Also:
setSelectParentRowWhenCollapsing(boolean)

setSelectParentRowWhenCollapsing

public void setSelectParentRowWhenCollapsing(boolean selectParentRowWhenCollapsing)
Sets the flag indicating if the parent row should be selected when it's collapsed and one of its child row is already selected.

By default, the value is true.

Parameters:
selectParentRowWhenCollapsing - the flag
Since:
3.5.9

createExpandMouseListener

protected MouseInputListener createExpandMouseListener()
Creates the mouse listener used to handle mouse click on +/- icon.

Please override this method if you are NOT in JDK 1.6. Otherwise, please use createExpandMouseInputListener(javax.swing.event.MouseInputListener) instead.

Returns:
a mouse listener.
See Also:
createExpandMouseInputListener(javax.swing.event.MouseInputListener)

createExpandMouseInputListener

protected MouseInputListener createExpandMouseInputListener(MouseInputListener listener)
Creates the mouse listener used to handle mouse click on +/- icon.

Please override this method if you are in JDK 1.6. In other JDK releases, please use createExpandMouseListener() instead.

Parameters:
listener - the MouseInputListener
Returns:
a mouse listener.
See Also:
createExpandMouseListener()

addTreeExpansionListener

public void addTreeExpansionListener(TreeExpansionListener tel)
Adds a listener for TreeExpansion events.

Please note, methods such as expandAll(), expandFirstLevel(), expandNextLevel(), collapseAll(), collapseFirstLevel() and collapseLastLevel() will not fire this event.

Parameters:
tel - a TreeExpansionListener that will be notified when a row is expanded or collapsed (a "negative expansion")

removeTreeExpansionListener

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

Parameters:
tel - the TreeExpansionListener to remove

getTreeExpansionListeners

public TreeExpansionListener[] getTreeExpansionListeners()
Returns an array of all the TreeExpansionListeners added to this TreeTable with addTreeExpansionListener().

Returns:
all of the TreeExpansionListeners added or an empty array if no listeners have been added

fireTreeExpanded

public void fireTreeExpanded(TreePath path)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the path parameter.

Parameters:
path - the TreePath indicating the node that was expanded
See Also:
EventListenerList

fireTreeCollapsed

public void fireTreeCollapsed(TreePath path)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the path parameter.

Parameters:
path - the TreePath indicating the node that was collapsed
See Also:
EventListenerList

addTreeWillExpandListener

public void addTreeWillExpandListener(TreeWillExpandListener tel)
Adds a listener for TreeWillExpand events.

Please note, methods such as expandAll(), expandFirstLevel(), expandNextLevel(), collapseAll(), collapseFirstLevel() and collapseLastLevel() will not fire this event.

Parameters:
tel - a TreeWillExpandListener that will be notified when a tree node will be expanded or collapsed (a "negative expansion")

removeTreeWillExpandListener

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

Parameters:
tel - the TreeWillExpandListener to remove

getTreeWillExpandListeners

public TreeWillExpandListener[] getTreeWillExpandListeners()
Returns an array of all the TreeWillExpandListeners added to this JTree with addTreeWillExpandListener().

Returns:
all of the TreeWillExpandListeners added or an empty array if no listeners have been added

fireTreeWillExpand

public void fireTreeWillExpand(TreePath path)
                        throws ExpandVetoException
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the path parameter.

Parameters:
path - the TreePath indicating the node that was expanded
Throws:
ExpandVetoException - if the tree node is not allowed to be expanded
See Also:
EventListenerList

fireTreeWillCollapse

public void fireTreeWillCollapse(TreePath path)
                          throws ExpandVetoException
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the path parameter.

Parameters:
path - the TreePath indicating the node that was expanded
Throws:
ExpandVetoException - if the tree node is not allowed to be collapsed
See Also:
EventListenerList

isShowTreeLines

public boolean isShowTreeLines()
Checks if the tree lines are visible.

Returns:
true if tree lines is visible.

setShowTreeLines

public void setShowTreeLines(boolean showTreeLines)
Sets the tree lines visible or not. Property change event on PROPERTY_SHOW_TREE_LINES be fired when value changes.

Parameters:
showTreeLines - true to show the tree lines. Otherwise false.

isShowLeafNodeTreeLines

public boolean isShowLeafNodeTreeLines()
Checks if the tree lines are visible.

Returns:
true if tree lines is visible.

setShowLeafNodeTreeLines

public void setShowLeafNodeTreeLines(boolean showLeafNodeTreeLines)
Sets the tree lines visible or not. Property change event on PROPERTY_SHOW_LEAF_NODE_TREE_LINES be fired when value changes.

Parameters:
showLeafNodeTreeLines - true to show leaf node's tree lines

isDoubleClickEnabled

public boolean isDoubleClickEnabled()
Checks if the double click is enabled. If it is enabled, double clicking anywhere on the row (except the +/- icon area) will expand/collapse the row. If the cells are editable, it is recommend you set it to false. Otherwise it will conflict with cell editing. Default is true.

Returns:
true if double click on the row is enabled.

setDoubleClickEnabled

public void setDoubleClickEnabled(boolean doubleClickEnabled)
Enables double click on the row to expand/collapse the row. Property change event on PROPERTY_DOUBLE_CLICK_ENABLED be fired when value changes.

Parameters:
doubleClickEnabled - true to enable double click to expand/collapse a row

getTreeLineColor

public Color getTreeLineColor()
Gets the line color used to pain the tree line.

Returns:
the tree line color.

setTreeLineColor

public void setTreeLineColor(Color treeLineColor)
Sets the tree line color. Property change event on PROPERTY_TREE_LINE_COLOR be fired when value changes.

Parameters:
treeLineColor - the new tree line color

getTreeTableModel

protected TableModel getTreeTableModel()

createSortableTableModel

protected ISortableTableModel createSortableTableModel(TableModel model)
Override the method in SortableTable to create a special sortable table model for TreeTable.

Overrides:
createSortableTableModel in class SortableTable
Parameters:
model - the table model.
Returns:
a SortableTableModel.

getIndent

public int getIndent()
Gets the indent of child level, in pixels.

Returns:
the indent.

setIndent

public void setIndent(int indent)
Sets the indent of child level, in pixels. Default value is 16.

Parameters:
indent - the new indent

getLeftMargin

public int getLeftMargin()
Gets the left margin of first level, in pixels.

Returns:
the indent.
See Also:
setLeftMargin(int)

setLeftMargin

public void setLeftMargin(int leftMargin)
Sets the left margin of first level, in pixels.

By default, the value is 16.

Parameters:
leftMargin - the left margin

getShowsRootHandles

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

Returns:
the value of the showsRootHandles property
See Also:
_showsRootHandles

setShowsRootHandles

public void setShowsRootHandles(boolean showRootHandles)
Sets the value of the showsRootHandles property, which specifies whether the node handles should be displayed. The default value of this property depends on the constructor used to create the TreeTable. Some look and feels might not support handles; they will ignore this property.

Parameters:
showRootHandles - true if root handles should be displayed; otherwise, false description: Whether the node handles are to be displayed.
See Also:
_showsRootHandles, getShowsRootHandles()

isExpandAllAllowed

public boolean isExpandAllAllowed()
Is expand all or collapse all operations are allowed.

Returns:
if expand all operation is allowed.

setExpandAllAllowed

public void setExpandAllAllowed(boolean expandAllAllowed)
Sets if expand all or collapse all are allowed. Expand all will recursively go through all tree nodes and expand all of them. So if your tree table has a huge number or unlimited number of children nodes, you should disable expand all operation because it will never end. This is important because Numpad "*" will trigger expand all. If you didn't disable expand all, user might press Numpad "*" key by mistake and freeze the GUI.

Parameters:
expandAllAllowed - true to enable expand all

isExpandable

public boolean isExpandable()
Whether allowing the rows to be expanded and collapsed by the users. Developers can still expand/collapse rows using the API.

Returns:
true or false.

setExpandable

public void setExpandable(boolean expandable)
Sets the flag if the rows are allowed to be expanded and collapsed by the users. Default is true.

Parameters:
expandable - true to allow the rows to be expanded and collapsed by the users.

getExpandableColumnViewIndex

public int getExpandableColumnViewIndex()
Gets the expandable column view index. Different from getExpandableColumn(), this one will convert the index from model index to index. There is no setter for this method, you have to set it through setExpandableColumn(int). If you never called setExpandableColumn, this method will always return 0 meaning the first visible column will be used to display the +/- icon.

Returns:
the expandable column view index.

shouldPaintHorizontalLeg

public boolean shouldPaintHorizontalLeg(int rowIndex)
Check if TreeTable should paint the horizontal leg for the row.

The default implementation of this method is to check the isShowLeafNodeTreeLines method.

      Row row = getRowAt(rowIndex);
      if (row == null) {
          return false;
      }
      Expandable parent = row.getParent();
      if (row instanceof Expandable && !((Expandable) row).hasChildren() && !isShowLeafNodeTreeLines() && parent
 instanceof Row) {
          int lastChildIndex = getRowIndex((Row) parent) + TableModelWrapperUtils.getVisibleChildrenCount(getModel(),
 (Row) parent);
          if (rowIndex != lastChildIndex) {
              return false;
          }
      }
      return true;
 

Parameters:
rowIndex - the index of the row
Returns:
true if the horizontal leg should be painted. Otherwise false.
See Also:
isShowLeafNodeTreeLines()

getExpandableColumn

public int getExpandableColumn()
Gets the expandable column.

Expandable column is the column which has an expand/collapse button and tree lines if needed. Clicking on that button will show/hide the child component associated with that row. Due to the limitation of the implementation, all cells in that column should be not editable.

It should be a value between -1 and getColumnCount() - 1. A value as -1 means that you don't want to designate any column to be expandable. In this case, the first visible column would always be painted with expand/collapse button and tree lines. Any value between 0 and getColumnCount() - 1 means that the visible column with the model index as the value will be painted with expand/collapse button and tree lines.

The default value is -1.

Returns:
the expandable column.

setExpandableColumn

public void setExpandableColumn(int expandableColumn)
Sets the expandable column.

Parameters:
expandableColumn - new expandable column.
See Also:
getExpandableColumn()

getHorizontalLegPosition

public int getHorizontalLegPosition(int cellHeight)
Gets the horizontal leg y position. It is also the +/- icon y center position. By default, it will use half the size of cellHeight. You can override this method to return another value in case your cell is not center aligned vertically.

Parameters:
cellHeight - the new cell height
Returns:
the horizontal leg y position.

getVerticalLineStartPosition

public int getVerticalLineStartPosition(int cellHeight)
Gets the vertical line start position. By default, it will start from the next row of the parent row. You can override this method to return another value in case you want to cover the empty space when your row height is big.

Parameters:
cellHeight - the cell height
Returns:
vertical line start position.

expandableRowAtPoint

public Row expandableRowAtPoint(Point p)
If the point falls into the expand icon (+/- icon), this method will return the Row. Otherwise, it will return null.

Parameters:
p - the point
Returns:
the Row that has the +/- icon or null.

getEditorCellRect

public Rectangle getEditorCellRect(int rowIndex,
                                   int columnIndex)
Description copied from class: JideTable
In TreeTable and HierarchicalTable case, the cell rect for cell editor should consider the +/- icon size so the cell editor doesn't cover the +/- icon. In order to do it, we introduce EditorCellRect concept. By default, it is same as getCellRect(rowIndex, columnIndex, false). TreeTable and HierarchicalTable will override it to provide a different rect for cell editor.

Overrides:
getEditorCellRect in class JideTable
Parameters:
rowIndex - the row index.
columnIndex - the column index
Returns:
the cell rect for the cell editor.

alwaysCalculateCellRect

public boolean alwaysCalculateCellRect()
A boolean flag to determine if the rect should always be calculated when painting the grid line and cells. If false, it will calculate the rect for the first column once and then add the column width to determine the next column cell rect. It returns false in JideTable but subclass can return true (such as in TreeTable and HierarchicalTable case).

Overrides:
alwaysCalculateCellRect in class JideTable
Returns:
true by default. Since we will calculate the rect differently for the cell that has expand/collapse icon, we will have to calculate the rect size for each cell.

isRespectRenderPreferredHeight

public boolean isRespectRenderPreferredHeight()
Gets the flag if the renderer's preferred height is respected.

Returns:
true or false.

setRespectRenderPreferredHeight

public void setRespectRenderPreferredHeight(boolean respectRenderPreferredHeight)
Sets the flag if the renderer's preferred height is respected. By default, the tree table's first column adds +/- icon before the actual renderer. The renderer is painted to cover the whole height of the cell. If this flag is set to false, we will use the actual renderer height when painting the renderer.

Parameters:
respectRenderPreferredHeight - true or false.

shouldDisplayExpandIcon

public boolean shouldDisplayExpandIcon(Row row)
Check if the expand icon should be displayed for a row.

This method is invoked by BasicTreeTableUIDelegate to determine if an icon should be painted for the row. You could override this method to alter the default painting behavior.

Parameters:
row - the row to check
Returns:
true if an expand/collapse icon should be displayed for the row. Otherwise false.
Since:
3.5.8

JIDE 3.5.15