Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.table.group
Class TreeTableHeader

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.table.JTableHeader
                  extended by com.citra.table.AdvancedTableHeader
                      extended by com.citra.table.GroupTableHeader
                          extended by com.citra.filter.FilterTableHeader
                              extended by com.citra.table.group.TreeTableHeader
All Implemented Interfaces:
GroupTableColumnModelListener, VetoableTableColumnModelListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, TableColumnModelListener
Direct Known Subclasses:
PivotTableHeader

public class TreeTableHeader
extends FilterTableHeader

TreeTableHeader is a JTableHeader component that is able to display table columns in a hierarchical structure. The structure is defined by a TreeTableColumnModel, while the visible columns are stored in a TreeTableColumnModelAdapter.

Since:
3.4
See Also:
Serialized Form

Nested Class Summary
protected  class TreeTableHeader.CachingHeaderControl
          CachingHeaderControl caches tree header renderers and components returned by them.
 
Nested classes/interfaces inherited from class javax.swing.table.JTableHeader
JTableHeader.AccessibleJTableHeader
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Cursor defaultHeaderCursor
          the header's default cursor
protected  boolean delayed
          boolean flag that determines whether events received from the treemodel will be added to the swing event queue.
protected  TreeTableHeader.CachingHeaderControl headerControl
          provides caching for tree header renderers and components returned by them.
protected  boolean hideColumnOnExpansion
          flag that controls a parent column's visibility when expanded
protected  Dimension prefSize
          the preferred size of the tree header
protected  TreeTableHeaderRendererFactory treeHeaderFactory
          the factory for creating tree header renderers
protected  TableCellRendererWrapperFactory wrapperFactory
          the renderer wrapper factory for tree-columns
 
Fields inherited from class com.citra.filter.FilterTableHeader
callBack
 
Fields inherited from class com.citra.table.GroupTableHeader
allowGroupColumnReordering, allowGroupReordering, factory, groupTableColumnModel
 
Fields inherited from class com.citra.table.AdvancedTableHeader
factories
 
Fields inherited from class javax.swing.table.JTableHeader
columnModel, draggedColumn, draggedDistance, reorderingAllowed, resizingAllowed, resizingColumn, table, updateTableInRealTime
 
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
TreeTableHeader()
          Constructs a TreeTableHeader.
TreeTableHeader(TreeTableColumnModel model)
          Constructs a TreeTableHeader.
TreeTableHeader(TreeTableColumnModelAdapter cm)
          Constructs a TreeTableHeader.
 
Method Summary
protected  boolean canMove(int fromIndex, int toIndex)
          Determines whether the column at fromIndex can be moved to toIndex. By default, this method returns true. You will need to override it in order to define conditions for which columns cannot be moved.
protected  void columnsChanged()
          Notification that the structure of the entire column model has changed.
protected  TableColumnModel createDefaultColumnModel()
          Creates a new instance of DefaultVetoableColumnModel.
protected  TreeTableHeaderRendererFactory createDefaultTreeHeaderFactory()
          Creates and returns the default factory for creating TreeTableHeaderRenderers.
protected  TableCellRendererWrapperFactory createWrapperFactory()
          Creates the renderer wrapper factory for tree-columns that will be installed on the header.
protected  void doProcessMouseMotionEvent(MouseEvent e)
          Processes mouse motion events, such as MouseEvent.MOUSE_DRAGGED.
 boolean getAllowGroupColumnReordering()
          Determines whether group columns can be reordered with the mouse.
 Cursor getDefaultHeaderCursor()
          Retrieves the default header's cursor.
 boolean getDelayed()
          Returns true if events received from the treemodel are to be added to the swing event queue.
 boolean getHideColumnOnExpansion()
          Determines a parent column's visibility when expanded.
 Dimension getPreferredSize()
          If the preferredSize has been set to a non-null value just returns it.
 JTree getTree()
          Returns the associated tree.
 TreeTableHeaderRendererFactory getTreeHeaderFactory()
          Retrieves the factory for creating TreeTableHeaderRenderers.
 TreeTableColumnModel getTreeTableColumnModel()
          Convenience method to retrieve the treetable column model.
 TreeTableColumnModelAdapter getTreeTableColumnModelAdapter()
          Convenience method to retrieve the treetable model adapter.
protected  boolean handleEvent(MouseEvent e, Component comp)
          Handles a mouse event on the header. This method is called before the event is propagated to any mouse listeners.
protected  void nodeCollapsed(TreePath path)
          Notification that columns at the specified path were collapsed.
protected  void nodeExpanded(TreePath path)
          Notification that columns at the specified path were expanded.
protected  void nodeExpanded(TreePath path, boolean checkExpansions)
          Notification that columns at the specified path were expanded.
protected  void nodesChanged(TreeModelEvent e)
          Notification that columns at the specified path have changed.
protected  void nodesInserted(TreeModelEvent e)
          Notification that columns at the specified path have been added.
protected  void nodesRemoved(TreeModelEvent e)
          Notification that columns at the specified path have been removed.
 void revalidate()
          Supports deferred automatic layout.
 void setColumnModel(TableColumnModel newModel)
          Sets the column model for this table to newModel and registers for listener notifications from the new column model.
 void setDefaultHeaderCursor(Cursor cursor)
          Assigns the default headers' cursor.
 void setDelayed(boolean delayed)
          Sets the delay property, which if true, events received from the treemodel are to be added to the swing event queue.
 void setFactory(TableCellRendererFactory newFactory)
          Assigns a new table cell renderer factory.
 void setHideColumnOnExpansion(boolean hideColumnOnExpansion)
          Determines a parent column's visibility when expanded.
 void setTreeHeaderFactory(TreeTableHeaderRendererFactory treeHeaderFactory)
          Assigns a new factory for creating TreeTableHeaderRenderers.
protected  void structureChanged(TreeModelEvent e)
          Notification that the structure of the columns at the specified path has changed.
 void updateUI()
          Notification from the UIManager that the look and feel (L&F) has changed. Replaces the current UI object with the latest version from the UIManager.
 void validate()
          Validates this container and all of its subcomponents.
 
Methods inherited from class com.citra.filter.FilterTableHeader
getCallBack, setCallBack
 
Methods inherited from class com.citra.table.GroupTableHeader
addGroupColumn, columnRemoved, columnWillBeMoved, createDefaultGroupColumnModel, createDefaultGroupRenderer, getAllowGroupReordering, getDefaultGroupRenderer, getFactory, getGroupColumn, getGroupColumnModel, getGroupColumnState, getGroupLevel, getPathToRoot, getPathToRoot, getPreferredHeight, getResizingAllowed, groupColumnAtPoint, groupColumnsChanged, groupColumnsInserted, groupColumnsRemoved, groupLevelAtPoint, groupStructureChanged, initFactories, isReorderingAllowed, isReorderingAllowed, prepareRenderer, removeGroupColumn, setAllowGroupColumnReordering, setAllowGroupReordering, setDefaultGroupRenderer, setGroupColumnModel, setGroupColumnState, setResizingColumn, setTable
 
Methods inherited from class com.citra.table.AdvancedTableHeader
addNotify, addWrapperFactory, columnAdded, columnWillBeAdded, columnWillBeRemoved, doProcessMouseEvent, getComponentAtPoint, getDraggedDistance, getReorderingAllowed, getToolTipLocation, getToolTipText, initializeLocalVars, processMouseEvent, processMouseMotionEvent, removeWrapperFactory, setDraggedColumn
 
Methods inherited from class javax.swing.table.JTableHeader
columnAtPoint, columnMarginChanged, columnMoved, columnSelectionChanged, createDefaultRenderer, getAccessibleContext, getColumnModel, getDefaultRenderer, getDraggedColumn, getHeaderRect, getResizingColumn, getTable, getUI, getUIClassID, getUpdateTableInRealTime, paramString, resizeAndRepaint, setDefaultRenderer, setDraggedDistance, setReorderingAllowed, setResizingAllowed, setUI, setUpdateTableInRealTime
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hideColumnOnExpansion

protected boolean hideColumnOnExpansion
flag that controls a parent column's visibility when expanded


prefSize

protected Dimension prefSize
the preferred size of the tree header


delayed

protected boolean delayed
boolean flag that determines whether events received from the treemodel will be added to the swing event queue.


defaultHeaderCursor

protected Cursor defaultHeaderCursor
the header's default cursor


treeHeaderFactory

protected TreeTableHeaderRendererFactory treeHeaderFactory
the factory for creating tree header renderers


headerControl

protected TreeTableHeader.CachingHeaderControl headerControl
provides caching for tree header renderers and components returned by them.


wrapperFactory

protected TableCellRendererWrapperFactory wrapperFactory
the renderer wrapper factory for tree-columns

Constructor Detail

TreeTableHeader

public TreeTableHeader()
Constructs a TreeTableHeader.


TreeTableHeader

public TreeTableHeader(TreeTableColumnModel model)
Constructs a TreeTableHeader.


TreeTableHeader

public TreeTableHeader(TreeTableColumnModelAdapter cm)
Constructs a TreeTableHeader.

Method Detail

canMove

protected boolean canMove(int fromIndex,
                          int toIndex)
Determines whether the column at fromIndex can be moved to toIndex. By default, this method returns true. You will need to override it in order to define conditions for which columns cannot be moved.

Overrides:
canMove in class GroupTableHeader
Parameters:
fromIndex - the current view index of the column being moved
toIndex - the index the column is being moved to
Returns:
true if the column can move, false otherwise

columnsChanged

protected void columnsChanged()
Notification that the structure of the entire column model has changed.


createDefaultColumnModel

protected TableColumnModel createDefaultColumnModel()
Creates a new instance of DefaultVetoableColumnModel.

Returns the default column model object which is a DefaultTableColumnModel. A subclass can override this method to return a different column model object

Overrides:
createDefaultColumnModel in class AdvancedTableHeader
Returns:
the default column model object

createDefaultTreeHeaderFactory

protected TreeTableHeaderRendererFactory createDefaultTreeHeaderFactory()
Creates and returns the default factory for creating TreeTableHeaderRenderers.

Returns:
a new instance of the default tree header factory

createWrapperFactory

protected TableCellRendererWrapperFactory createWrapperFactory()
Creates the renderer wrapper factory for tree-columns that will be installed on the header.

Returns:
the renderer wrapper factory

doProcessMouseMotionEvent

protected void doProcessMouseMotionEvent(MouseEvent e)
Processes mouse motion events, such as MouseEvent.MOUSE_DRAGGED.

Overrides:
doProcessMouseMotionEvent in class AdvancedTableHeader
Parameters:
e - the 'converted' mouse event

getAllowGroupColumnReordering

public boolean getAllowGroupColumnReordering()
Determines whether group columns can be reordered with the mouse. Returns true if group columns can be reordered with the mouse, false otherwise

Overrides:
getAllowGroupColumnReordering in class GroupTableHeader

getDefaultHeaderCursor

public Cursor getDefaultHeaderCursor()
Retrieves the default header's cursor.

Returns:
the default header's cursor

getDelayed

public boolean getDelayed()
Returns true if events received from the treemodel are to be added to the swing event queue.

Returns:
true if events received from the treemodel are to be added to the swing event queue, false otherwise

getHideColumnOnExpansion

public boolean getHideColumnOnExpansion()
Determines a parent column's visibility when expanded.

Returns:
true if the parent column will be hidden when expanded, false otherwise

getPreferredSize

public Dimension getPreferredSize()
If the preferredSize has been set to a non-null value just returns it. If the UI delegate's getPreferredSize method returns a non null value then return that; otherwise defer to the component's layout manager.

Overrides:
getPreferredSize in class JComponent
Returns:
the value of the preferredSize property
See Also:
JComponent.setPreferredSize(java.awt.Dimension), ComponentUI

getTree

public JTree getTree()
Returns the associated tree.

Returns:
the tree

getTreeHeaderFactory

public TreeTableHeaderRendererFactory getTreeHeaderFactory()
Retrieves the factory for creating TreeTableHeaderRenderers.

Returns:
the tree header factory

getTreeTableColumnModel

public TreeTableColumnModel getTreeTableColumnModel()
Convenience method to retrieve the treetable column model.

Returns:
the treetable column model

getTreeTableColumnModelAdapter

public TreeTableColumnModelAdapter getTreeTableColumnModelAdapter()
Convenience method to retrieve the treetable model adapter.

Returns:
the treetable model adapter.

handleEvent

protected boolean handleEvent(MouseEvent e,
                              Component comp)
Handles a mouse event on the header. This method is called before the event is propagated to any mouse listeners.

Overrides:
handleEvent in class FilterTableHeader
Parameters:
e - the mouse event that triggered the method
comp - the drawn table cell component
Returns:
true, if the event should be consumed, false otherwise

nodeCollapsed

protected void nodeCollapsed(TreePath path)
Notification that columns at the specified path were collapsed.

Parameters:
path - the column path at which columns were collapsed

nodeExpanded

protected void nodeExpanded(TreePath path)
Notification that columns at the specified path were expanded.

Parameters:
path - the column path at which columns were expanded

nodeExpanded

protected void nodeExpanded(TreePath path,
                            boolean checkExpansions)
Notification that columns at the specified path were expanded.

Parameters:
path - the column path at which columns were expanded
checkExpansions - flag to indicate whether to generate nodeExpanded events for expanded columns beneath the specified path

nodesChanged

protected void nodesChanged(TreeModelEvent e)
Notification that columns at the specified path have changed.

Parameters:
e - the event generating the notification

nodesInserted

protected void nodesInserted(TreeModelEvent e)
Notification that columns at the specified path have been added.

Parameters:
e - the event generating the notification

nodesRemoved

protected void nodesRemoved(TreeModelEvent e)
Notification that columns at the specified path have been removed.

Parameters:
e - the event generating the notification

revalidate

public void revalidate()
Supports deferred automatic layout.

Calls invalidate and then adds this component's validateRoot to a list of components that need to be validated. Validation will occur after all currently pending events have been dispatched. In other words after this method is called, the first validateRoot (if any) found when walking up the containment hierarchy of this component will be validated. By default, JRootPane, JScrollPane, and JTextField return true from isValidateRoot.

This method will automatically be called on this component when a property value changes such that size, location, or internal layout of this component has been affected. This automatic updating differs from the AWT because programs generally no longer need to invoke validate to get the contents of the GUI to update.

Overrides:
revalidate in class JComponent
See Also:
Component.invalidate(), Container.validate(), JComponent.isValidateRoot(), RepaintManager#addInvalidComponent

setColumnModel

public void setColumnModel(TableColumnModel newModel)
Sets the column model for this table to newModel and registers for listener notifications from the new column model.

Overrides:
setColumnModel in class GroupTableHeader
Parameters:
newModel - the new data source for this table
See Also:
JTableHeader.getColumnModel()

setDefaultHeaderCursor

public void setDefaultHeaderCursor(Cursor cursor)
Assigns the default headers' cursor.

Parameters:
cursor - the default header cursor to assign

setDelayed

public void setDelayed(boolean delayed)
Sets the delay property, which if true, events received from the treemodel are to be added to the swing event queue.

Parameters:
delayed - set to true if events received from the treemodel are to be added to the swing event queue.

setFactory

public void setFactory(TableCellRendererFactory newFactory)
Assigns a new table cell renderer factory.

Overrides:
setFactory in class GroupTableHeader
Parameters:
newFactory - the new table cell renderer factory to assign.

setHideColumnOnExpansion

public void setHideColumnOnExpansion(boolean hideColumnOnExpansion)
Determines a parent column's visibility when expanded.

Parameters:
hideColumnOnExpansion - true if the parent column will be hidden when expanded, false otherwise

setTreeHeaderFactory

public void setTreeHeaderFactory(TreeTableHeaderRendererFactory treeHeaderFactory)
Assigns a new factory for creating TreeTableHeaderRenderers.

Parameters:
treeHeaderFactory - the new factory to assign

structureChanged

protected void structureChanged(TreeModelEvent e)
Notification that the structure of the columns at the specified path has changed.

Parameters:
e - the event generating the notification

updateUI

public void updateUI()
Notification from the UIManager that the look and feel (L&F) has changed. Replaces the current UI object with the latest version from the UIManager.

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

validate

public void validate()
Validates this container and all of its subcomponents.

The validate method is used to cause a container to lay out its subcomponents again. It should be invoked when this container's subcomponents are modified (added to or removed from the container, or layout-related information changed) after the container has been displayed.

Overrides:
validate in class Container
See Also:
Container.add(java.awt.Component), Component.invalidate(), JComponent.revalidate()

Copyright © 2011 Citra Technologies. All Rights Reserved.