JIDE 3.5.15

com.jidesoft.grid
Class HierarchicalTable

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.HierarchicalTable
All Implemented Interfaces:
HierarchicalTableSupport, IndexChangeListener, SortListener, TableAdapter, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable
Direct Known Subclasses:
NavigationHierarchicalTable

public class HierarchicalTable
extends SortableTable
implements HierarchicalTableSupport

HierarchicalTable is a special JTable which can show any components inside the table in a hierarchical fashion. Each row can have a child component. Usually the child component is not visible. However if expandRow() is called on a row, the child component will be shown either under that row or replace that row. Since the child component itself could be another HierarchicalTable which can have child components, as a result, it forms a hierarchy. This is why we called it HierarchicalTable.

In fact, in addition to show in as hierarchy, HierarchicalTable can also be used to display master-detail relation. When there are a lot of details of each row but can't be shown because of the column count limitation, child component can be used to display the details of each row.

HierarchicalTable has one special column called expandable column. If a column is an expandable column, there will be an expand/collapse button on the left side of any cells in that column. Clicking on that button will expand/collapse. By default, the first column is the expandable column. Usually if you choose a column to be expandable column, the cells in that column should be read only. If you want to control when to expand/collapse all by yourself, you can call setHierarchicalColumn(-1). You can then add mouse listener or key listener to expand or collapse.

There is another attribute called singleExpansion. Typical when user expand a row, then expand another row, they want both rows to be expanded. However there are case user wants one row to be expanded at a time. singleExpansion can be used in this case. singleExpansion is true means only one row can expanded at a time. Default is false.

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.setCategoryExpandedIcon(javax.swing.Icon) and CategorizedTable.setCategoryCollapsedIcon(javax.swing.Icon).

HierarchicalTable is a SortableTable, so you can sort the table even with some rows are expanded. If you don't want the sorting feature, simple call setSortable(false).

This class is part of HierarchicalTable component. If you used the beta version of HierarchicalTable component before, please note you need to change your code as the interface changed. The main reason for this change is to break the model from view. Please refer to HierarchicalTableModel for details.

See Also:
Serialized Form

Nested Class Summary
protected  class HierarchicalTable.DelegateExpandMouseInputListener
           
protected  class HierarchicalTable.ExpandMouseListener
           
protected static class HierarchicalTable.HierarchicalTableAction
           
 
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
protected  HierarchicalTableCellRenderer _hierarchicalTableCellRenderer
           
static String PROPERTY_DOUBLE_CLICK_ENABLED
           
static String PROPERTY_HIERARCHICAL_COLUMN
           
static String PROPERTY_MOUSE_ENABLED
           
static String PROPERTY_SELECT_ROW_WHEN_TOGGLING
           
static String PROPERTY_SINGLE_EXPANSION
           
 
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
HierarchicalTable()
          Constructs a default HierarchicalTable that is initialized with a default data model, a default column model, and a default selection model.
HierarchicalTable(int numRows, int numColumns)
          Constructs a JTable with numRows and numColumns of empty cells using DefaultTableModel.
HierarchicalTable(Object[][] rowData, Object[] columnNames)
          Constructs a JTable to display the values in the two dimensional array, rowData, with column names, columnNames.
HierarchicalTable(TableModel dm)
          Constructs a HierarchicalTable that is initialized with dm as the data model, a default column model, and a default selection model.
HierarchicalTable(TableModel dm, TableColumnModel cm)
          Constructs a HierarchicalTable that is initialized with dm as the data model, cm as the column model, and a default selection model.
HierarchicalTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
          Constructs a JTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model.
HierarchicalTable(Vector<?> rowData, Vector<?> columnNames)
          Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames.
 
Method Summary
 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 changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
          Override the default implementation to adjust the selection avoiding the non-navigable cells.
protected  void childComponentResized()
          The action to take while child component is resized.
 void collapseAllRows()
          Collapse all rows.
 void collapseRow(int row)
          Collapse the row.
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  HierarchicalTableCellRenderer createHierarchicalTableCellRenderer()
          Creates the HierarchicalTableCellRenderer.
protected  RowHeights createRowHeights()
           
 void doLayout()
           
 boolean editCellAt(int row, int column, EventObject e)
          Overrides to make sure the editor is set the correct height when there is expanded row.
 void expandAllRows()
          Expands all rows as long as they are expandable.
 void expandRow(int row)
          Expands the row if the row has child component.
 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.
 int getActualRowHeight(int row)
          As we overridden getRowModel(), JideTable.getRowHeight(int) will now return the row height considering the child component height.
 String getActualUIClassID()
           
 Rectangle getCellRect(int rowIndex, int columnIndex, boolean includeSpacing)
           
 TableCellRenderer getCellRenderer(int row, int column)
          Returns an appropriate renderer for the cell specified by this row and column.
 Component getChildComponentAt(int row)
          Gets the child component at the specified row index.
protected  ComponentListener getChildComponentResizeListener()
          Get the child component listener.
 HierarchicalTableComponentFactory getComponentFactory()
          Gets the component factory that will create the child component of HierarchicalTable.
 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 getHierarchicalColumn()
          Gets the hierarchical column.
 int getHierarchicalColumnViewIndex()
          Gets the expandable column view index.
 int getHorizontalLegPosition(int cellHeight)
          Gets the horizontal leg y position.
 TreeExpansionListener[] getTreeExpansionListeners()
          Returns an array of all the TreeExpansionListeners added to this JTree with addTreeExpansionListener().
 TreeWillExpandListener[] getTreeWillExpandListeners()
          Returns an array of all the TreeWillExpandListeners added to this JTree with addTreeWillExpandListener().
protected  void handleMouseEvent(MouseEvent e)
          There are too many ways to control when to expand and when to collapse.
 boolean isActualRowExpanded(int actualRow)
          Return true if the row is expanded.
 boolean isAnyExpanded()
          Return true if any row is expanded.
 boolean isAutoRefreshOnRowUpdate()
          Checks if refreshRow() is called when row updated event is fired.
 boolean isDoubleClickEnabled()
          Checks if the double click is enabled.
 boolean isExpanded(int row)
          Return true if the row is expanded.
 boolean isMouseEnabled()
          Returns true if default mouse listener is installed to expand/collapse rows.
 boolean isPaintMarginGridMarginBackground()
          Get the flag indicating if HierarchicalTable should paint the grids inside the MarginExpandablePanel to the color get from CategorizedTable.getMarginBackground().
protected  boolean isRowHeightChanged(int row, int newHeight)
          The method will check if the new height is different with current height.
 boolean isSelectRowWhenToggling()
          Gets the value of selectRowWhenToggling property.
 boolean isSingleExpansion()
          Returns true if only one row can be expanded at a time.
 boolean isVariousRowHeights()
          Is the table has various row height on each row.
protected  void muteDefaultKeyStroke()
           
 void refreshRow(int row)
          Refresh the row.
 void removeTreeExpansionListener(TreeExpansionListener tel)
          Removes a listener for TreeExpansion events.
 void removeTreeWillExpandListener(TreeWillExpandListener tel)
          Removes a listener for TreeWillExpand events.
 boolean rolloverCellAt(int row, int column)
          Makes the cell enters editing mode without forcing the other cell editor, if any, to stop editing.
 void setActualRowHeight(int row, int rowHeight)
          Sets the actual row height without the child component.
 void setAutoRefreshOnRowUpdate(boolean autoRefreshOnRowUpdate)
          Sets the flag autoRefreshOnRowUpdate.
 void setComponentFactory(HierarchicalTableComponentFactory factory)
          Sets the component factory that will create the child component of HierarchicalTable.
 void setDoubleClickEnabled(boolean doubleClickEnabled)
          Enables double click on the row to expand/collapse the row.
 void setEnabled(boolean enabled)
           
 void setHierarchicalColumn(int hierarchicalColumn)
          Sets the hierarchical column.
 void setMouseEnabled(boolean mouseEnabled)
          Sets the mouseEnabled attribute.
 void setPaintMarginGridMarginBackground(boolean paintMarginGridMarginBackground)
          Set the flag indicating if HierarchicalTable should paint the grids inside the MarginExpandablePanel to the color get from CategorizedTable.getMarginBackground().
 void setSelectRowWhenToggling(boolean selectRowWhenToggling)
          Sets the selectRowWhenToggling flag.
 void setSingleExpansion(boolean singleExpansion)
          Sets the singleExpansion attribute.
 void toggleRow(int row)
          Expands the specified row if it's not expanded or collapse the row if it's expanded already.
 
Methods inherited from class com.jidesoft.grid.SortableTable
createDefaultTableHeader, createSortableTableHeaderMouseListener, createSortableTableModel, createSortIcon, getActualRowAt, getSortableHeaderMouseListener, getSortableTableModel, getSortArrowForeground, getSortedRowAt, getSortOrderForeground, isAutoResort, isEnsureSelectedRowVisibleOnTogglingSort, isMultiColumnSortable, isOptimized, isPreserveSelectionsAfterSorting, isReusable, isShowSortOrderNumber, isSortable, isSortingEnabled, resort, setAutoResort, setEnsureSelectedRowVisibleOnTogglingSort, setModel, 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, updateUI
 
Methods inherited from class com.jidesoft.grid.CellSpanTable
binarySearch, calculateRowHeight, calculateRowHeight, calculateRowHeights, columnAdded, columnAtPoint, columnMoved, columnRemoved, convertModelCellSpanToView, convertViewCellSpanToModel, createCellSpanCache, getAutoCellMerge, getCache, getCacheEmpty, getCellEditor, 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, rowAtPoint, setAutoCellMerge, setAutoConvertCellSpan, setCellSpanCacheEnabled, setKeepColumnAtPoint, setKeepRowAtPoint, setPaintCellSpanAsSelected, shouldCellBePaintedAsFocused, shouldCellBePaintedAsSelected, tableChanged, 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
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, 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, isRowResizable, isRowSelected, isScrollRowWhenRowHeightChanges, isSelectInsertedRows, isTablePrinting, isValidCellEditingKey, loadTableRowSettings, paintFillHeader, removeCellEditorListener, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, 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, 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, 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_SINGLE_EXPANSION

public static final String PROPERTY_SINGLE_EXPANSION
See Also:
Constant Field Values

PROPERTY_MOUSE_ENABLED

public static final String PROPERTY_MOUSE_ENABLED
See Also:
Constant Field Values

PROPERTY_HIERARCHICAL_COLUMN

public static final String PROPERTY_HIERARCHICAL_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

PROPERTY_DOUBLE_CLICK_ENABLED

public static final String PROPERTY_DOUBLE_CLICK_ENABLED
See Also:
Constant Field Values

_hierarchicalTableCellRenderer

protected HierarchicalTableCellRenderer _hierarchicalTableCellRenderer
Constructor Detail

HierarchicalTable

public HierarchicalTable()
Constructs a default HierarchicalTable that is initialized with a default data model, a default column model, and a default selection model.

Since HierarchicalTable expects an instance of HierarchicalTableModel ex data model, this constructor creates nothing but a regular JTable if there is no subsequent call to setModel() to pass in a HierarchicalTableModel.


HierarchicalTable

public HierarchicalTable(TableModel dm)
Constructs a HierarchicalTable that is initialized with dm as the data model, a default column model, and a default selection model.

Parameters:
dm - the data model for the table. It should be an instance of HierarchicalTableModel.

HierarchicalTable

public HierarchicalTable(TableModel dm,
                         TableColumnModel cm)
Constructs a HierarchicalTable that is initialized with dm as the data model, cm as the column model, and a default selection model.

Parameters:
dm - the data model for the table. It should be an instance of HierarchicalTableModel.
cm - the column model for the table

HierarchicalTable

public HierarchicalTable(TableModel dm,
                         TableColumnModel cm,
                         ListSelectionModel sm)
Constructs a JTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model. If any of the parameters are null this method will initialize the table with the corresponding default model. The autoCreateColumnsFromModel flag is set to false if cm is non-null, otherwise it is set to true and the column model is populated with suitable TableColumns for the columns in dm.

Parameters:
dm - the data model for the table. It should be an instance of HierarchicalTableModel.
cm - the column model for the table
sm - the row selection model for the table

HierarchicalTable

public HierarchicalTable(int numRows,
                         int numColumns)
Constructs a JTable with numRows and numColumns of empty cells using DefaultTableModel. The columns will have names of the form "A", "B", "C", etc.

Since HierarchicalTable expects an instance of HierarchicalTableModel ex data model, this constructor creates nothing but a regular JTable if there is no subsequent call to setModel() to pass in a HierarchicalTableModel.

Parameters:
numRows - the number of rows the table holds
numColumns - the number of columns the table holds
See Also:
DefaultTableModel

