JIDE 3.4.0

com.jidesoft.grid
Class TableCustomFilterEditor

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.jidesoft.dialog.AbstractPage
                      extended by com.jidesoft.dialog.AbstractDialogPage
                          extended by com.jidesoft.grid.TableCustomFilterEditor
All Implemented Interfaces:
Laziness, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, TableModelListener

public class TableCustomFilterEditor
extends AbstractDialogPage
implements TableModelListener

TableCustomFilterEditor adds additional controls to create a list of FilterItems and they can be added to FilterableTableModel. To get the list of FilterItems, you can call getFilterItems() method.

It has two different ways to configure the filters. The first way is what we called filter list way (using setStyle(STYLE_FILTER_LIST)). In this way, you define the filter, add the filter to the list below it. Then define another filter, add it to the list and so on. The second way is to use inline editor to define filter (using setStyle(STYLE_INLINE_EDITOR)). You can use setStyle method to change the style. Note calling this method will clear the filters that are already defined. Or you can pass in the style as the second parameter of the constructor.

See Also:
Serialized Form

Nested Class Summary
 class TableCustomFilterEditor.FilterPanel
          It's one line of FilterPanel contains several components.
 
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
protected  JButton _addButton
          The button displayed on the right and above the _list.
protected  JToggleButton _andButton
          The label displayed on the left and below the _list.
protected  JButton _applyButton
          The button displayed on the right and below the _list.
protected  JButton _clearButton
          The button displayed on the left of _applyButton It is only used if getStyle() returns STYLE_FILTER_LIST.
protected  CustomFilterEditor _editor
          The CustomFilterEditor, which contains a column selection JComboBox, a condition JComboBox and the ValueEditors.
protected  List<TableCustomFilterEditor.FilterPanel> _filterPanels
          The FilterPanel list currently visible.
protected  JLabel _filtersLabel
          The label displayed on the left and above the _list.
protected  JList _list
          The existing filter list, which contains a list of current existing filters.
protected  JButton _removeButton
          The button displayed on the left of _clearButton It is only used if getStyle() returns STYLE_FILTER_LIST.
protected  JButton _replaceButton
          The button displayed on the left of _addButton.
protected  int _style
           
 String PROPERTY_COLLAPSED
           
 String PROPERTY_COLLAPSIBLE
           
static int STYLE_FILTER_LIST
           
static int STYLE_INLINE_EDITOR
           
 
Fields inherited from class com.jidesoft.dialog.AbstractDialogPage
_buttonEvent, _description, _icon, _pageEnabled, _parentPage, _title, DESCRIPTION_PROPERTY, ICON_PROPERTY, PROPERTY_PAGE_ENABLED, TITLE_PROPERTY
 
Fields inherited from class com.jidesoft.dialog.AbstractPage
_pageEvent, INVOKE_ON_ALL, INVOKE_ON_NONE, INVOKE_ON_PAINT, INVOKE_ON_REPAINT, INVOKE_ON_UPDATE, INVOKE_ON_VALIDATE
 
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
TableCustomFilterEditor(TableModel tableModel)
          Creates a TableCustomFilterEditor from a table model.
TableCustomFilterEditor(TableModel tableModel, int style)
          Creates a TableCustomFilterEditor from a table model.
 
Method Summary
protected  JComboBox createColumnComboBox(String[] columnNames)
           
protected  CustomFilterEditor createCustomFilterEditor(FilterFactoryManager filterFactoryManager, Class type, ConverterContext converterContext, Object[] possibleValues)
          Creates a CustomFilterEditor.
protected  IFilterableTableModel createFilterableTableModel(TableModel tableModel)
          Creates the FilterableTableModel.
protected  FilterFactoryManager createFilterFactoryManager()
          Creates the FilterFactoryManager used by this TableCustomFilterEditor.
protected  Component createListPanel()
           
protected  ValueEditor createValueEditor(Class type, ConverterContext converterContext, Object[] possibleValues)
          Creates the ValueEditor.
 ActionListener getApplyFilterActionListener()
          Gets the action listener to apply the filters defined by this editor to a FilterableTableModel.
 ActionListener getClearFilterActionListener()
          Gets the action listener to clear the filters defined by this editor to a FilterableTableModel.
protected  String getColumnName(TableModel tableModel, int columnIndex)
          Gets the table column name.
 IFilterableTableModel getFilterableTableModel()
          Gets the filterable table model.
 FilterFactoryManager getFilterFactoryManager()
          Gets the FilterFactoryManager used by this TableCustomFilterEditor.
 IFilterableTableModel.FilterItem[] getFilterItems()
          Gets the FilterItems defined in this TableCustomFilterEditor.
protected  String getResourceString(String key)
           
 int getStyle()
           
