|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.sciapp.filter.FilterTablePanel
public class FilterTablePanel
FilterTablePanel is a panel through which filter events are propagated to a FilterTableModel.
FilterTablePanel uses a box layout with horizontal orientation to layout the different gui components. You can customize its appearance by overriding makePanel, in which you must supply code to add these gui components to the panel. FilterTablePanel provides filters for the fields passed as arguments in the constructor. Additionally, it defines two more filtering options: no filter and filter on all columns.
FilterTablePanel uses VisualFilter objects in order to offer visual filtering at runtime. Each time the filter column changes, the associated VisualFilter is taken by calling getDefaultFilter(int field), and is then shown on the FilterTablePanel. If the latter method returns null, FilterTablePanel takes the default visual filter based on the field's class, by calling getDefaultFilter(Class columnClass).
Nested Class Summary |
---|
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.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected HashMap |
defaultFiltersByColumnClass
A table of objects that filter data and that can be manipulated visually, indexed by class. |
protected JComboBox |
fieldBox
a combobox that contains the fields that we are able to filter. |
protected JButton |
filterButton
a button that when clicked, fires the filter event. |
protected FilterModel |
filterModel
the filter model of the FilterTablePanel that forwards filter notification events to the listeners (normally a FilterTableModel). |
protected JCheckBox |
filterOn
a checkbox that shows if the filter displayed is active or not. |
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 | |
---|---|
FilterTablePanel(String[] fields)
Constructs a FilterTablePanel with fields as the fields that we are able to filter. |
|
FilterTablePanel(String[] fields,
Class[] classes)
Constructs a FilterTablePanel with fields as the fields that we are able to filter
and classes as the corresponding classes of each field. |
|
FilterTablePanel(TableModel tableModel)
Constructs a FilterTablePanel by quering tableModel for the filtering fields
and the corresponding classes. |
Method Summary | |
---|---|
protected void |
createDefaultFilters()
Creates default VisualFilters for objects, strings, numbers and boolean values. |
VisualFilter |
getDefaultFilter(Class columnClass)
Returns the visual filter to use for the class defined by columnClass. |
VisualFilter |
getDefaultFilter(int field)
Returns the visual filter to use for the value at field . |
FilterModel |
getFilterModel()
Returns the filter model. |
protected void |
makePanel()
Adds the gui components to the FilterTablePanel using a box layout with horizontal orientation. |
void |
setDefaultFilter(Class columnClass,
VisualFilter filter)
Sets the default visual filter for columnClass. |
void |
update(TableModel model)
Updates the FilterTablePanel by querying model and recreating the
fields that we are able to filter. |
void |
updateUI()
Resets the UI property with a value from the current look and feel. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected FilterModel filterModel
protected HashMap defaultFiltersByColumnClass
protected JButton filterButton
protected JCheckBox filterOn
protected JComboBox fieldBox
Constructor Detail |
---|
public FilterTablePanel(String[] fields)
fields
as the fields that we are able to filter.
The corresponing filter for each field is initialized to a StringFilter.
fields
- the fields, which ususally are the columns of a table.public FilterTablePanel(String[] fields, Class[] classes)
fields
as the fields that we are able to filter
and classes
as the corresponding classes of each field.
An IllegalArgumentException is thrown if fields
and classes
are not of the same length.
fields
- the fields, which ususally are the columns of a table.classes
- the associated classes to fields.public FilterTablePanel(TableModel tableModel)
tableModel
for the filtering fields
and the corresponding classes. The filter columns and classes are constructed by calling
the getColumnName and getColumnClass methods of TableModel respectively. Therefore,
these methods should not return null.
tableModel
- the tablemodel to queryMethod Detail |
---|
protected void createDefaultFilters()
public VisualFilter getDefaultFilter(int field)
field
.
This method returns null by default. Override it in order to return your own visual filter object.
field
- the field index to which a visual filter is associated.
field
public VisualFilter getDefaultFilter(Class columnClass)
columnClass
- the class to which a visual filter is associated.
public FilterModel getFilterModel()
protected void makePanel()
public void setDefaultFilter(Class columnClass, VisualFilter filter)
columnClass
- the Class with which a visual filter we want to associatefilter
- the visual filter to setpublic void update(TableModel model)
model
and recreating the
fields that we are able to filter.
model
- the TableModel to querypublic void updateUI()
updateUI
in class JPanel
JComponent.updateUI()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |