JIDE 3.5.15

com.jidesoft.plaf.basic
Class BasicAutoFilterTableHeaderUIDelegate

java.lang.Object
  extended by com.jidesoft.plaf.TableHeaderUIDelegate
      extended by com.jidesoft.plaf.basic.BasicCellStyleTableHeaderUIDelegate
          extended by com.jidesoft.plaf.basic.BasicSortableTableHeaderUIDelegate
              extended by com.jidesoft.plaf.basic.BasicEditableTableHeaderUIDelegate
                  extended by com.jidesoft.plaf.basic.BasicAutoFilterTableHeaderUIDelegate
All Implemented Interfaces:
SortListener, MouseListener, MouseMotionListener, PropertyChangeListener, EventListener, TableColumnModelListener, TableModelListener
Direct Known Subclasses:
BasicGroupTableHeaderUIDelegate, BasicNestedTableHeaderUIDelegate

public class BasicAutoFilterTableHeaderUIDelegate
extends BasicEditableTableHeaderUIDelegate

The UIDelegate class for AutoFilterTableHeader works for all L&Fs.

Since:
3.1.0

Nested Class Summary
 class BasicAutoFilterTableHeaderUIDelegate.DropDownSwingWorker
           
 
Field Summary
protected  Object HIDE_POPUP_KEY
           
 
Fields inherited from class com.jidesoft.plaf.basic.BasicCellStyleTableHeaderUIDelegate
_header, _mouseXOffset, _rendererPane
 
Constructor Summary
BasicAutoFilterTableHeaderUIDelegate(JTableHeader header, CellRendererPane rendererPane)
           
 
Method Summary
protected  void applyFilter(Filter filter, int columnIndex)
          Applies the filter to the specified column index of the FilterableTableModel.
protected  void applyFilter(Filter filter, int columnIndex, boolean clearFirst)
          Applies the filter to the specified column index of the FilterableTableModel.
protected  void applyFilters(Filter[] filters, int columnIndex)
          Applies the filter to the specified column index of the FilterableTableModel.
protected  void applyFilters(Filter[] filters, int columnIndex, boolean clearFirst)
          Applies the filter to the specified column index of the FilterableTableModel.
protected  Point calculatePopupLocation()
          calculate the popup location.
protected  String convertElementToString(Object item)
          Converts the element from object to string.
protected  String convertElementToString(Object item, boolean isArray, ObjectGrouper grouper)
          Converts element to string.
protected  String convertElementToString(Object item, ConverterContext context)
          Converts the element from object to string.
protected  PopupPanel createCheckBoxListChooserPanel(TableModel tableModel, int columnIndex, Object[] possibleValues, ObjectGrouper objectGrouper, DefaultComboBoxModel comboBoxModel)
          Create a multiple selection popup panel (check box list chooser panel).
protected  FilterEditor createCustomFilterEditor(FilterFactoryManager filterFactoryManager, Class<?> type, ConverterContext converterContext, Object[] possibleValues)
          Creates the CustomFilterEditor used in the FieldBox's custom filter drop down list.
protected  StandardDialog createCustomFilterEditorDialog(Container container, String title, JComponent filterEditor)
          Creates the CustomFilterEditorDialog when the "(Custom...)" is clicked in the drop down list of the AutoFilterBox.
protected  PopupPanel createListChooserPanel(TableModel tableModel, int columnIndex, Object[] possibleValues, ObjectGrouper objectGrouper, DefaultComboBoxModel comboBoxModel)
          Create a single selection popup panel (list chooser panel).
protected  PopupPanel createPopupPanel(TableModel tableModel, int columnIndex, Object[] possibleValues)
          Create the popup panel while the customer clicks the filter icon.
protected  JidePopup createPopupWindow()
          Creates the popup window.
protected  void customizeList(JList list)
          Create Searchable instance for drop down list in AutoFilterTableHeader.
protected  Filter[] getCurrentFilters()
          Gets the current filters in the FilterableTableModel for the column this AutoFilterBox is working on.
protected  int[] getFilterCellDecoratorProperties()
          Gets the properties which will help FilterableTableHeaderCellDecorator paints.
protected  TableCellRenderer getHeaderRenderer(TableColumn aColumn)
          Gets header renderer from the TableColumn instance and the column index.
 Object[] getPossibleValues(ObjectGrouper objectGrouper, Object[] values, Comparator comparator)
          Gets possible values under the object grouper.
protected  boolean hasFocus(int columnIndex)
          Checks if the column index should have focus.
 void hidePopup()
          Causes the combo box to close its popup window.
 boolean isPopupVisible()
          Determines the visibility of the popup.
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
protected  boolean mouseOverFilterButton(Point p)
          Check if the mouse point is over the filter button.
 void paint(Graphics g, JComponent c)
          Paint method to paint the entire header.
protected  void paintCell(Graphics g, Rectangle cellRect, int columnIndex, Object value, boolean isSelected, boolean hasFocus, boolean paintCellDecorators)
          Paints the header cell.
protected  void showCustomFilterEditor(IFilterableTableModel filterableTableModel, int columnIndex, Object[] possibleValues)
          Shows CustomFilterEditor when "(Custom...) is selected in the drop down list.
 
Methods inherited from class com.jidesoft.plaf.basic.BasicEditableTableHeaderUIDelegate
mouseReleased
 
Methods inherited from class com.jidesoft.plaf.basic.BasicSortableTableHeaderUIDelegate
mouseEntered, mousePressed, propertyChange, sortChanged, sortChanging, uninstallAllListeners
 
Methods inherited from class com.jidesoft.plaf.basic.BasicCellStyleTableHeaderUIDelegate
columnAdded, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, createMarginBorder, customizePaint, customizeRendererComponent, dragColumn, getBorderInsets, getHeaderPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getResizingColumn, hasStyledLabelColumn, invalidateCache, isMouseOverPaintArea, releaseRendererComponent, resizeColumn, startResizingColumn, tableChanged, viewIndexForColumn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HIDE_POPUP_KEY

protected Object HIDE_POPUP_KEY
Constructor Detail

BasicAutoFilterTableHeaderUIDelegate

public BasicAutoFilterTableHeaderUIDelegate(JTableHeader header,
                                            CellRendererPane rendererPane)
Method Detail

getHeaderRenderer

protected TableCellRenderer getHeaderRenderer(TableColumn aColumn)
Description copied from class: BasicCellStyleTableHeaderUIDelegate
Gets header renderer from the TableColumn instance and the column index.

Overrides:
getHeaderRenderer in class BasicCellStyleTableHeaderUIDelegate
Parameters:
aColumn - the TableColumn instance
Returns:
the cell renderer for the column.

paintCell

protected void paintCell(Graphics g,
                         Rectangle cellRect,
                         int columnIndex,
                         Object value,
                         boolean isSelected,
                         boolean hasFocus,
                         boolean paintCellDecorators)
Description copied from class: BasicCellStyleTableHeaderUIDelegate
Paints the header cell.

Overrides:
paintCell in class BasicCellStyleTableHeaderUIDelegate
Parameters:
g - the Graphics instance
cellRect - the cell rectangle to be painted in
columnIndex - the view column index to paint
value - the header value to paint
isSelected - if the column is selected
hasFocus - if the column has focus
paintCellDecorators - if the cell decorators should be used as well

hasFocus

protected boolean hasFocus(int columnIndex)
Checks if the column index should have focus.

By default, the mouse roll over column has focus. In this method, we will add the column which currently shows popup to have focus as well.

Parameters:
columnIndex - the view column index.
Returns:
true if the column should have focus. Otherwise false.

paint

public void paint(Graphics g,
                  JComponent c)
Description copied from class: BasicSortableTableHeaderUIDelegate
Paint method to paint the entire header.

Overrides:
paint in class BasicSortableTableHeaderUIDelegate
Parameters:
g - the Graphics instance
c - the component to be painted

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener
Overrides:
mouseClicked in class BasicEditableTableHeaderUIDelegate

mouseOverFilterButton

protected boolean mouseOverFilterButton(Point p)
Check if the mouse point is over the filter button.

Parameters:
p - the mouse point
Returns:
true if the mouse point is over the filter button. Otherwise false.

getFilterCellDecoratorProperties

protected int[] getFilterCellDecoratorProperties()
Gets the properties which will help FilterableTableHeaderCellDecorator paints.

Returns:
the property array indicating all columns which should paint the filter icons.

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener
Overrides:
mouseMoved in class BasicEditableTableHeaderUIDelegate

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class BasicEditableTableHeaderUIDelegate

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener
Overrides:
mouseExited in class BasicSortableTableHeaderUIDelegate

createPopupPanel

protected PopupPanel createPopupPanel(TableModel tableModel,
                                      int columnIndex,
                                      Object[] possibleValues)
Create the popup panel while the customer clicks the filter icon.

Basically, we will try to use the converterContext defined in the table model to render the popup list in AutoFilterTableHeader. With this attempt, the customer will be able to see a consistent display in table cells and the popup list. You could also override AutoFilterBox#customizeList() to set your desired renderer.

Parameters:
tableModel - the table model
columnIndex - the column index to create the popup panel
possibleValues - possible values to be displayed
Returns:
the popup panel to be displayed.

createPopupWindow

protected JidePopup createPopupWindow()
Creates the popup window. By default it will create a JidePopup which is not detached and not resizable. Subclass can override it to create your own JidePopup or customize the default one.

Returns:
the popup window.

isPopupVisible

public boolean isPopupVisible()
Determines the visibility of the popup.

Returns:
true if the popup is visible, otherwise returns false

hidePopup

public void hidePopup()
Causes the combo box to close its popup window.


calculatePopupLocation

protected Point calculatePopupLocation()
calculate the popup location.

Returns:
the location of popup.

getPossibleValues

public Object[] getPossibleValues(ObjectGrouper objectGrouper,
                                  Object[] values,
                                  Comparator comparator)
Gets possible values under the object grouper.