HierarchicalTable

public HierarchicalTable(Vector<?> rowData,
                         Vector<?> columnNames)
Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames. The Vectors contained in rowData should contain the values for that row. In other words, the value of the cell at row 1, column 5 can be obtained with the following code:

((Vector)rowData.elementAt(1)).elementAt(5);

Since HierarchicalTable expects an instance of HierarchicalTableModel ex data model, this constructor creates nothing but a regular JTable if there is no subsequent call to setModel() to pass in a HierarchicalTableModel.

Parameters:
rowData - the data for the new table
columnNames - names of each column

HierarchicalTable

public HierarchicalTable(Object[][] rowData,
                         Object[] columnNames)
Constructs a JTable to display the values in the two dimensional array, rowData, with column names, columnNames. rowData is an array of rows, so the value of the cell at row 1, column 5 can be obtained with the following code:

 rowData[1][5]; 

All rows must be of the same length as columnNames.

Since HierarchicalTable expects an instance of HierarchicalTableModel ex data model, this constructor creates nothing but a regular JTable if there is no subsequent call to setModel() to pass in a HierarchicalTableModel.

Parameters:
rowData - the data for the new table
columnNames - names of each column
Method Detail

getActualUIClassID

public String getActualUIClassID()
Overrides:
getActualUIClassID in class CellSpanTable

setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class JideTable

handleMouseEvent

protected void handleMouseEvent(MouseEvent e)
There are too many ways to control when to expand and when to collapse. By default, the expand/collapse button will do the job if expandable column is a valid column index. If the expandable column is -1, double clicking on the column will expand/collapse the row. However you can always decide which way you want. You can either overwrite this method to implement another mouse event based handler or simply overwrite with an empty method then implement your own way.

Parameters:
e - the mouse event

isActualRowExpanded

public boolean isActualRowExpanded(int actualRow)
Return true if the row is expanded.

Specified by:
isActualRowExpanded in interface HierarchicalTableSupport
Parameters:
actualRow - the actual row index
Returns:
true if the row is expanded

isExpanded

public boolean isExpanded(int row)
Return true if the row is expanded. The row is the visual row.

Specified by:
isExpanded in interface HierarchicalTableSupport
Parameters:
row - the row index
Returns:
true if the row is expanded

isAnyExpanded

public boolean isAnyExpanded()
Return true if any row is expanded.

Returns:
true if any row is expanded

getHierarchicalColumnViewIndex

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

Specified by:
getHierarchicalColumnViewIndex in interface HierarchicalTableSupport
Returns:
the expandable column view index.

getHierarchicalColumn

public int getHierarchicalColumn()
Gets the hierarchical column. Hierarchical column is the column which has an expand/collapse button. Clicking on that button will show/hide the child component associated with that row.

Specified by:
getHierarchicalColumn in interface HierarchicalTableSupport
Returns:
the hierarchical column.

setHierarchicalColumn

public void setHierarchicalColumn(int hierarchicalColumn)
Sets the hierarchical column. Please note, this column index is the model column index. In the other word, when user rearranges the columns, the +/- icon will go with the column. If you prefer the +/- icon remains on the same view column index, you can override getHierarchicalColumnViewIndex() to return a view column index. For example, if you return 0, the +/- icon will always be at the first column no matter how you rearrange the columns.

Specified by:
setHierarchicalColumn in interface HierarchicalTableSupport
Parameters:
hierarchicalColumn - new hierarchical column. It should be a value between 0 and getColumnCount() - 1. Or -1 if you don't want to show any column to be hierarchical. Default value is 0.

getCellRenderer

public TableCellRenderer getCellRenderer(int row,
                                         int column)
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:
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 renderer for the column and row.

createHierarchicalTableCellRenderer

protected HierarchicalTableCellRenderer createHierarchicalTableCellRenderer()
Creates the HierarchicalTableCellRenderer.

Returns:
the HierarchicalTableCellRenderer.
Since:
3.5.1

toggleRow

public void toggleRow(int row)
Expands the specified row if it's not expanded or collapse the row if it's expanded already.

Specified by:
toggleRow in interface HierarchicalTableSupport
Parameters:
row - the row index to be toggled.

expandRow

public void expandRow(int row)
Expands the row if the row has child component. Please note each expanded child component is considered as a row if isHierarchical() in HierarhicalTableModel returns true. So the value passed in as row parameter could be different from the row in getChildComponent(int row).

Specified by:
expandRow in interface HierarchicalTableSupport
Parameters:
row - the row index

collapseRow

public void collapseRow(int row)
Collapse the row.

Specified by:
collapseRow in interface HierarchicalTableSupport
Parameters:
row - the row index

refreshRow

public void refreshRow(int row)
Refresh the row. If the row is expanded, refreshRow method will destroy current child component and recreate it. Since the expansion state doesn't change, there is no expand/collapse event fired in this case.

Specified by:
refreshRow in interface HierarchicalTableSupport
Parameters:
row - the row index

collapseAllRows

public void collapseAllRows()
Collapse all rows.

Specified by:
collapseAllRows in interface HierarchicalTableSupport

expandAllRows

public void expandAllRows()
Expands all rows as long as they are expandable.

Specified by:
expandAllRows in interface HierarchicalTableSupport

doLayout

public void doLayout()
Overrides:
doLayout in class JTable

getChildComponentAt

public Component getChildComponentAt(int row)
Gets the child component at the specified row index. If the row is not expanded, it will return null.

Parameters:
row - the row index.
Returns:
the child component. Null if the specified row is not expanded.

isPaintMarginGridMarginBackground

public boolean isPaintMarginGridMarginBackground()
Get the flag indicating if HierarchicalTable should paint the grids inside the MarginExpandablePanel to the color get from CategorizedTable.getMarginBackground().

By default, the flag is false to keep the original behavior. However, if you set the margin background differently with the grid color, you may need set this flag to true.

Returns:
true if the margin grid should be painted the same color with margin background. Otherwise false.
See Also:
CategorizedTable.getMarginBackground(), JTable.getGridColor(), JideTable.getGridColor(int)

setPaintMarginGridMarginBackground

public void setPaintMarginGridMarginBackground(boolean paintMarginGridMarginBackground)
Set the flag indicating if HierarchicalTable should paint the grids inside the MarginExpandablePanel to the color get from CategorizedTable.getMarginBackground().

Parameters:
paintMarginGridMarginBackground - the flag
See Also:
isPaintMarginGridMarginBackground()

childComponentResized

protected void childComponentResized()
The action to take while child component is resized.

By default, it will invoke doLayout(). However, if you have any concern about the performance, you could override this method to invoke invalidate() only.


isAutoRefreshOnRowUpdate

public boolean isAutoRefreshOnRowUpdate()
Checks if refreshRow() is called when row updated event is fired.

Returns:
true or false.

setAutoRefreshOnRowUpdate

public void setAutoRefreshOnRowUpdate(boolean autoRefreshOnRowUpdate)
Sets the flag autoRefreshOnRowUpdate. If the flag is true, refreshRow method will be called when table model fireTableRowsUpdated. Otherwise, you will have to call refreshRow if the child component of that row is changed. Default is true.

Parameters:
autoRefreshOnRowUpdate - true or false

isSingleExpansion

public boolean isSingleExpansion()
Returns true if only one row can be expanded at a time.

Returns:
true if only one row can be expanded at a time.

setSingleExpansion

public void setSingleExpansion(boolean singleExpansion)
Sets the singleExpansion attribute. If singleExpansion is true, only one row can be expanded at a time.

Parameters:
singleExpansion - true or false.

isMouseEnabled

public boolean isMouseEnabled()
Returns true if default mouse listener is installed to expand/collapse rows.

Returns:
true if only one row can be expanded at a time.

setMouseEnabled

public void setMouseEnabled(boolean mouseEnabled)
Sets the mouseEnabled attribute. If mouseEnabled is true, mouse clicks on +/- button will expand or collapse the row if getHierarchicalColumnViewIndex() getHierarchicalColumnViewIndex() == -1, double clicking will expand/collapse the row. However if mouseEnabled is false, no mouse listener will be added. You need to add your own mouse listener or some other ways to expand or collapse the row.

Parameters:
mouseEnabled - true or false

getComponentFactory

public HierarchicalTableComponentFactory getComponentFactory()
Gets the component factory that will create the child component of HierarchicalTable.

Returns:
the component factory.

setComponentFactory

public void setComponentFactory(HierarchicalTableComponentFactory factory)
Sets the component factory that will create the child component of HierarchicalTable.

Parameters:
factory - the new component factory.

createRowHeights

protected RowHeights createRowHeights()
Overrides:
createRowHeights in class JideTable

isRowHeightChanged

protected boolean isRowHeightChanged(int row,
                                     int newHeight)
Description copied from class: JideTable
The method will check if the new height is different with current height. The method is called by TableUtils.autoResizeRow(javax.swing.JTable, int, int).

Overrides:
isRowHeightChanged in class JideTable
Parameters:
row - the row to be checked
newHeight - new height of the row, most likely from JideTable.calculateRowHeight(int)
Returns:
True if current row height is not the same with the new height. Otherwise false.

getActualRowHeight

public int getActualRowHeight(int row)
As we overridden getRowModel(), JideTable.getRowHeight(int) will now return the row height considering the child component height. So this method will give you a way to get the actual row height without the child component.

Specified by:
getActualRowHeight in interface HierarchicalTableSupport
Overrides:
getActualRowHeight in class CellSpanTable
Parameters:
row - the row index
Returns:
the actual row height without the child component.

setActualRowHeight

public void setActualRowHeight(int row,
                               int rowHeight)
Sets the actual row height without the child component.

Specified by:
setActualRowHeight in interface HierarchicalTableSupport
Parameters:
row - the row index.
rowHeight - new actual row height.

muteDefaultKeyStroke

protected void muteDefaultKeyStroke()
Overrides:
muteDefaultKeyStroke in class CellSpanTable

createDelegateAction

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

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. We reused the listener and event class for JTree to avoid duplicate code. However since there is not TreeNode concept in HierarchicalTable and there is one level deep, the TreePath object in the TreeExpansionEvent only has one element which is the row index.

Parameters:
tel - a TreeExpansionListener that will be notified when a tree node 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 JTree with addTreeExpansionListener().

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

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.

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

editCellAt

public boolean editCellAt(int row,
                          int column,
                          EventObject e)
Overrides to make sure the editor is set the correct height when there is expanded row.

Overrides:
editCellAt in class CellSpanTable
Parameters:
row - the row to be edited
column - the column to be edited
e - event to pass into shouldSelectCell; note that as of Java 2 platform v1.2, the call to shouldSelectCell is no longer made
Returns:
false if for any reason the cell cannot be edited

rolloverCellAt

public boolean rolloverCellAt(int row,
                              int column)
Description copied from class: JideTable
Makes the cell enters editing mode without forcing the other cell editor, if any, to stop editing.

Overrides:
rolloverCellAt in class CellSpanTable
Parameters:
row - the row index.
column - the column index.
Returns:
true if the action is successful.

getCellRect

public Rectangle getCellRect(int rowIndex,
                             int columnIndex,
                             boolean includeSpacing)
Overrides:
getCellRect in class CellSpanTable

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.

changeSelection

public void changeSelection(int rowIndex,
                            int columnIndex,
                            boolean toggle,
                            boolean extend)
Description copied from class: NavigableTable
Override the default implementation to adjust the selection avoiding the non-navigable cells. This implementation works for keyboard events only, assuming the direction from the previous anchor selection. Mouse events on non-navigable cells are blocked in the mouse input listener.

This implementation uses the following conventions:

Specified by:
changeSelection in interface TableAdapter
Overrides:
changeSelection in class NavigableTable
Parameters:
rowIndex - Affects the selection at row
columnIndex - Affects the selection at column
toggle - See description above
extend - If true, extend the current selection

isVariousRowHeights

public boolean isVariousRowHeights()
Description copied from class: JideTable
Is the table has various row height on each row. There is no setter for this property. The only way to change it is to override to return a different value. We did this way because we don't think a table should by nature either has various row heights or the same row heights. So you should know beforehand if the table has the same or different row heights thus overriding is a better way.

For example, in the case of HierarchicalTable, we override it to always return true.

Overrides:
isVariousRowHeights in class JideTable
Returns:
true if JideTable.isRowAutoResizes() is true.

getChildComponentResizeListener

protected ComponentListener getChildComponentResizeListener()
Get the child component listener.

Returns:
the child component listener.

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.

Specified by:
getHorizontalLegPosition in interface HierarchicalTableSupport
Parameters:
cellHeight - the new cell height
Returns:
the horizontal leg y position.

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.

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.

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

JIDE 3.5.15