|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel com.jidesoft.grid.QuickFilterPane
public class QuickFilterPane
QuickFilterPane
works along with any TableModel to provide filtering feature.
QuickFilterPane quickFilterPane = new QuickFilterPane(new SortableTableModel(tableModel), new int[]{3, 1,
2});
Later on, when you display the table, instead using your original table model, use getDisplayTableModel()
.
SortableTable table = new SortableTable(quickFilterPane.getDisplayTableModel());
As you can see, the usage is the same as QuickTableFilterField
. In fact, you can pass
quickTableFilterField.getDisplayTableModel()
to QuickFilterPane
as input. Or you can take
quickFilterPane.getDisplayTableModel()
and pass it as input to QuickTableFilterField
. You
can imagine as two pipes that connect. The input end is the raw table model. The output end is getDisplayTableModel()
which you should use it to display in a JTable or SortableTable.
QuickFilterPane
has several JLists. The number of JList is determined by the length of columnIndices
array. If you select an item from the list, a filter will be applied the underlying table model on corresponding
column, so you will see less rows in the table as well as the following JLists. You can multiple select which will
add more filters in OR relation. So just a few clicks, you can quick narrow down the table to have only the rows you
are interested in.
Nested Class Summary | |
---|---|
class |
QuickFilterPane.QuickFilterCheckBoxList
|
class |
QuickFilterPane.QuickFilterList
|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
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 MessageFormat |
_allItemFormat
|
protected JList[] |
_lists
|
protected IFilterableTableModel[] |
_models
|
protected JTable |
_table
|
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 | |
---|---|
QuickFilterPane()
Creates an empty QuickFilterPane . |
|
QuickFilterPane(TableModel tableModel)
Creates a QuickFilterPane using the specified table model. |
|
QuickFilterPane(TableModel tableModel,
int[] columnIndices)
Creates a QuickFilterPane using the specified table model and indices to the columns to be
filtered. |
|
QuickFilterPane(TableModel tableModel,
int[] columnIndices,
String[] displayNames)
Creates a QuickFilterPane using the specified table model and indices to the columns to be
filtered. |
Method Summary | |
---|---|
protected void |
applyFilter(JList list,
IFilterableTableModel filterableTableModel,
int column)
Apply filters to FilterableTableModel. |
protected TableModel |
createFilterableTableModel(TableModel tableModel,
int index)
Creates the FilterableTableModel for the JList at the specified index. |
protected Component |
createListComponent(JList list,
String name)
Creates a panel for the list which is used as filter for a column. |
protected ListModel |
createListModel(IFilterableTableModel filterableTableModel,
int column)
Creates the ListModel for the JList. |
protected Component |
createListsComponent(Component[] components)
Creates a component that contains all the lists. |
protected JList |
createQuickFilterList(IFilterableTableModel model,
int index)
Creates the list component that will be used for the quick filter. |
protected Object |
customizeDisplayedTextForAll(Object text)
Get displayed text in the list to represent "all" items. |
int[] |
getColumnIndices()
Gets the column indices. |
String[] |
getDisplayNames()
Gets the label name for each list in an array. |
TableModel |
getDisplayTableModel()
Gets the display table model. |
JList |
getList(int index)
Gets the JList at the specified index in QuickFilterPane . |
protected String |
getPluralForm(String word)
Gets the plural form. |
protected Object[] |
getPossibleValues(TableModel tableModel,
int column)
Gets all possible values at the specified column in the table model. |
protected String |
getResourceString(String key)
Gets the localized string from resource bundle. |
JTable |
getTable()
Gets the table where the display table model will be set. |
TableModel |
getTableModel()
Gets the table model used by QuickFilterPane . |
TableScrollPane |
getTablePane()
Gets the TableScrollPane where the display table model will be set. |
int |
getVisibleRowCount()
Returns the preferred number of visible rows. |
protected void |
initComponent()
Initialize this component. |
boolean |
isAutoUpdate()
Sets the auto-updated flag. |
boolean |
isUseCheckBoxList()
Checks if the CheckBoxList is used as the filter JList. |
boolean |
isUseTableCellRenderer()
Gets the flag indicating if table cell renderer will be used for the list. |
void |
removeAll()
|
void |
reset()
Resets the QuickFilterPane and selects the first row in all the lists. |
void |
setAutoUpdate(boolean autoUpdate)
Sets the autoUpdate flag. |
void |
setColumnIndices(int[] columnIndices)
Sets the filter column indices. |
void |
setDisplayNames(String[] displayNames)
Sets the label name for each list. |
void |
setEnabled(boolean enabled)
|
void |
setTable(JTable table)
Sets the table where the display table model will be set. |
void |
setTableModel(TableModel tableModel)
Sets the table model. |
void |
setTablePane(TableScrollPane tablePane)
Sets the TableScrollPane where the display table model will be set. |
void |
setUseCheckBoxList(boolean useCheckBoxList)
Uses the CheckBoxList as the filter JList. |
void |
setUseTableCellRenderer(boolean useTableCellRenderer)
Sets the flag indicating if table cell renderer will be used for the list. |
void |
setVisibleRowCount(int visibleRowCount)
Sets the preferred number of rows in the lists. |
protected boolean |
shouldPossibleValueBeIncluded(FilterableTableModel filterableTableModel,
Object value,
int column)
Check if the possible value should be included in the value select list. |
void |
update()
Updates the QuickFilterPane to refresh the data from the table model. |
void |
updateListsFromFilters()
Updates the selection of the lists from the filters in the FilterTableModel's created by QuickFilterPane. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected IFilterableTableModel[] _models
protected JList[] _lists
protected final MessageFormat _allItemFormat
protected JTable _table
Constructor Detail |
---|
public QuickFilterPane()
QuickFilterPane
. This method is useless since QuickFilterPane
has to
have a table model in order to work correctly. So we have this method in place mainly to make it JavaBean
compatible. You must call setTableModel(javax.swing.table.TableModel)
after you create
QuickFilterPane
using this constructor.
public QuickFilterPane(TableModel tableModel)
QuickFilterPane
using the specified table model. Since it doesn't specify the columns to
be filtered, it will use all columns as filter columns.
tableModel
- the table model. It could be any table model. We will automatically wrap it in
FilterableTableModel.public QuickFilterPane(TableModel tableModel, int[] columnIndices)
QuickFilterPane
using the specified table model and indices to the columns to be
filtered.
tableModel
- the table model. It could be any table model. We will automatically wrap it in
FilterableTableModel.columnIndices
- the indices to the columns to be filtered. You need to make sure all values in the index
array are within the range. Otherwise, it will throw ArrayIndexOutOfBoundsException. The
order also matters as it will determine the filter order. In the other words, it will apply
filter to the first column index, then the second and so on.
ArrayIndexOutOfBoundsException
- if the value in columnIndices array are out of the range of tableModel's
column count.public QuickFilterPane(TableModel tableModel, int[] columnIndices, String[] displayNames)
QuickFilterPane
using the specified table model and indices to the columns to be
filtered.
tableModel
- the table model. It could be any table model. We will automatically wrap it in
FilterableTableModel.columnIndices
- the indices to the columns to be filtered. You need to make sure all values in the index
array are within the range. Otherwise, it will throw ArrayIndexOutOfBoundsException. The
order also matters as it will determine the filter order. In the other words, it will apply
filter to the first column index, then the second and so on.displayNames
- the names used to label each list. If you don't specify this parameter, it will use column
names in tableModel instead. In most cases, it should be fine.
ArrayIndexOutOfBoundsException
- if the value in columnIndices array are out of the range of tableModel's
column count.
IllegalArgumentException
- if the length of columnIndices array is different from that of
displayNames array.Method Detail |
---|
public void setEnabled(boolean enabled)
setEnabled
in class JComponent
public void updateListsFromFilters()
protected ListModel createListModel(IFilterableTableModel filterableTableModel, int column)
filterableTableModel
- the FilterableTableModel controlled by the JList.column
- the column index.
protected Object customizeDisplayedTextForAll(Object text)
text
- the default text generated by JIDE
protected void applyFilter(JList list, IFilterableTableModel filterableTableModel, int column)
list
- the list.filterableTableModel
- the FilterableTableModel where filter will be added.column
- the column index.protected Object[] getPossibleValues(TableModel tableModel, int column)
tableModel
- the table modelcolumn
- the column
protected void initComponent()
protected JList createQuickFilterList(IFilterableTableModel model, int index)
model
- FilterableTableModelindex
- the index of the list
setUseCheckBoxList(boolean)
is set to true.protected TableModel createFilterableTableModel(TableModel tableModel, int index)
if(index == 0) {
return new FilterableTableModel(tableModel);
}
else {
return tableModel;
}
tableModel
- the table model. For the first JList, it is the the table model passed to the constructor of
QuickFilterPane. For the following JLists, the table model is the FilterableTableModel returned
from previous call of createFilterableTableModel.index
- the index of the JList.
protected boolean shouldPossibleValueBeIncluded(FilterableTableModel filterableTableModel, Object value, int column)
filterableTableModel
- the filterable table modelvalue
- the value to be checkcolumn
- the column index where the value resides
protected Component createListsComponent(Component[] components)
components
- the list of components. Each component contains a JList which is used as filter. The component
is created by createListComponent(javax.swing.JList, String)
.
protected Component createListComponent(JList list, String name)
list
- the list which is used as filter for a column.name
- the name of the list. If you specify displayName, the name will be the display name. Otherwise, it
will be the corresponding column name.
public void reset()
QuickFilterPane
and selects the first row in all the lists.
public void update()
QuickFilterPane
to refresh the data from the table model.
public TableModel getTableModel()
QuickFilterPane
.
public void setTableModel(TableModel tableModel)
tableModel
- the new table modelpublic void removeAll()
removeAll
in class Container
public int[] getColumnIndices()
public void setColumnIndices(int[] columnIndices)
setTable(javax.swing.JTable)
method before. If so, you just call
table.setModel(quickFilterPane.getDisplayTableModel() method yourself after the setColumnIndices call.
columnIndices
- the indices to the columns to be filtered. You need to make sure all values in the index
array are within the range. Otherwise, it will throw ArrayIndexOutOfBoundsException. The
order also matters as it will determine the filter order. In the other words, it will apply
filter to the first column index, then the second and so on.
ArrayIndexOutOfBoundsException
- if the value in columnIndices array are out of the range of tableModel's
column count.
IllegalArgumentException
- if the length of columnIndices array is different from that of
displayNames array.public String[] getDisplayNames()
public void setDisplayNames(String[] displayNames)
displayNames
- the names used to label each list. If you don't specify this parameter, it will use column
names in tableModel instead. In most cases, it should be fine.
IllegalArgumentException
- if the length of columnIndices array is different from that of displayNames
array.public TableModel getDisplayTableModel()
QuickFilterPane
doesn't modify the table model that you passed in but
wrap it in FilterableTableModel. So if you want to display the result after being filtered, you should use this
method to get the display table model and set it to your table.
public void setVisibleRowCount(int visibleRowCount)
visibleRowCount
- the new visible row countpublic int getVisibleRowCount()
public JList getList(int index)
QuickFilterPane
. You should call this method after
QuickFilterPane
having been initialized (after tableModel has been set).
index
- the index.
QuickFilterPane
. It will return null if
QuickFilterPane
has not been initialized.
IndexOutOfBoundsException
- if the index is less than 0 or larger than the number filtered columns.protected String getResourceString(String key)
key
- the key for the resource string
protected String getPluralForm(String word)
word
- the word
public JTable getTable()
public void setTable(JTable table)
setColumnIndices(int[])
method so that you don't need to explicitly
set the display table model to the table after the call.
table
- the table where the display table model will be set.public TableScrollPane getTablePane()
setTablePane(TableScrollPane)
public void setTablePane(TableScrollPane tablePane)
setColumnIndices(int[])
method so that you don't need
to explicitly set the display table model to the table scroll pane after the call.
tablePane
- the table scroll pane where the display table model will be set.public boolean isUseCheckBoxList()
public void setUseCheckBoxList(boolean useCheckBoxList)
useCheckBoxList
- true to use CheckBoxList as the lists.public boolean isAutoUpdate()
public void setAutoUpdate(boolean autoUpdate)
autoUpdate
- true to update JList automatically when table model is updated.public boolean isUseTableCellRenderer()
setUseTableCellRenderer(boolean)
public void setUseTableCellRenderer(boolean useTableCellRenderer)
useTableCellRenderer
- the flag
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |