|
||||||||||
| 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.byteslooser.filters.gui.TableFilterHeader
public class TableFilterHeader
Implementation of a table filter that displays a set of editors associated to each table's column. This is the main Gui component in this library.
These editors are moved and resized as the table's columns are resized, so this Swing
component is better suited to be displayed atop the JTable, or just below, using the same
size -and resizing- as the table itself.
Each column can have a different type of editor associated, and there are four predefined editors:
JComboBox appearance. The user can enter free
text format, which is parsed using a given IFilterTextParser. The combobox keeps track of the last used
entries, and, in case of columns with enumeration or boolean types, it is prepopulated with the
possible values.JTextField appearance. It behaves as the BASIC
editor, but represented with a different (slimmer) swing component. It uses a contextual menu to
facilitate the input of last used expressionsJComboBox appearance, where only predefined
filters can be chosen. The list of options is obtained directly from the table, or, if is it an
enumeration or a Boolean type, directly from the type itself.Users can also provide customized editors, or modify the behaviour or appearance of the created ones
The implementation relies on the TableFilter class, please
read its documentation to understand the requirements on the table and its model, and how it is
affected by this filter
| Nested Class Summary | |
|---|---|
static class |
TableFilterHeader.EditorMode
Editor mode for the filter editors associated to each column |
| 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 | |
|---|---|
static float |
DEFAULT_FONT_PROPORTION
Default proportion size related to 'normal' cell fonts. |
| 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 | |
|---|---|
TableFilterHeader()
Constructor; the object is functional after a table is attached |
|
TableFilterHeader(TableFilterHeader.EditorMode mode)
Constructor; the object is functional after a table is attached |
|
| Method Summary | |
|---|---|
Color |
getErrorBackground()
Returns the color set by default as background on each text editor when the user commits any error on the filter expression. |
Color |
getErrorForeground()
Returns the color set by default as foreground on each text editor when the user commits any error on the filter expression. |
Color |
getFilterBackground()
Returns the color set by default as background on each editor. |
ITableFilterEditor |
getFilterEditor(int modelColumn)
Returns the filter editor for the given column. |
Color |
getFilterForeground()
Returns the color set by default as foreground on each editor. |
TableFilterHeader.EditorMode |
getMode()
Returns the mode currently associated to the TableHeader |
JTable |
getTable()
Returns the table currently atached |
TableFilter |
getTableFilter()
Returns the internal table filter. |
IFilterTextParser |
getTextParser()
Returns the parser used on plain text filters. |
void |
resetFilters()
Invokes resetFilter on all the editor filters. |
void |
resetMode(TableFilterHeader.EditorMode mode)
Defines the type of filter editors associated by default to the columns, and recreates all the editors with the given type |
TextChoiceFilterEditor |
setBasicFilterEditor(int modelColumn)
Sets a filter editor of type TextChoiceFilterEditor on the given column; this editor
is a JComboBox which allows the user to enter complex filter expressions,
with a historic of the last entries |
TableChoiceFilterEditor |
setChoiceFilterEditor(int modelColumn)
Sets a filter editor of type TableChoiceFilterEditor on the given column; this editor
is a JComboBox which only allows the user to enter predefined options. |
void |
setEnabled(boolean enabled)
Enables/Disables programatically the filters |
void |
setErrorBackground(Color bg)
Sets the background color used by the parsing text editors when there are error on the filter expressions. |
void |
setErrorForeground(Color fg)
Sets the foreground color used by the parsing text editors when there are error on the filter expressions. |
void |
setFilterBackground(Color bg)
Sets the background color used by the parsed-based editors. |
void |
setFilterEditor(int modelColumn,
ITableFilterEditor editor)
Sets a specific filter editor for a given column. |
void |
setFilterForeground(Color fg)
Sets the foreground color used by the editors. |
void |
setFont(Font font)
Sets the font used on all the editors. |
void |
setMode(TableFilterHeader.EditorMode mode)
Defines the type of the filter editors associated by default to the columns. |
TextFilterEditor |
setSlimFilterEditor(int modelColumn)
Sets a filter editor of type TextFilterEditor
on the given column; this editor is a JTextField which allows the user to
enter complex filter expressions, and includes a contextual menu to facilitate the input of
older entries |
void |
setTable(JTable table)
Attachs the table where the filtering will be applied. |
void |
setTableFilter(TableFilter filter)
Sets a new table filter. |
void |
setTextParser(IFilterTextParser parser)
Sets the parser to be used on text filter editors. |
void |
updateFilter()
Invokes updateFilter on all the editor filters. |
| 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 |
|---|
public static final float DEFAULT_FONT_PROPORTION
| Constructor Detail |
|---|
public TableFilterHeader()
setTable(JTable)public TableFilterHeader(TableFilterHeader.EditorMode mode)
| Method Detail |
|---|
public void setTable(JTable table)
Attachs the table where the filtering will be applied.
It will be created a row of editors, of the type currently set TableFilterHeader.EditorMode that follow the size and position of each of the columns in the
table.
public JTable getTable()
public TableFilter getTableFilter()
public void setTableFilter(TableFilter filter)
Sets a new table filter.
The filters associated to the initial TableFilter are transferred to the new
one.
public void setMode(TableFilterHeader.EditorMode mode)
Defines the type of the filter editors associated by default to the columns.
If the filter editors have been already created, they are not removed, the mode will only be used on newly created editors (like when adding columns to the table)
public TableFilterHeader.EditorMode getMode()
public void resetMode(TableFilterHeader.EditorMode mode)
public void resetFilters()
Invokes resetFilter on all the editor filters.
Note that the exact semantics depend on the exact editor type.
ITableFilterEditor.resetFilter()public void updateFilter()
Invokes updateFilter on all the editor filters.
Note that the exact semantics depend on the exact editor type.
ITableFilterEditor.updateFilter()public void setFilterBackground(Color bg)
Sets the background color used by the parsed-based editors.
public Color getFilterBackground()
Returns the color set by default as background on each editor.
Note that the color of each specific editor can be different, if the user customizes it directly.
public void setFilterForeground(Color fg)
Sets the foreground color used by the editors.
This method is a helper, invoking JComponent.setForeground(Color) on each editor
component, already created or not.
public Color getFilterForeground()
Returns the color set by default as foreground on each editor.
Note that the color of each specific editor can be different, if the user customizes it directly.
public void setErrorForeground(Color fg)
Sets the foreground color used by the parsing text editors when there are error on the filter expressions.
public Color getErrorForeground()
Returns the color set by default as foreground on each text editor when the user commits any error on the filter expression.
Note that the color of each specific editor can be different, if the user customizes it directly
public void setErrorBackground(Color bg)
Sets the background color used by the parsing text editors when there are error on the filter expressions.
public Color getErrorBackground()
Returns the color set by default as background on each text editor when the user commits any error on the filter expression.
Note that the color of each specific editor can be different, if the user customizes it directly
public ITableFilterEditor getFilterEditor(int modelColumn)
Returns the filter editor for the given column.
By default, all FilterEditors are instances of TextChoiceFilterEditor
modelColumn - The column number in the table model
public void setFilterEditor(int modelColumn,
ITableFilterEditor editor)
modelColumn - The column number in the table modeleditor - The filter editor, which can be null to place a TableFilterHeader.EditorMode NULL
editor.public TableChoiceFilterEditor setChoiceFilterEditor(int modelColumn)
Sets a filter editor of type TableChoiceFilterEditor on the given column; this editor
is a JComboBox which only allows the user to enter predefined options.
The initial options are the values in the table model for the given column.
If the given column already contains an editor of the given type, the existing editor is returned.
modelColumn - The column number in the table model
TableChoiceFilterEditor
editor, which can be then directly manipulated by the userpublic TextFilterEditor setSlimFilterEditor(int modelColumn)
Sets a filter editor of type TextFilterEditor
on the given column; this editor is a JTextField which allows the user to
enter complex filter expressions, and includes a contextual menu to facilitate the input of
older entries
If the given column already contains an editor of the given type, the existing editor is returned.
modelColumn - The column number in the table model
TextFilterEditor editor,
which can be then directly manipulated by the userpublic TextChoiceFilterEditor setBasicFilterEditor(int modelColumn)
Sets a filter editor of type TextChoiceFilterEditor on the given column; this editor
is a JComboBox which allows the user to enter complex filter expressions,
with a historic of the last entries
If the given column already contains an editor of the given type, the existing editor is returned.
modelColumn - The column number in the table model
TextChoiceFilterEditor
editor, which can be then directly manipulated by the userpublic void setTextParser(IFilterTextParser parser)
Sets the parser to be used on text filter editors.
This parser overrides any parser already set on the separate columns filters.
public IFilterTextParser getTextParser()
Returns the parser used on plain text filters.
By default, it is an instance of FilterTextParser
Each column can have its own Parser, if setTextParser is used on the associated filter. In that case, it is needed to access each filter to obtain the used parser.
public void setEnabled(boolean enabled)
setEnabled in class JComponentJComponent.setEnabled(boolean)public void setFont(Font font)
setFont in class JComponentJComponent.setFont(java.awt.Font)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||