protected  void initComponents()
           
 boolean isAnd()
          Gets the relation of the filters when there are multiple filters.
 boolean isCollapsed()
           
 boolean isCollapsible()
           
 void lazyInitialize()
          This method must be implemented by any child class.
 void saveFilterItems()
           
 void setAnd(boolean and)
          Sets the relation of the filters when there are multiple filters.
 void setApplyFilterActionListener(ActionListener applyFilterActionListener)
          Sets the action listener that applies the filters defined by this editor to a FilterableTableModel.
 void setClearFilterActionListener(ActionListener clearFilterActionListener)
          Sets the action listener that clears the filters defined by this editor to a FilterableTableModel.
 void setCollapsed(boolean collapsed)
          Sets the filter editor into collapsed mode so that only the first filter editor is visible.
 void setCollapsible(boolean collapsible)
          Sets the collapsible property.
 void setFilterItems(IFilterableTableModel.FilterItem[] filterItems)
          Sets the FilterItems.
 void setStyle(int style)
          Changes the way how the filters are defined.
 void tableChanged(TableModelEvent e)
           
 
Methods inherited from class com.jidesoft.dialog.AbstractDialogPage
addButtonListener, fireButtonEvent, fireButtonEvent, fireButtonEvent, focusDefaultFocusComponent, getButtonListeners, getDefaultFocusComponent, getDescription, getFullTitle, getIcon, getParentPage, getTitle, isPageEnabled, removeButtonListener, setDefaultFocusComponent, setDescription, setIcon, setPageEnabled, setParentPage, setTitle
 
Methods inherited from class com.jidesoft.dialog.AbstractPage
addPageListener, allowClosing, firePageEvent, firePageEvent, getInvokeCondition, getPageListeners, initialize, invalidate, paint, paintAll, paintComponents, removePageListener, repaint, repaint, repaint, repaint, reset, revalidate, setAllowClosing, setInvokeCondition, update
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_editor

protected CustomFilterEditor _editor
The CustomFilterEditor, which contains a column selection JComboBox, a condition JComboBox and the ValueEditors. It is only used if getStyle() returns STYLE_FILTER_LIST.


_list

protected JList _list
The existing filter list, which contains a list of current existing filters. It is only used if getStyle() returns STYLE_FILTER_LIST.


_filtersLabel

protected JLabel _filtersLabel
The label displayed on the left and above the _list. It is only used if getStyle() returns STYLE_FILTER_LIST.


_replaceButton

protected JButton _replaceButton
The button displayed on the left of _addButton. It is only used if getStyle() returns STYLE_FILTER_LIST.


_removeButton

protected JButton _removeButton
The button displayed on the left of _clearButton It is only used if getStyle() returns STYLE_FILTER_LIST.


_applyButton

protected JButton _applyButton
The button displayed on the right and below the _list. It is only used if getStyle() returns STYLE_FILTER_LIST.


_addButton

protected JButton _addButton
The button displayed on the right and above the _list. It is only used if getStyle() returns STYLE_FILTER_LIST.


_clearButton

protected JButton _clearButton
The button displayed on the left of _applyButton It is only used if getStyle() returns STYLE_FILTER_LIST.


_style

protected int _style

STYLE_FILTER_LIST

public static final int STYLE_FILTER_LIST
See Also:
Constant Field Values

STYLE_INLINE_EDITOR

public static final int STYLE_INLINE_EDITOR
See Also:
Constant Field Values

_filterPanels

protected List<TableCustomFilterEditor.FilterPanel> _filterPanels
The FilterPanel list currently visible. It is only used if getStyle() returns STYLE_INLINE_EDITOR.


_andButton

protected JToggleButton _andButton
The label displayed on the left and below the _list. It is only used if getStyle() returns STYLE_FILTER_LIST.


PROPERTY_COLLAPSIBLE

public final String PROPERTY_COLLAPSIBLE
See Also:
Constant Field Values

PROPERTY_COLLAPSED

public final String PROPERTY_COLLAPSED
See Also:
Constant Field Values
Constructor Detail

TableCustomFilterEditor

public TableCustomFilterEditor(TableModel tableModel)
Creates a TableCustomFilterEditor from a table model.

Parameters:
tableModel - the table model.

TableCustomFilterEditor

public TableCustomFilterEditor(TableModel tableModel,
                               int style)
Creates a TableCustomFilterEditor from a table model. You can also specify the style which could be either STYLE_FILTER_LIST or STYLE_INLINE_EDITOR.

Parameters:
tableModel - the table model.
style - the style.
Method Detail

tableChanged

public void tableChanged(TableModelEvent e)
Specified by:
tableChanged in interface TableModelListener

lazyInitialize

public void lazyInitialize()
Description copied from interface: Laziness
This method must be implemented by any child class. Instead of putting initialization code in constructor, user should put code in this method in order to taking advantage of lazy loading.

Specified by:
lazyInitialize in interface Laziness

initComponents

protected void initComponents()

createFilterableTableModel

protected IFilterableTableModel createFilterableTableModel(TableModel tableModel)
Creates the FilterableTableModel. Subclass can override to return an existing FilterableTableModel if the table model wrapper chain already has a FilterableTableModel.

Parameters:
tableModel - the table model.
Returns:
a FilterableTableModel.

isCollapsible

public boolean isCollapsible()

setCollapsible

public void setCollapsible(boolean collapsible)
Sets the collapsible property. This property is only used when the style is STYLE_INLINE_EDITOR.

Parameters:
collapsible - true or false.

isCollapsed

public boolean isCollapsed()

setCollapsed

public void setCollapsed(boolean collapsed)
Sets the filter editor into collapsed mode so that only the first filter editor is visible. This flag is only used when the style is STYLE_INLINE_EDITOR.

Parameters:
collapsed - true or false.

saveFilterItems

public void saveFilterItems()

createColumnComboBox

protected JComboBox createColumnComboBox(String[] columnNames)

createFilterFactoryManager

protected FilterFactoryManager createFilterFactoryManager()
Creates the FilterFactoryManager used by this TableCustomFilterEditor. Subclass can override it to provide your own instance of FilterFactoryManager or customize it before returning the one created by super.createFilterFactoryManager.

Returns:
an new instance of FilterFactoryManager.

getColumnName

protected String getColumnName(TableModel tableModel,
                               int columnIndex)
Gets the table column name.

Parameters:
tableModel - the table model.
columnIndex - the column index.
Returns:
the name of the column at the specified index.

createCustomFilterEditor

protected CustomFilterEditor createCustomFilterEditor(FilterFactoryManager filterFactoryManager,
                                                      Class type,
                                                      ConverterContext converterContext,
                                                      Object[] possibleValues)
Creates a CustomFilterEditor.

Parameters:
filterFactoryManager - the FilterFactoryManager.
type - the type.
converterContext - the ConverterContext.
possibleValues - the possible values.
Returns:
a new instance of CustomFilterEditor.

createValueEditor

protected ValueEditor createValueEditor(Class type,
                                        ConverterContext converterContext,
                                        Object[] possibleValues)
Creates the ValueEditor.

Parameters:
type - the type.
converterContext - the ConverterContext.
possibleValues - the possible values.
Returns:
a new instance of the ValueEditor.

createListPanel

protected Component createListPanel()

getFilterItems

public IFilterableTableModel.FilterItem[] getFilterItems()
Gets the FilterItems defined in this TableCustomFilterEditor.

Returns:
the FilterItems defined in this TableCustomFilterEditor.

setFilterItems

public void setFilterItems(IFilterableTableModel.FilterItem[] filterItems)
Sets the FilterItems. It will remove all existing FilterItems defined in the editor and replace them with the new ones.

Parameters:
filterItems - the FilterItems defined this TableCustomFilterEditor.

getFilterableTableModel

public IFilterableTableModel getFilterableTableModel()
Gets the filterable table model.

Returns:
the filterable table model.

getFilterFactoryManager

public FilterFactoryManager getFilterFactoryManager()
Gets the FilterFactoryManager used by this TableCustomFilterEditor.

Returns:
the FilterFactoryManager instance.

getResourceString

protected String getResourceString(String key)

getStyle

public int getStyle()

setStyle

public void setStyle(int style)
Changes the way how the filters are defined. Valid values are {#link #STYLE_FILTER_LIST} and STYLE_INLINE_EDITOR. Please note, calling this method will clear the filters that are already defined.

Parameters:
style - the new style;.

getApplyFilterActionListener

public ActionListener getApplyFilterActionListener()
Gets the action listener to apply the filters defined by this editor to a FilterableTableModel.

Returns:
the action listener.

setApplyFilterActionListener

public void setApplyFilterActionListener(ActionListener applyFilterActionListener)
Sets the action listener that applies the filters defined by this editor to a FilterableTableModel.

Parameters:
applyFilterActionListener - a new listener.

getClearFilterActionListener

public ActionListener getClearFilterActionListener()
Gets the action listener to clear the filters defined by this editor to a FilterableTableModel.

Returns:
the action listener.

setClearFilterActionListener

public void setClearFilterActionListener(ActionListener clearFilterActionListener)
Sets the action listener that clears the filters defined by this editor to a FilterableTableModel.

Parameters:
clearFilterActionListener - a new listener.

isAnd

public boolean isAnd()
Gets the relation of the filters when there are multiple filters. It could be either AND or OR relation. It will apply to all the filters. In a single query, you can't have a mixsure of AND and OR among filters.

Returns:
true or false.

setAnd

public void setAnd(boolean and)
Sets the relation of the filters when there are multiple filters. The relation could be either AND or OR relation. It will apply to all the filters. In a single query, you can't have a mixsure of AND and OR among filters.

Parameters:
and - true or false. True means AND and false means OR.

JIDE 3.4.0