|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sciapp.filter.FilterHeaderModel
com.sciapp.filter.PopupFilterHeaderModel
public class PopupFilterHeaderModel
PopupFilterHeaderModel 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.
PopupFilterHeaderModel is easily installed on a JTable:
PopupFilterHeaderModel popup = new PopupFilterHeaderModel();
popup.attachToTable(table);
NOTE: If your table is an AdvancedJTable (or TreeTable), you need to add the following line:
popup.setTableHeader((FilterTableHeader) table.getTableHeader());
,so that the table will take into account the presence of the last column
(see getShowDummyColumn
).
Field Summary | |
---|---|
protected String |
allString
The string to display for the "ALL" option |
protected ArrowButton |
arrow
The button that is showing on the header. |
protected String |
BLANK_STRING
a string for the 'blanks' filter selection |
protected JComboBox |
box
The combo box whose popup menu is displayed. |
protected String |
NON_BLANK_STRING
a string for the 'non blanks' filter selection |
protected PopupRenderer |
renderer
The renderer of the popup menu. |
Fields inherited from class com.sciapp.filter.FilterHeaderModel |
---|
ALL_VALUES_MODE, autoCreateAllFilters, columnShowing, defaultFiltersByColumnClass, filterHeader, filterMode, filterModel, ORDERED_MODE, PROGRESSIVE_MODE, tableModel |
Constructor Summary | |
---|---|
PopupFilterHeaderModel()
Constructs a PopupFilterHeaderModel. |
Method Summary | |
---|---|
protected boolean |
checkForFilter(MouseEvent e)
Determines if the user clicked on any of the arrow buttons on the table's header. |
protected void |
filterSelected(JList list,
int c)
Called as soon as the user has selected a value from the popup menu. |
ArrowButton |
getArrowButton()
Returns the arrow button that is showing when a filter is installed on the column. |
protected Collection |
getCollectionForColumn(int c)
Returns an empty collection that will be used to fill with available filter expression values. |
JComboBox |
getComboBox()
Returns the combo box whose popup menu is displayed when the arrow button is pressed. |
void |
installFilter(TableFilter tableFilter,
Object listValue,
Object filterValue,
int c)
Assigns a new table filter to the column c . |
protected void |
populatePopup(int c)
Populates the popup menu with values that will be used as filter expressions. |
protected void |
popupWillShow(int c)
This method is called just before the popup is shown on screen. |
protected void |
preparePopup(int c)
Makes final preparations 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 FilterHeaderModel instance from the table to which it was previously assigned. |
protected void |
removeRenderer(TableColumn column)
Remove the renderer for aColumn . |
protected void |
setRenderer(TableColumn column)
Assigns a renderer for aColumn . |
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected String BLANK_STRING
protected String NON_BLANK_STRING
protected JComboBox box
protected ArrowButton arrow
protected PopupRenderer renderer
protected String allString
Constructor Detail |
---|
public PopupFilterHeaderModel()
Method Detail |
---|
protected boolean checkForFilter(MouseEvent e)
e
- the mouse event generated on the table's header.
protected void filterSelected(JList list, int c)
e.g. Object selectedValue = list.getSelectedValue();
list
- the list of the popup menu.public ArrowButton getArrowButton()
protected Collection getCollectionForColumn(int c)
c
- the column
public JComboBox getComboBox()
public void installFilter(TableFilter tableFilter, Object listValue, Object filterValue, int c)
c
.
installFilter
in class FilterHeaderModel
tableFilter
- the new table filter to assign.listValue
- the label of the filter.filterValue
- the value of the filter.c
- the view index of the column.protected void populatePopup(int c)
c
- the column that contains the values.protected void popupWillShow(int c)
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);
c
- the column for which a popup filter will be displayed.protected void preparePopup(int c)
c
- the column for which the popup filter will be displayed.protected void prepareRenderer(int c)
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.
c
- the column the renderer is painting.public void removeFromTable()
removeFromTable
in class FilterHeaderModel
protected void removeRenderer(TableColumn column)
aColumn
.
removeRenderer
in class FilterHeaderModel
column
- the column which renderer we want to remove.protected void setRenderer(TableColumn column)
aColumn
.
setRenderer
in class FilterHeaderModel
column
- the column to which a renderer we want to assign.public boolean shouldProcessEvent(MouseEvent e)
e
- the mouse event.
public void updateUI()
updateUI
in class FilterHeaderModel
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |