java.io.Serializablepublic abstract class CustomChoice
extends java.lang.Object
implements java.io.Serializable
A custom choice allows to specify custom filters that can be selected as a
choice in the filter editor. A custom choice is associated always to a text,
which the user can input to select the given choice.
It is also possible to specify how the custom filter is rendered; by
default it is displayed the icon -if provided-, and the text, unless the user
provides a custom renderer.
The order of the custom choices on the choices list can be modified with the precedence attribute. By default, custom choices are sorted by their textual representation. If a precedence is given, lower values are displayed first.
| Modifier and Type | Field | Description |
|---|---|---|
static int |
DEFAULT_PRECEDENCE |
|
static CustomChoice |
MATCH_ALL |
Empty filter, returns all entries.
|
static int |
MATCH_ALL_PRECEDENCE |
|
static CustomChoice |
MATCH_EMPTY |
Special empty filter, returns all entries with null or empty values.
|
| Constructor | Description |
|---|---|
CustomChoice(java.lang.String representation) |
Creates a custom choice without associated icon, and with default
precedence, to be handled exclusively as text.
|
CustomChoice(java.lang.String representation,
javax.swing.Icon icon) |
Creates a custom choice with associated icon and default precedence.
|
CustomChoice(java.lang.String representation,
javax.swing.Icon icon,
int precedence) |
Full constructor.
|
| Modifier and Type | Method | Description |
|---|---|---|
static CustomChoice |
create(java.lang.Object choice) |
Creates a CustomChoice that matches the given object; its stringfied
format is the representation shown to the user.
|
static CustomChoice |
create(java.lang.Object choice,
java.lang.String repr) |
Creates a CustomChoice that matches the given object, with the provided
representation.
The choice can be a Pattern instance, in which case it is
performed a complete regular expression match. |
static java.util.Set<CustomChoice> |
createSet(java.lang.Object[] choices) |
Creates a set of CustomChoice instances, one for each provided choice.
|
static java.util.Set<CustomChoice> |
createSet(java.util.Collection choices) |
Creates a set of CustomChoice instances, one for each provided choice.
|
void |
decorateComponent(IFilterEditor editor,
boolean isSelected,
javax.swing.JComponent c,
java.awt.Graphics g) |
Decorates the choice on the given editor.
|
java.awt.Color |
getBackground(IFilterEditor editor,
boolean isSelected) |
Returns the background color, or null to use the default one.
|
abstract javax.swing.RowFilter |
getFilter(IFilterEditor editor) |
Returns the associated filter.
|
java.awt.Font |
getFont(IFilterEditor editor,
boolean isSelected) |
Returns the font, or null to use the default one.
|
java.awt.Color |
getForeground(IFilterEditor editor,
boolean isSelected) |
Returns the foreground color, or null to use the default one.
|
javax.swing.Icon |
getIcon() |
Returns the associated icon, if any.
|
int |
getPrecedence() |
Returns the precedence value.
|
java.lang.String |
getRepresentation() |
Returns the associated string.
|
void |
setIcon(javax.swing.Icon icon) |
Sets the associated icon.
|
void |
setPrecedence(int precedence) |
Sets the precedence value.
|
void |
setRepresentation(java.lang.String representation) |
Sets the representation value.
|
java.lang.String |
toString() |
Returns the string representation of the filter.
|
public static final int DEFAULT_PRECEDENCE
public static final int MATCH_ALL_PRECEDENCE
public static final CustomChoice MATCH_ALL
public static final CustomChoice MATCH_EMPTY
public CustomChoice(java.lang.String representation,
javax.swing.Icon icon,
int precedence)
public CustomChoice(java.lang.String representation)
public CustomChoice(java.lang.String representation,
javax.swing.Icon icon)
public static java.util.Set<CustomChoice> createSet(java.lang.Object[] choices)
public static java.util.Set<CustomChoice> createSet(java.util.Collection choices)
public static CustomChoice create(java.lang.Object choice)
public static CustomChoice create(java.lang.Object choice, java.lang.String repr)
Pattern instance, in which case it is
performed a complete regular expression match.public java.awt.Color getBackground(IFilterEditor editor, boolean isSelected)
editor - the editor where the choice is usedisSelected - true if the choice is selectedpublic java.awt.Color getForeground(IFilterEditor editor, boolean isSelected)
editor - the editor where the choice is usedisSelected - true if the choice is selectedpublic java.awt.Font getFont(IFilterEditor editor, boolean isSelected)
editor - the editor where the choice is usedisSelected - true if the choice is selectedpublic javax.swing.Icon getIcon()
public void setIcon(javax.swing.Icon icon)
public void decorateComponent(IFilterEditor editor, boolean isSelected, javax.swing.JComponent c, java.awt.Graphics g)
editor - the editor where the choice is usedisSelected - true if the choice is selectedc - the component to decorateg - the decoration contextpublic int getPrecedence()
public void setPrecedence(int precedence)
public java.lang.String getRepresentation()
public void setRepresentation(java.lang.String representation)
public abstract javax.swing.RowFilter getFilter(IFilterEditor editor)
public final java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2018 coderazzi. All Rights Reserved.