|
||||||||||
| 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.JComboBox
com.byteslooser.filters.gui.editors.ChoiceFilterEditor
public class ChoiceFilterEditor
Table filter editor based on selection of given expression choices, represented by a JComboBox.
Although it is initially less powerful than the editors based on text expressions, it is more customizable, in behaviour and appearance. It supports two specific ways to customize its appearance and contents:
ChoiceFilterEditor.IRenderer can be used to modify how the options are
rendered in the combobox.ChoiceFilterEditor.IChoice allows to set specific options that know if
they match the text in a table cell. This interface can be used to display/select options whose
representation does not match the representation in the GUI componentAn example of this second customization would be, in a column displaying people's ages, to setup several age ranges as choices, like 'ages below 25', '25 to 35', 'over 35'
| Nested Class Summary | |
|---|---|
protected class |
ChoiceFilterEditor.Filter
Implementation of a RowFilter for the ChoiceFilterEditor |
static interface |
ChoiceFilterEditor.IChoice
Interface to delegate to the application how a selected option in the editor matches a RowFilter.Entry instance. |
static interface |
ChoiceFilterEditor.IRenderer
Renderer to display the different choices |
| Nested classes/interfaces inherited from class javax.swing.JComboBox |
|---|
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager |
| 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 Object[] |
choices
The list of choices presented to the user |
protected Object |
currentChoice
The last selected choice |
protected ChoiceFilterEditor.Filter |
filter
The internal filter implementation |
protected int |
filterPosition
This is the filter position requested to the RowFilter.Entry; it
corresponds, in the case of a table, to the column to which this editor is associated. |
static String |
NO_FILTER
The object representing 'no filter', that is, it is the option to be selected for this editor to perform no filtering. |
protected Object |
otherChoices
The object representing the notion of 'other choices'. |
| Fields inherited from class javax.swing.JComboBox |
|---|
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder |
| 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 | |
|---|---|
ChoiceFilterEditor()
Default constructor. |
|
ChoiceFilterEditor(int filterPosition,
Object labelForOtherChoices,
Object... choices)
Full constructor |
|
| Method Summary | |
|---|---|
Component |
getComponent()
Provides the GUI component associated to the given editor |
IFilterObservable |
getFilterObservable()
Provides the IFilterObservable associated to the given
instance |
int |
getFilterPosition()
Returns the filter position |
void |
resetFilter()
Unselects any choice, removing, therefore, any filtering by this editor. |
protected void |
setChoiceModel(Object selected,
Object otherChoices,
Object[] choices)
Sets the model for the combo box |
void |
setChoiceRenderer(ChoiceFilterEditor.IRenderer renderer)
Sets the choice renderer, giving full access on how to render the contents of the component. |
void |
setChoices(ChoiceFilterEditor.IChoice... choices)
Sets the choices to be displayed. |
void |
setChoices(Object otherChoices,
Object... choices)
Sets the elements to be used as choices, and the element to be used as 'other choices'. |
void |
setEnabled(boolean enabled)
|
void |
setFilterPosition(int filterPosition)
Sets the filter position requested to the RowFilter.Entry; it
corresponds, in the case of a table, to the column to which this editor is associated. |
void |
updateFilter()
It propagates the current filter to any listeners |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String NO_FILTER
protected int filterPosition
This is the filter position requested to the RowFilter.Entry; it
corresponds, in the case of a table, to the column to which this editor is associated.
protected Object[] choices
protected Object otherChoices
The object representing the notion of 'other choices'.
If the user has multiple choices, but they do not cover all the possibilities, selection 'other choices', if present, will filter out all the choices not selected
This is, therefore, a special choice: selecting is equivalent to select any value not covered as the other provided choices.
It can be null, if the concept is not used or applicable.
protected Object currentChoice
protected ChoiceFilterEditor.Filter filter
| Constructor Detail |
|---|
public ChoiceFilterEditor()
public ChoiceFilterEditor(int filterPosition,
Object labelForOtherChoices,
Object... choices)
filterPosition - This is the filter position requested to the RowFilter.Entry; it corresponds, in the case of a
table, to the column to which this editor is associated.labelForOtherChoices - The object representing the notion of 'other choices'. This is
a special choice: selecting is equivalent to select any value
not covered in the current choices. It can be null, if the
concept is not applicable.choices - The choices to present to the usersetFilterPosition(int),
setChoices(Object, Object[])| Method Detail |
|---|
public void setChoices(ChoiceFilterEditor.IChoice... choices)
Sets the choices to be displayed.
Note that, in this case, there is no concept of 'other choices'; if needed, the invoker should provide a choice to cover that possible case.
public void setChoices(Object otherChoices, Object... choices)
Sets the elements to be used as choices, and the element to be used as 'other choices'.
If the user has multiple choices, but they do not cover all the possibilities, selection 'other choices', if present, will filter out all the choices not selected.
public void setChoiceRenderer(ChoiceFilterEditor.IRenderer renderer)
Sets the choice renderer, giving full access on how to render the contents of the component.
This is a wrapper method around JComboBox.setRenderer(ListCellRenderer)
public void setFilterPosition(int filterPosition)
Sets the filter position requested to the RowFilter.Entry; it
corresponds, in the case of a table, to the column to which this editor is associated.
public int getFilterPosition()
setFilterPosition(int)public IFilterObservable getFilterObservable()
ITableFilterEditorIFilterObservable associated to the given
instance
getFilterObservable in interface ITableFilterEditorpublic void updateFilter()
updateFilter in interface ITableFilterEditorITableFilterEditor.updateFilter()public void resetFilter()
resetFilter in interface ITableFilterEditorITableFilterEditor.resetFilter()public Component getComponent()
ITableFilterEditor
getComponent in interface ITableFilterEditorITableFilterEditor.getComponent()protected void setChoiceModel(Object selected, Object otherChoices, Object[] choices)
selected - The elemenet to select in the comboboxotherChoices - The element defining the concept of 'other choices'. It will be
displayed as the last option in the comboboxchoices - All the values to show in the combo box, in the provided orderpublic void setEnabled(boolean enabled)
setEnabled in class JComboBox
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||