JIDE 3.5.15

com.jidesoft.grid
Class AutoFilterTableHeader

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.jidesoft.grid.DraggingTableHeader
                      extended by com.jidesoft.grid.CellStyleTableHeader
                          extended by com.jidesoft.grid.SortableTableHeader
                              extended by com.jidesoft.grid.EditableTableHeader
                                  extended by com.jidesoft.grid.AutoFilterTableHeader
All Implemented Interfaces:
FilterableTableModelListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, CellEditorListener, TableColumnModelListener
Direct Known Subclasses:
GroupTableHeader, NestedTableHeader

public class AutoFilterTableHeader
extends EditableTableHeader
implements FilterableTableModelListener, PropertyChangeListener

AutoFilterTableHeader implements auto-filter feature. Each column header has a combobox-like control to allow user selecting certain values to be filtered from the list. The list contains the possible values for that column as well as other customized items. Each item represents a Filter class that will be added to FilterableTableModel when selected.

AutoFilterTableHeader works with any FilterableTableModel. If the table passed to the constructor of AutoFilterTableHeader already defined a FilterableTableModel, it will use that FilterableTableModel. Otherwise, it will create a new FilterableTableModel, wrapping the current table's table model and reset the table's table model to the newly created FilterableTableModel.

There are three kinds of Filters AutoFilterTableHeader will use. They are SingleValueFilter, MultipleValuesFilter and DynamicTableFilter. When isAllowMultipleValues() returns false and user selects a value from AutoFilterTableHeader's drop down value list, SingleValueFilter will be created and added to that column as the filter. DynamicTableFilter could also be used in this case when you call AutoFilterBox.addDynamicTableFilter(DynamicTableFilter). This method call will add new custom filter to the header which will appear as a new item under "All" item in the drop down value list. If isAllowMultipleValues() returns true, MultipleValuesFilter will be the only filter that is used to allow multiple values as the filter values.

AutoFilterTableHeader also detects filters added outside AutoFilterTableHeader. For example, if isAllowMultipleValues returns false, you can add a SingleValueFilter to the column, or if isAllowMultipleValues returns true, you can add a MultipleValuesFilter. After you did it, AutoFilterTableHeader will automatically update the display to show a filter name or filter name to indicate the column has a filter.

See Also:
Serialized Form

Nested Class Summary
 
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean _autoFilterEnabled
           
protected  IFilterableTableModel _filterableTableModel
           
static String CLIENT_PROPERTY_CUSTOM_FILTER_EDITOR_TYPE
          Set this client property to choose a specific editor.
static String CUSTOM_FILTER_EDITOR_TYPE_TABLE_CUSTOM_FILTER_EDITOR
           
static String PROPERTY_ACCEPT_TEXT_INPUT
           
static String PROPERTY_AUTO_FILTER_ENABLED
           
static String PROPERTY_USE_NATIVE_CELL_RENDERER
           
 
Fields inherited from class com.jidesoft.grid.EditableTableHeader
_cellEditor, _defaultEditor, _editingColumn, _editorComp, HEADER_ROW
 
Fields inherited from class com.jidesoft.grid.SortableTableHeader
PROPERTY_SHOW_SORT_ARROW
 
Fields inherited from class com.jidesoft.grid.CellStyleTableHeader
_cellStyleList
 
Fields inherited from class com.jidesoft.grid.DraggingTableHeader
PROPERTY_DRAGGED_COLUMN, PROPERTY_DRAGGED_DISTANCE, PROPERTY_RESIZING_COLUMN
 
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
  AutoFilterTableHeader(JTable table)
          Creates AutoFilterTableHeader.
protected AutoFilterTableHeader(TableColumnModel columnModel)
          The constructor.
 
Method Summary
 void clearFilters()
          Clears all filters created by the AutoFilterTableHeader.
 void columnMarginChanged(ChangeEvent e)
           
