|
||||||||||
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
net.coderazzi.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, inline the JTable
, or just below,
using the same size -and resizing- as the table itself. The position can be automatically
handled by the header itself -that is the default behavior-
The editor associated to each column has the type FilterEditor
, and can be
manipulated separately.
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
The default settings can be modified by using system properties or by setting values on
the singleton FilterSettings
instance
Providing a filter header to an existing table is as easy as doing:
TableFilterHeader filter = new TableFilterHeader(table);
Nested Class Summary | |
---|---|
static class |
TableFilterHeader.Position
Location of the header in relation to the table |
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 |
---|
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(JTable table)
Constructor, using the default location |
|
TableFilterHeader(JTable table,
TableFilterHeader.Position location)
Full constructor |
Method Summary | |
---|---|
void |
addHeaderObserver(IFilterHeaderObserver observer)
Adds a new observer to the header |
void |
addNotify()
Method automatically invoked when the class ancestor changes |
protected void |
customizeEditor(FilterEditor editor)
Customizes the editor, can be overridden for custom appearance |
Color |
getDisabledForeground()
Sets the color used for disabled fields |
Color |
getErrorForeground()
Returns the color set by default as foreground on each text editor when the user commits any error on the filter expression. |
FilterEditor |
getFilterEditor(int modelColumn)
Returns the filter editor for the given column in the table model |
int |
getMaxVisibleRows()
Returns the maximum number of visible rows in the popup menu |
TableFilterHeader.Position |
getPosition()
Returns the mode currently associated to the TableHeader |
JTable |
getTable()
Returns the table currently attached |
TableFilter |
getTableFilter()
Returns the internal table filter. |
IFilterTextParser |
getTextParser()
Returns the parser used on plain text filters. |
boolean |
isAutoOptions()
Returns the auto options flag |
boolean |
isEnabled()
Returns the current enable status |
void |
removeHeaderObserver(IFilterHeaderObserver observer)
Removes an existing observer from the header |
void |
resetFilter()
Invokes resetFilter on all the editor filters. |
void |
setAutoOptions(boolean set)
Sets the auto options flag. |
void |
setBackground(Color bg)
Sets the background color used by the parsed-based editors. |
void |
setDisabledForeground(Color dfg)
Sets the color used for disabled fields |
void |
setEnabled(boolean enabled)
Enables/Disables the filters |
void |
setErrorForeground(Color fg)
Sets the foreground color used by the parsing text editors when there are error on the filter expressions. |
void |
setFont(Font font)
Sets the font used on all the editors. |
void |
setForeground(Color fg)
Sets the foreground color used by the editors. |
void |
setMaxVisibleRows(int maxVisibleRows)
Sets the maximum number of visible rows in the popup menu (a minimum is always enforced) |
void |
setPosition(TableFilterHeader.Position location)
Defines the behaviour of the header concerning its position related to the table. |
void |
setTable(JTable table)
Attaches the table where the filtering will be applied. |
void |
setTableCellRenderer(int modelColumn,
TableCellRenderer renderer)
Sets as renderer for the editor a generic TableCellRenderer , as used by the JTable |
void |
setTableFilter(TableFilter filter)
Sets a new table filter. |
void |
setTextParser(IFilterTextParser parser)
Sets the parser to be used on text filter editors. |
void |
setVisible(boolean flag)
Hides / makes visible the header |
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 |
Constructor Detail |
---|
public TableFilterHeader()
setTable(JTable)
public TableFilterHeader(JTable table)
setPosition(net.coderazzi.filters.gui.TableFilterHeader.Position)
public TableFilterHeader(JTable table, TableFilterHeader.Position location)
setTable(JTable)
,
setPosition(net.coderazzi.filters.gui.TableFilterHeader.Position)
Method Detail |
---|
public void setTable(JTable table)
Attaches the table where the filtering will be applied.
It will be created a row of editors, 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 setPosition(TableFilterHeader.Position location)
Defines the behaviour of the header concerning its position related to the table.
public TableFilterHeader.Position getPosition()
public void resetFilter()
Invokes resetFilter on all the editor filters.
Invokes resetFilter on all the editors. This does not only implies invokingFilterEditor.resetFilter()
,
as it tries to reset the original editor options for enums and boolean types
FilterEditor.resetFilter()
public void addNotify()
addNotify
in class JComponent
public void setBackground(Color bg)
setBackground
in class JComponent
public void setForeground(Color fg)
setForeground
in class JComponent
public void setDisabledForeground(Color dfg)
public Color getDisabledForeground()
public void setErrorForeground(Color fg)
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 setMaxVisibleRows(int maxVisibleRows)
public int getMaxVisibleRows()
protected void customizeEditor(FilterEditor editor)
public FilterEditor getFilterEditor(int modelColumn)
public void setTableCellRenderer(int modelColumn, TableCellRenderer renderer)
Sets as renderer for the editor a generic TableCellRenderer
, as used by the JTable
This method allows reusing a renderer already written for a table as the editor's renderer, but it has an important restriction: it only works if the renderer does not depend on the cell coordinates
public 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.
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 setVisible(boolean flag)
setVisible
in class JComponent
public void setAutoOptions(boolean set)
public boolean isAutoOptions()
public void setEnabled(boolean enabled)
setEnabled
in class JComponent
public boolean isEnabled()
isEnabled
in class Component
public void setFont(Font font)
setFont
in class JComponent
public void addHeaderObserver(IFilterHeaderObserver observer)
public void removeHeaderObserver(IFilterHeaderObserver observer)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |