Copyright © 2005 Scientific Applications. All Rights Reserved.

com.sciapp.filter.tree
Class PopupTreeFilterHeaderModel

java.lang.Object
  extended by com.sciapp.filter.tree.TreeFilterHeaderModel
      extended by com.sciapp.filter.tree.PopupTreeFilterHeaderModel
All Implemented Interfaces:
FilterHeaderCallback
Direct Known Subclasses:
ColumnFilterHeaderModel, LevelColumnFilterHeaderModel

public class PopupTreeFilterHeaderModel
extends TreeFilterHeaderModel

PopupTreeFilterHeaderModel uses an arrow button in order to provide real-time row filtering. The arrow appears on the right of the column's normal header and, once pressed, a popup is shown that contains available filter expression values regarding the column.

PopupTreeFilterHeaderModel is easily installed on a TreeTable:

TreeTable treeTable = new TreeTable();

PopupTreeFilterHeaderModel popup = new PopupTreeFilterHeaderModel();

popup.attachToTable(treeTable);

NOTE: PopupTreeFilterHeaderModel will create and install its own FilterTableHeader on the table when the attachToTable method is called. If you made changes to the header, or want to use TreeTable's header, you should call TreeFilterHeaderModel.setTableHeader prior to the attachToTable method. For example:

popup.setTableHeader((FilterTableHeader) treeTable.getTableHeader());


Field Summary
protected  ArrowButton arrow
          The button that is showing on the header.
static int ARROW_LEFT
          integer identifying that the arrow button should appear on the left of the column
static int ARROW_RIGHT
          integer identifying that the arrow button should appear on the right of the column
protected  int arrowMode
          the current positioning mode of the arrow (left or right)
protected  JComboBox box
          The combo box whose popup menu is displayed.
protected  Cursor defaultHeaderCursor
          the header's default cursor
protected  Color filteredColor
          the color of the arrow for a column that has filters
protected  Color unfilteredColor
          the color of the arrow for a column that has no filters
 
Fields inherited from class com.sciapp.filter.tree.TreeFilterHeaderModel
ALL_VALUES_MODE, autoCreateAllFilters, columnShowing, defaultFiltersByColumnClass, dynamicFilterTreeTableModel, filterHeader, filterMode, filterTreeTableModel, mapper, PROGRESSIVE_MODE, removeOnInvisible
 
Constructor Summary
PopupTreeFilterHeaderModel()
          Constructs a PopupTreeFilterHeaderModel.
 
Method Summary
protected  boolean checkForFilter(MouseEvent e)
          Determines if the user clicked on any of the arrow buttons on the table's header.
protected  ColumnFilterMapper createFilterMapper()
          This will return a DefaultColumnFilterMapper.
 ArrowButton getArrowButton()
          Returns the arrow button that is showing when a filter is installed on the column.
 int getArrowMode()
          Determines the positioning mode of the arrow.
 JComboBox getComboBox()
          Returns the combo box whose popup menu is displayed when the arrow button is pressed.
 Cursor getDefaultHeaderCursor()
          Retrieves the default header's cursor.
 Color getFilteredColor()
          Determines the color of the arrow button for columns that have filters.
 Color getUnfilteredColor()
          Determines the color of the arrow button for columns that do not have filters.
protected  void popupWillShow(int c)
          This method is called just before the popup is shown on screen.
protected  void prepareRenderer(int c)
          This method is called just before the renderer paints the column at c for columns that have a filter installed.
 void removeFromTable()
          Removes this TreeFilterHeaderModel instance from the table to which it was previously installed.
protected  void removeRenderer(TableColumn column)
          Remove the renderer for aColumn.
 void setArrowMode(int arrowMode)
          Determines the positioning mode of the arrow.
 void setDefaultHeaderCursor(Cursor cursor)
          Assigns the default headers' cursor.
 void setFilteredColor(Color filteredColor)
          Assigns the color of the arrow button for columns that have filters.
protected  void setRenderer(TableColumn column)
          Assigns a renderer for aColumn.
 void setTableHeader(FilterTableHeader header)
          Associates a header that will be used for displaying a visual representation of a filter on columns.
 void setUnfilteredColor(Color unfilteredColor)
          Assigns the color of the arrow button for columns that do not have filters.
 boolean shouldProcessEvent(MouseEvent e)
          Determines whether the mouse event generated on the table's header should be propagated.
 void updateUI()
          Calls to this method should update all components that are used to display the filter on the header.
 
Methods inherited from class com.sciapp.filter.tree.TreeFilterHeaderModel
attachToTable, attachToTable, createDefaultFilters, createTableHeader, getAutoCreateAllFilters, getColumnShowing, getDefaultFilter, getFilter, getFilterMapper, getFilterMode, getRemoveOnInvisible, getTableHeader, hasFilter, hasFilterControl, inferColumnClass, removeFilter, removeFilterControlFromColumn, removeFilterControlFromColumns, setAutoCreateAllFilters, setColumnShowing, setDefaultFilter, setFilterControlInColumn, setFilterControlInColumns, setFilterMapper, setFilterMode, setModel, setModel, setRemoveOnInvisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARROW_LEFT

public static final int ARROW_LEFT
integer identifying that the arrow button should appear on the left of the column

See Also:
Constant Field Values

ARROW_RIGHT

public static final int ARROW_RIGHT
integer identifying that the arrow button should appear on the right of the column

See Also:
Constant Field Values

arrowMode

protected int arrowMode
the current positioning mode of the arrow (left or right)


unfilteredColor

protected Color unfilteredColor
the color of the arrow for a column that has no filters


filteredColor

protected Color filteredColor
the color of the arrow for a column that has filters


box

protected JComboBox box
The combo box whose popup menu is displayed.


arrow

protected ArrowButton arrow
The button that is showing on the header.


defaultHeaderCursor

protected Cursor defaultHeaderCursor
the header's default cursor

Constructor Detail

PopupTreeFilterHeaderModel

public PopupTreeFilterHeaderModel()
Constructs a PopupTreeFilterHeaderModel.

Method Detail

checkForFilter

protected boolean checkForFilter(MouseEvent e)
Determines if the user clicked on any of the arrow buttons on the table's header. If so, a popup menu containing available filter expression values is displayed for the column pressed.

Parameters:
e - the mouse event generated on the table's header.
Returns:
true if the arrow button was pressed.

createFilterMapper

protected ColumnFilterMapper createFilterMapper()
This will return a DefaultColumnFilterMapper.

Creates a new instance of the column filter mapper that will be used to install and uninstall the filters.

Specified by:
createFilterMapper in class TreeFilterHeaderModel
Returns:
a new instance of the column filter mapper object.

getArrowButton

public ArrowButton getArrowButton()
Returns the arrow button that is showing when a filter is installed on the column.

Returns:
the arrow button.

getArrowMode

public int getArrowMode()
Determines the positioning mode of the arrow. This can be ARROW_LEFT or ARROW_RIGHT, in which the arrow is shown to the left or to the right of the column respectively. The default is ARROW_RIGHT.

Returns:
integer indicating where the arrow is positioned

getComboBox

public JComboBox getComboBox()
Returns the combo box whose popup menu is displayed when the arrow button is pressed.

Returns:
the combo box.

getDefaultHeaderCursor

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

Returns:
the default header's cursor

getFilteredColor

public Color getFilteredColor()
Determines the color of the arrow button for columns that have filters. The default is Color.blue.

Returns:
the arrow button's color for filtered columns

getUnfilteredColor

public Color getUnfilteredColor()
Determines the color of the arrow button for columns that do not have filters. The default is null.

Returns:
the arrow button's color for non-filtered columns

popupWillShow

protected void popupWillShow(int c)
This method is called just before the popup is shown on screen. The location and size of the popup can be specified at this point. For example:

Rectangle rec = filterHeader.getHeaderRect(c);

Point p = new Point(rec.x-50, rec.y + filterHeader.getHeight());

box.setLocation(p);

box.setSize(rec.width+50, 0);

Parameters:
c - the column for which a popup filter will be displayed.

prepareRenderer

protected void prepareRenderer(int c)
This method is called just before the renderer paints the column at c for columns that have a filter installed. This implementation pushes the arrow button down and paints it with a blue color if a filter expression is present on the column.

Parameters:
c - the column the renderer is painting.

removeFromTable

public void removeFromTable()
Removes this TreeFilterHeaderModel instance from the table to which it was previously installed. The TreeFilterHeaderModel can then become free for garbage collection.

Overrides:
removeFromTable in class TreeFilterHeaderModel

removeRenderer

protected void removeRenderer(TableColumn column)
Remove the renderer for aColumn.

Specified by:
removeRenderer in class TreeFilterHeaderModel
Parameters:
column - the column which renderer we want to remove.

setArrowMode

public void setArrowMode(int arrowMode)
Determines the positioning mode of the arrow. This can be ARROW_LEFT or ARROW_RIGHT, in which the arrow is shown to the left or to the right of the column respectively. The default is ARROW_RIGHT.

Parameters:
arrowMode - integer indicating where the arrow is positioned

setDefaultHeaderCursor

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

Parameters:
cursor - the default header cursor to assign

setFilteredColor

public void setFilteredColor(Color filteredColor)
Assigns the color of the arrow button for columns that have filters. The default is Color.blue.

Parameters:
filteredColor - the arrow button's color for filtered columns

setRenderer

protected void setRenderer(TableColumn column)
Assigns a renderer for aColumn.

Specified by:
setRenderer in class TreeFilterHeaderModel
Parameters:
column - the column to which a renderer we want to assign.

setTableHeader

public void setTableHeader(FilterTableHeader header)
Associates a header that will be used for displaying a visual representation of a filter on columns.

Overrides:
setTableHeader in class TreeFilterHeaderModel
Parameters:
header - the new header to assign

setUnfilteredColor

public void setUnfilteredColor(Color unfilteredColor)
Assigns the color of the arrow button for columns that do not have filters. The default is null.

Parameters:
unfilteredColor - the arrow button's color for non-filtered columns

shouldProcessEvent

public boolean shouldProcessEvent(MouseEvent e)
Determines whether the mouse event generated on the table's header should be propagated.

Parameters:
e - the mouse event.
Returns:
true if the event is to be processed, false otherwise.

updateUI

public void updateUI()
Calls to this method should update all components that are used to display the filter on the header.

Specified by:
updateUI in class TreeFilterHeaderModel

Copyright © 2005 Scientific Applications. All Rights Reserved.