protected  TableCellEditor createDefaultEditor()
          Overrides to create an AutoFilterTableHeaderEditor.
protected  IFilterableTableModel createDefaultFilterableTableModel(TableModel model)
          Creates the FilterableTableModel.
protected  TableCellRenderer createDefaultRenderer()
          Overrides to create an AutoFilterTableHeaderRenderer.
protected  TableHeaderCellDecorator createFilterableTableHeaderCellDecorator()
          Creates a TableHeaderCellDecorator instance to paint the filter button and icon.
protected  IFilterableTableModel createFilterableTableModel(TableModel model)
          Creates the FilterableTableModel to be used by AutoFilterTableHeader.
protected  void customizeAutoFilterBox(AutoFilterBox autoFilterBox)
          Customizes the AutoFilterBox.
 void editingStopped(ChangeEvent e)
           
 void filterableTableModelChanged(FilterableTableModelEvent event)
          Called whenever the FilterableTableModel's filtered is changed.
protected  String formatColumnTitle(int modelIndex, String columnName, Filter[] filters)
          Formats the string when the filter name is displayed.
 String getActualUIClassID()
          Returns a string that specifies the name of the L&F class that renders this component.
 TableCellRenderer getAutoFilterTableHeaderRenderer()
          Gets the header renderer for auto filter feature.
 TableHeaderCellDecorator getFilterableTableHeaderCellDecorator()
          Gets the TableHeaderCellDecorator instance to paint the filter button and icon.
 IFilterableTableModel getFilterableTableModel()
          Gets the FilterableTableModel used by this AutoFilterTableHeader.
protected  IFilterableTableModel getFilterableTableModel(AutoFilterBox box)
          Gets the FilterableTableModel used by the AutoFilterBox.
protected  ImageIcon getFilterIcon(int columnIndex, boolean mouseOverPaintArea, boolean hasFilter)
          Gets the filter icon to be painted in the AutoFilterTableHeader if isUseNativeHeaderRenderer() returns true.
 String getFormattedColumnName(int columnIndex)
          Get formatted column name based on current filters for header and tooltip text.
 String getToolTipText(MouseEvent event)
          Gets the tool tip text from ToolTipSupport
 String getUIDelegateClassID()
          Returns a string that specifies the name of the UIDelegate class that paints this component.
protected  void initTable(JTable table)
          Initializes the table.
 boolean isAcceptTextInput()
          Gets the flag indicating if this header accepts text input.
 boolean isAllowMultipleValues()
          Checks if the AutoFilterTableHeader allows multiple values as the filter.
 boolean isAllowMultipleValues(int columnIndex)
          Checks if the AutoFilterTableHeader allows multiple values as the filter.
 boolean isAutoFilterEnabled()
          Gets the flag indicating if auto filter feature is enabled for the entire header.
protected  boolean isAutoRequestFocus()
          If the editor requests focus when starts editing.
 boolean isCellEditable(int columnIndex)
          Returns true if the header cell at index is editable.
 boolean isPreferSelectedValues()
          Get the flag indicating if selected possible values will be used or filtered possible values.
 boolean isRolloverEnabled()
          Checks if rollover is enabled.
 boolean isShowFilterIcon()
          Checks if the filter icon is visible on the box as part of the title.
 boolean isShowFilterName()
          Checks if the filter name is visible on the box as part of the title.
 boolean isShowFilterNameAsToolTip()
          Checks if the filter name is displayed as tooltip on the table header.
 boolean isUseNativeHeaderRenderer()
          Gets the flag indicating if the native header renderer will be used.
 void propertyChange(PropertyChangeEvent evt)
           
 void setAcceptTextInput(boolean acceptTextInput)
          Sets the flag indicating if the header accepts text input.
 void setAllowMultipleValues(boolean allowMultipleValues)
          Set the flag if the AutoFilterTableHeader allows multiple values as the filter.
 void setAutoFilterEnabled(boolean autoFilterEnabled)
          Sets the flag indicating if auto filter feature is enabled for the entire header.
 void setPreferSelectedValues(boolean preferSelectedPossibleValues)
          Set the flag indicating if selected possible values will be used or filtered possible values.
 void setShowFilterIcon(boolean showFilterIcon)
          Sets the flag if the filter icon is shown on the title.
 void setShowFilterName(boolean showFilterName)
          Sets the flag if the filter name is shown on the title.
 void setShowFilterNameAsToolTip(boolean showFilterNameAsToolTip)
          Sets the flag if the filter name is displayed as tooltip on the table header.
 void setShowSortArrow(boolean showSortArrow)
          Sets the flag if the sort arrow is shown on the header.
 void setTable(JTable table)
           
 void setUseNativeHeaderRenderer(boolean useNativeHeaderRenderer)
          Sets the flag indicating if the native header renderer will be used.
protected  void tableModelChanged(JTable table)
          This method will be called when TableModel on JTable is changed.
 
Methods inherited from class com.jidesoft.grid.EditableTableHeader
cancelEditing, customizeEditorComponent, editCellAt, editCellAt, editingCanceled, getCellEditor, getCellEditor, getDefaultEditor, getEditingColumn, getEditorComponent, isClickToStartEditing, isEditing, prepareEditor, removeEditor, removeNotify, resizeAndRepaint, setCellEditor, setClickToStartEditing, setDefaultEditor, setDraggedColumn, setEditingColumn, setRolloverEnabled, stopEditing
 
Methods inherited from class com.jidesoft.grid.SortableTableHeader
createSortableTableHeaderCellDecorator, createSortIcon, getSortableTableHeaderCellDecorator, isShowSortArrow, paintComponent, paintSortArrow, paintSortArrows
 
Methods inherited from class com.jidesoft.grid.CellStyleTableHeader
addCellDecorator, addCellDecorator, addCellStyleCustomizer, clearCellStyleCustomizers, collectCellStyles, createToolTip, customizeRendererComponent, getActualHeaderY, getCellDecorators, getCellStyleAt, getCellStyleCustomizers, getDefaultCursor, mergeCellStyles, originalColumnAtPoint, releaseRendererComponent, removeCellDecorator, removeCellStyleCustomizer, setCursor, setDefaultRenderer, updateUI
 
Methods inherited from class com.jidesoft.grid.DraggingTableHeader
getPreferredSize, setDraggedDistance, setResizingColumn
 
Methods inherited from class javax.swing.table.JTableHeader
columnAdded, columnAtPoint, columnMoved, columnRemoved, columnSelectionChanged, createDefaultColumnModel, getAccessibleContext, getColumnModel, getDefaultRenderer, getDraggedColumn, getDraggedDistance, getHeaderRect, getReorderingAllowed, getResizingAllowed, getResizingColumn, getTable, getUI, getUIClassID, getUpdateTableInRealTime, initializeLocalVars, paramString, setColumnModel, setReorderingAllowed, setResizingAllowed, setUI, setUpdateTableInRealTime
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, 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, 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, processKeyBinding, 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, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, 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

_filterableTableModel

protected IFilterableTableModel _filterableTableModel

_autoFilterEnabled

protected boolean _autoFilterEnabled

PROPERTY_ACCEPT_TEXT_INPUT

public static final String PROPERTY_ACCEPT_TEXT_INPUT
See Also:
Constant Field Values

PROPERTY_USE_NATIVE_CELL_RENDERER

public static final String PROPERTY_USE_NATIVE_CELL_RENDERER
See Also:
Constant Field Values

PROPERTY_AUTO_FILTER_ENABLED

public static final String PROPERTY_AUTO_FILTER_ENABLED
See Also:
Constant Field Values

CLIENT_PROPERTY_CUSTOM_FILTER_EDITOR_TYPE

public static final String CLIENT_PROPERTY_CUSTOM_FILTER_EDITOR_TYPE
Set this client property to choose a specific editor. If this client property is set to CUSTOM_FILTER_EDITOR_TYPE_TABLE_CUSTOM_FILTER_EDITOR, TableCustomFIlterEditor will be used. Otherwise, CustomFilterEditor will be used

Since:
3.4.3
See Also:
Constant Field Values

CUSTOM_FILTER_EDITOR_TYPE_TABLE_CUSTOM_FILTER_EDITOR

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

AutoFilterTableHeader

protected AutoFilterTableHeader(TableColumnModel columnModel)
The constructor.

Parameters:
columnModel - the column model
Since:
3.1.0

AutoFilterTableHeader

public AutoFilterTableHeader(JTable table)
Creates AutoFilterTableHeader. By default, rollover is enabled.

Parameters:
table - the table to install this AutoFilterTableHeader. The table model of this table could be FilterableTableModel or if it is a TableModelWrapper, it could have a nested FilterableTableModel. In either case, we will use the FilterableTableModel and add filters to it. If there is no FilterableTableModel, we will create one and wrap it around the table model returned from table.getModel(). If so, after creating the AutoFilterTableHeader, table.getModel() will return a FilterableTableModel. FilterableTableModel's getActualModel() will be the old tableModel.
Method Detail

createFilterableTableHeaderCellDecorator

protected TableHeaderCellDecorator createFilterableTableHeaderCellDecorator()
Creates a TableHeaderCellDecorator instance to paint the filter button and icon.

Returns:
a FilterableTableHeaderCellDecorator instance.
Since:
3.1.0

getFilterableTableHeaderCellDecorator

public TableHeaderCellDecorator getFilterableTableHeaderCellDecorator()
Gets the TableHeaderCellDecorator instance to paint the filter button and icon.

Returns:
a FilterableTableHeaderCellDecorator instance.

setTable

public void setTable(JTable table)
Overrides:
setTable in class JTableHeader

getUIDelegateClassID

public String getUIDelegateClassID()
Returns a string that specifies the name of the UIDelegate class that paints this component.

Overrides:
getUIDelegateClassID in class EditableTableHeader
Returns:
the string "TableHeader.autoFilterTableHeaderUIDelegate"
Since:
3.1.0

getActualUIClassID

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

Overrides:
getActualUIClassID in class EditableTableHeader
Returns:
the string "SortableTableHeaderUI"

getAutoFilterTableHeaderRenderer

public TableCellRenderer getAutoFilterTableHeaderRenderer()
Gets the header renderer for auto filter feature.

Returns:
default renderer if isUseNativeHeaderRenderer() returns true. Otherwise returns AutoFilterTableHeaderRenderer
Since:
3.1.0

createDefaultRenderer

protected TableCellRenderer createDefaultRenderer()
Overrides to create an AutoFilterTableHeaderRenderer. Below is the default code in case you need to override it to you create your own renderer.
 if (isAutoFilterEnabled() && !isUseNativeHeaderRenderer()) {
     return new AutoFilterTableHeaderRenderer(){
         protected void customizeAutoFilterBox(AutoFilterBox autoFilterBox) {
             super.customizeAutoFilterBox(autoFilterBox);
             AutoFilterTableHeader.this.customizeAutoFilterBox(autoFilterBox);
             autoFilterBox.applyComponentOrientation(AutoFilterTableHeader.this.getComponentOrientation());
         }
     };
 }
 else {
     return super.createDefaultRenderer();
 }
 

Overrides:
createDefaultRenderer in class JTableHeader
Returns:
an AutoFilterTableHeaderRenderer.

createDefaultEditor

protected TableCellEditor createDefaultEditor()
Overrides to create an AutoFilterTableHeaderEditor. Below is the default code in case you need to override it to you create your own editor.
 if (isAutoFilterEnabled()) {
    return new AutoFilterTableHeaderEditor() {
        protected void customizeAutoFilterBox(AutoFilterBox autoFilterBox) {
            autoFilterBox.applyComponentOrientation(AutoFilterTableHeader.this.getComponentOrientation());
            super.customizeAutoFilterBox(autoFilterBox);
            AutoFilterTableHeader.this.customizeAutoFilterBox(autoFilterBox);
        }
     };
 }
 else {
     return null;
 }
 

Overrides:
createDefaultEditor in class EditableTableHeader
Returns:
an AutoFilterTableHeaderEditor.

isCellEditable

public boolean isCellEditable(int columnIndex)
Description copied from class: EditableTableHeader
Returns true if the header cell at index is editable.

Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.

Overrides:
isCellEditable in class EditableTableHeader
Parameters:
columnIndex - the column whose value is to be queried
Returns:
true if the cell is editable

editingStopped

public void editingStopped(ChangeEvent e)
Specified by:
editingStopped in interface CellEditorListener
Overrides:
editingStopped in class EditableTableHeader

customizeAutoFilterBox

protected void customizeAutoFilterBox(AutoFilterBox autoFilterBox)
Customizes the AutoFilterBox.

Please be noted that this method will only be invoked if isUseNativeHeaderRenderer() returns false.

Parameters:
autoFilterBox - the AutoFilterBox created by AutoFilterTableHeaderRenderer or AutoFilterTableHeaderEditor.

initTable

protected void initTable(JTable table)
Initializes the table.

Parameters:
table - the table which is passed in as parameter of the constructor AutoFilterTableHeader(javax.swing.JTable).

columnMarginChanged

public void columnMarginChanged(ChangeEvent e)
Specified by:
columnMarginChanged in interface TableColumnModelListener
Overrides:
columnMarginChanged in class JTableHeader

tableModelChanged

protected void tableModelChanged(JTable table)
This method will be called when TableModel on JTable is changed.

Parameters:
table - the table

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

filterableTableModelChanged

public void filterableTableModelChanged(FilterableTableModelEvent event)
Description copied from interface: FilterableTableModelListener
Called whenever the FilterableTableModel's filtered is changed.

Specified by:
filterableTableModelChanged in interface FilterableTableModelListener
Parameters:
event - FilterableTableModelEvent.

createFilterableTableModel

protected IFilterableTableModel createFilterableTableModel(TableModel model)
Creates the FilterableTableModel to be used by AutoFilterTableHeader. It returns null by default. You can override it to create your own FilterableTableModel.

Parameters:
model - the table model.
Returns:
the FilterableTableModel.

createDefaultFilterableTableModel

protected IFilterableTableModel createDefaultFilterableTableModel(TableModel model)
Creates the FilterableTableModel.

Parameters:
model - the table model.
Returns:
the FilterableTableModel.

getFilterableTableModel

public IFilterableTableModel getFilterableTableModel()
Gets the FilterableTableModel used by this AutoFilterTableHeader.

Please be noted that, this method could return null since 3.1.0 when isAutoFilterEnabled() returns false.

Returns:
the FilterableTableModel.

clearFilters

public void clearFilters()
Clears all filters created by the AutoFilterTableHeader. Please note, this method only clears all the filters created by AutoFilterTableHeader but does NOT refresh the data. It will NOT clear any filter that is NOT created by AutoFilterTableHeader. You still need to call AutoFilterTableHeader#getFilterableTableModel().refresh() after this call to refresh the table.


isAutoFilterEnabled

public boolean isAutoFilterEnabled()
Gets the flag indicating if auto filter feature is enabled for the entire header.

By default, the flag is false.

Returns:
true if auto filter feature is enabled. Otherwise false.

setAutoFilterEnabled

public void setAutoFilterEnabled(boolean autoFilterEnabled)
Sets the flag indicating if auto filter feature is enabled for the entire header.

Parameters:
autoFilterEnabled - the flag

isShowFilterName

public boolean isShowFilterName()
Checks if the filter name is visible on the box as part of the title.

Returns:
true or false.

setShowFilterName

public void setShowFilterName(boolean showFilterName)
Sets the flag if the filter name is shown on the title.

Parameters:
showFilterName - true to show the filter name. False to not show it.

isShowFilterNameAsToolTip

public boolean isShowFilterNameAsToolTip()
Checks if the filter name is displayed as tooltip on the table header.

Returns:
true or false.

setShowFilterNameAsToolTip

public void setShowFilterNameAsToolTip(boolean showFilterNameAsToolTip)
Sets the flag if the filter name is displayed as tooltip on the table header.

Parameters:
showFilterNameAsToolTip - true to show the filter name as tooltip. False to not show it.

isShowFilterIcon

public boolean isShowFilterIcon()
Checks if the filter icon is visible on the box as part of the title.

Returns:
true or false.
See Also:
setShowFilterIcon(boolean)

setShowFilterIcon

public void setShowFilterIcon(boolean showFilterIcon)
Sets the flag if the filter icon is shown on the title.

Please be noted that if isUseNativeHeaderRenderer() returns true, it means that the filter icon will always be painted on the header. If isUseNativeHeaderRenderer() returns false, it means that if there is a filter, if a filter icon should be painted on the header.

Right now, we support show the icon directly while the header value is an instance of Icon. If you set the header value to icon and isUseNativeHeaderRenderer() returns false, this flag will not be respected.

Parameters:
showFilterIcon - true to show the filter icon. False to not show it.

setShowSortArrow

public void setShowSortArrow(boolean showSortArrow)
Sets the flag if the sort arrow is shown on the header.

Overrides:
setShowSortArrow in class SortableTableHeader
Parameters:
showSortArrow - true to show the sort arrow. False to not show it.

isAllowMultipleValues

public boolean isAllowMultipleValues(int columnIndex)
Checks if the AutoFilterTableHeader allows multiple values as the filter. The difference will be to use a CheckBoxList or a regular JList as the popup panel when clicking on the filter button.

Please be noted that the column index is in view level since the interface is provided in AutoFilterTableHeader. Make sure you will convert it to model level while overriding this method.

Parameters:
columnIndex - the visual column index.
Returns:
true or false.

isAllowMultipleValues

public boolean isAllowMultipleValues()
Checks if the AutoFilterTableHeader allows multiple values as the filter. The difference will be to use a CheckBoxList or a regular JList as the popup panel when clicking on the filter button.

Returns:
true or false.

setAllowMultipleValues

public void setAllowMultipleValues(boolean allowMultipleValues)
Set the flag if the AutoFilterTableHeader allows multiple values as the filter. The difference will be to use a CheckBoxList or a regular JList as the popup panel when clicking on the filter button.

Please note, call this method will clear all filters that were added before.

Parameters:
allowMultipleValues - true to allow multiple value filters. False to disallow it. Default is false.

isPreferSelectedValues

public boolean isPreferSelectedValues()
Get the flag indicating if selected possible values will be used or filtered possible values.

This flag is valid only if isAllowMultipleValues() return true.

The default value is false which is different from the behavior before 2.9.0. In this way, if you input a new record to the target table, the new record will stay. If you want the new record to be filtered away, please try to set this flag to true.

Returns:
true if the selected possible values will be used. Otherwise false.
See Also:
isAllowMultipleValues()

setPreferSelectedValues

public void setPreferSelectedValues(boolean preferSelectedPossibleValues)
Set the flag indicating if selected possible values will be used or filtered possible values.

Parameters:
preferSelectedPossibleValues - the flag
See Also:
isPreferSelectedValues()

isAutoRequestFocus

protected boolean isAutoRequestFocus()
Description copied from class: EditableTableHeader
If the editor requests focus when starts editing. Subclass can override to return false. Default is true.

Overrides:
isAutoRequestFocus in class EditableTableHeader
Returns:
true or false.

getFilterableTableModel

protected IFilterableTableModel getFilterableTableModel(AutoFilterBox box)
Gets the FilterableTableModel used by the AutoFilterBox. By default, we will return getFilterableTableModel() which means all AutoFilterBoxes will use the same filter table model. If for whatever reason you need to use different instances for different AutoFilterBox, you can create a new FilterableTableModel and return.

Parameters:
box - the AutoFilterBox who will use the IFilterableTableModel returned from this method.
Returns:
IFilterableTableModel.

isAcceptTextInput

public boolean isAcceptTextInput()
Gets the flag indicating if this header accepts text input.

Please be noted that this method will always return false if isUseNativeHeaderRenderer() returns true.

Returns:
true if text input is accepted. Otherwise false.
See Also:
setAcceptTextInput(boolean)

setAcceptTextInput

public void setAcceptTextInput(boolean acceptTextInput)
Sets the flag indicating if the header accepts text input.

Please be noted that this method will take effect only if isUseNativeHeaderRenderer() returns false.

By default, the value is false to minimize the height of the header. You could set it to true if you want to let your customer to input text in this header. However, the height of the header would be bigger.

Parameters:
acceptTextInput - the flag

isUseNativeHeaderRenderer

public boolean isUseNativeHeaderRenderer()
Gets the flag indicating if the native header renderer will be used.

Returns:
true if the native header renderer will be used. false if AutoFilterBox will be used.
Since:
3.1.0
See Also:
setUseNativeHeaderRenderer(boolean)

setUseNativeHeaderRenderer

public void setUseNativeHeaderRenderer(boolean useNativeHeaderRenderer)
Sets the flag indicating if the native header renderer will be used.

By default, the flag is false to keep backward compatibility. setting this flag to true would make the AutoFilterTableHeader use the same header renderer as system default. However, it will break the backward compatibility if you ever tried to override AutoFilterBox. If you have any backward compatibility concern, please set this flag to false.

Parameters:
useNativeHeaderRenderer - the flag
Since:
3.1.0

isRolloverEnabled

public boolean isRolloverEnabled()
Description copied from class: EditableTableHeader
Checks if rollover is enabled. If enabled, it will automatically start cell editing when mouse is moved over the table header.

Overrides:
isRolloverEnabled in class EditableTableHeader
Returns:
true or false.

getToolTipText

public String getToolTipText(MouseEvent event)
Description copied from class: DraggingTableHeader
Gets the tool tip text from ToolTipSupport

Overrides:
getToolTipText in class DraggingTableHeader
Parameters:
event - the mouse event
Returns:
the tool tip text. null if nothing to be displayed.

getFormattedColumnName

public String getFormattedColumnName(int columnIndex)
Get formatted column name based on current filters for header and tooltip text.

Parameters:
columnIndex - the view column index in the header
Returns:
the text after formatted. null if no need to display a tooltip text or change the column name.
Since:
3.1.0

formatColumnTitle

protected String formatColumnTitle(int modelIndex,
                                   String columnName,
                                   Filter[] filters)
Formats the string when the filter name is displayed. By default, we will display the column name first, followed by ": " then the filter name.

Parameters:
modelIndex - the model column index
columnName - the name for the column.
filters - the filters on the column
Returns:
the string after formatted.
Since:
3.1.0

getFilterIcon

protected ImageIcon getFilterIcon(int columnIndex,
                                  boolean mouseOverPaintArea,
                                  boolean hasFilter)
Gets the filter icon to be painted in the AutoFilterTableHeader if isUseNativeHeaderRenderer() returns true.

Parameters:
columnIndex - the column index
mouseOverPaintArea - if the mouse is currently over this column
hasFilter - if the column currently has filter
Returns:
the image icon to be painted.
Since:
3.4.1

JIDE 3.5.15