Parameters:
objectGrouper - the grouper
values - the original values
comparator - the comparator
Returns:
all possible values under the grouper.

createListChooserPanel

protected PopupPanel createListChooserPanel(TableModel tableModel,
                                            int columnIndex,
                                            Object[] possibleValues,
                                            ObjectGrouper objectGrouper,
                                            DefaultComboBoxModel comboBoxModel)
Create a single selection popup panel (list chooser panel).

Parameters:
tableModel - the table model
columnIndex - the column index
possibleValues - possible values to be displayed in the list
objectGrouper - the grouper which contains the information how we should display those values if the values are groupers.
comboBoxModel - the combo box model of the list.
Returns:
the popup panel.

createCheckBoxListChooserPanel

protected PopupPanel createCheckBoxListChooserPanel(TableModel tableModel,
                                                    int columnIndex,
                                                    Object[] possibleValues,
                                                    ObjectGrouper objectGrouper,
                                                    DefaultComboBoxModel comboBoxModel)
Create a multiple selection popup panel (check box list chooser panel).

Parameters:
tableModel - the table model
columnIndex - the column index
possibleValues - possible values to be displayed in the check box list
objectGrouper - the grouper which contains the information how we should display those values if the values are groupers.
comboBoxModel - the combo box model of the check box list.
Returns:
the popup panel.

customizeList

protected void customizeList(JList list)
Create Searchable instance for drop down list in AutoFilterTableHeader. You can override this method to create your own searchable. The default implementation is to utilize the converter from the cell renderer as below.
 new ListSearchable(list) {
     protected String convertElementToString(Object object) {
         return cellRenderer.convertElementToString(list.getLocale(), object);
     }
 };
 

Parameters:
list - the list generated by possible values

getCurrentFilters

protected Filter[] getCurrentFilters()
Gets the current filters in the FilterableTableModel for the column this AutoFilterBox is working on.

Returns:
the Filter array.

applyFilters

protected void applyFilters(Filter[] filters,
                            int columnIndex)
Applies the filter to the specified column index of the FilterableTableModel.

Parameters:
filters - the filters.
columnIndex - the column index.
Since:
3.4.1

applyFilters

protected void applyFilters(Filter[] filters,
                            int columnIndex,
                            boolean clearFirst)
Applies the filter to the specified column index of the FilterableTableModel.

Parameters:
filters - the filter.
columnIndex - the column index.
clearFirst - the flag indicating if it should clear current filter inside FilterableTableModel or not.
Since:
3.4.1

applyFilter

protected void applyFilter(Filter filter,
                           int columnIndex)
Applies the filter to the specified column index of the FilterableTableModel.

Parameters:
filter - the filter.
columnIndex - the column index.

applyFilter

protected void applyFilter(Filter filter,
                           int columnIndex,
                           boolean clearFirst)
Applies the filter to the specified column index of the FilterableTableModel.

Parameters:
filter - the filter.
columnIndex - the column index.
clearFirst - the flag indicating if it should clear current filter inside FilterableTableModel or not.

showCustomFilterEditor

protected void showCustomFilterEditor(IFilterableTableModel filterableTableModel,
                                      int columnIndex,
                                      Object[] possibleValues)
Shows CustomFilterEditor when "(Custom...) is selected in the drop down list.

Parameters:
filterableTableModel - the FilterableTableModel
columnIndex - the column index of the AutoFilterBox relative to the filterableTableModel.
possibleValues - the possible values of the column in the table model.

createCustomFilterEditor

protected FilterEditor createCustomFilterEditor(FilterFactoryManager filterFactoryManager,
                                                Class<?> type,
                                                ConverterContext converterContext,
                                                Object[] possibleValues)
Creates the CustomFilterEditor used in the FieldBox's custom filter drop down list.

Parameters:
filterFactoryManager - the FilterFactoryManager.
type - the type.
converterContext - the ConverterContext.
possibleValues - the possible values.
Returns:
a new instance of CustomFilterEditor.

createCustomFilterEditorDialog

protected StandardDialog createCustomFilterEditorDialog(Container container,
                                                        String title,
                                                        JComponent filterEditor)
Creates the CustomFilterEditorDialog when the "(Custom...)" is clicked in the drop down list of the AutoFilterBox.

Parameters:
container - the top level ancestor of the AutoFilterBox.
title - the title of the dialog.
filterEditor - the CustomFilterEditor.
Returns:
a CustomFilterEditorDialog.

convertElementToString

protected String convertElementToString(Object item,
                                        boolean isArray,
                                        ObjectGrouper grouper)
Converts element to string.

Parameters:
item - the item
isArray - the flag indicating if the item is an array or not
grouper - the object grouper
Returns:
the converted string.

convertElementToString

protected String convertElementToString(Object item)
Converts the element from object to string.

Parameters:
item - the item
Returns:
the string.

convertElementToString

protected String convertElementToString(Object item,
                                        ConverterContext context)
Converts the element from object to string.

Parameters:
item - the item
context - the converter context
Returns:
the string.

JIDE 3.5.15