Copyright © 2005 Scientific Applications. All Rights Reserved.

com.sciapp.filter
Class FilterTablePanel

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.sciapp.filter.FilterTablePanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class FilterTablePanel
extends JPanel

FilterTablePanel is a panel through which filter events are propagated to a FilterTableModel.

FilterTablePanel uses a box layout with horizontal orientation to layout the different gui components. You can customize its appearance by overriding makePanel, in which you must supply code to add these gui components to the panel. FilterTablePanel provides filters for the fields passed as arguments in the constructor. Additionally, it defines two more filtering options: no filter and filter on all columns.

FilterTablePanel uses VisualFilter objects in order to offer visual filtering at runtime. Each time the filter column changes, the associated VisualFilter is taken by calling getDefaultFilter(int field), and is then shown on the FilterTablePanel. If the latter method returns null, FilterTablePanel takes the default visual filter based on the field's class, by calling getDefaultFilter(Class columnClass).

See Also:
Serialized Form

Nested Class Summary
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  JLabel activeLabel
          a label showing whether the filter is active
protected  HashMap defaultFiltersByColumnClass
          A table of objects that filter data and that can be manipulated visually, indexed by class.
protected  JComboBox fieldBox
          a combobox that contains the fields that we are able to filter.
protected  JLabel fieldLabel
          a label showing the current filter column field
protected  JButton filterButton
          a button that when clicked, fires the filter event.
protected  FilterModel filterModel
          the filter model of the FilterTablePanel that forwards filter notification events to the listeners (normally a FilterTableModel).
protected  JCheckBox filterOn
          a checkbox that shows if the filter displayed is active or not.
 
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
FilterTablePanel(String[] fields)
          Constructs a FilterTablePanel with fields as the fields that we are able to filter.
FilterTablePanel(String[] fields, Class[] classes)
          Constructs a FilterTablePanel with fields as the fields that we are able to filter and classes as the corresponding classes of each field.
FilterTablePanel(TableModel tableModel)
          Constructs a FilterTablePanel by quering tableModel for the filtering fields and the corresponding classes.
 
Method Summary
protected  void createDefaultFilters()
          Creates default VisualFilters for objects, strings, numbers and boolean values.
 VisualFilter getDefaultFilter(Class columnClass)
          Returns the visual filter to use for the class defined by columnClass.
 VisualFilter getDefaultFilter(int field)
          Returns the visual filter to use for the value at field.
 JComboBox getFieldBox()
          Returns a combobox that contains the fields that we are able to filter.
 JButton getFilterButton()
          Returns a button that when clicked, fires the filter event.
 FilterModel getFilterModel()
          Returns the filter model.
 JCheckBox getFilterOn()
          Returns a checkbox that shows if the filter displayed is active or not.
protected  void makePanel()
          Adds the gui components to the FilterTablePanel using a box layout with horizontal orientation.
 void setDefaultFilter(Class columnClass, VisualFilter filter)
          Sets the default visual filter for columnClass.
 void update(TableModel model)
          Updates the FilterTablePanel by querying model and recreating the fields that we are able to filter.
 void updateUI()
          Resets the UI property with a value from the current look and feel.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, 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

filterModel

protected FilterModel filterModel
the filter model of the FilterTablePanel that forwards filter notification events to the listeners (normally a FilterTableModel).


defaultFiltersByColumnClass

protected HashMap defaultFiltersByColumnClass
A table of objects that filter data and that can be manipulated visually, indexed by class.


activeLabel

protected JLabel activeLabel
a label showing whether the filter is active


fieldLabel

protected JLabel fieldLabel
a label showing the current filter column field


filterButton

protected JButton filterButton
a button that when clicked, fires the filter event.


filterOn

protected JCheckBox filterOn
a checkbox that shows if the filter displayed is active or not.


fieldBox

protected JComboBox fieldBox
a combobox that contains the fields that we are able to filter.

Constructor Detail

FilterTablePanel

public FilterTablePanel(String[] fields)
Constructs a FilterTablePanel with fields as the fields that we are able to filter. The corresponing filter for each field is initialized to a StringFilter.

Parameters:
fields - the fields, which ususally are the columns of a table.

FilterTablePanel

public FilterTablePanel(String[] fields,
                        Class[] classes)
Constructs a FilterTablePanel with fields as the fields that we are able to filter and classes as the corresponding classes of each field. An IllegalArgumentException is thrown if fields and classes are not of the same length.

Parameters:
fields - the fields, which ususally are the columns of a table.
classes - the associated classes to fields.

FilterTablePanel

public FilterTablePanel(TableModel tableModel)
Constructs a FilterTablePanel by quering tableModel for the filtering fields and the corresponding classes. The filter columns and classes are constructed by calling the getColumnName and getColumnClass methods of TableModel respectively. Therefore, these methods should not return null.

Parameters:
tableModel - the tablemodel to query
Method Detail

createDefaultFilters

protected void createDefaultFilters()
Creates default VisualFilters for objects, strings, numbers and boolean values.


getDefaultFilter

public VisualFilter getDefaultFilter(int field)
Returns the visual filter to use for the value at field.

This method returns null by default. Override it in order to return your own visual filter object.

Parameters:
field - the field index to which a visual filter is associated.
Returns:
the visual filter that corresponds to field

getDefaultFilter

public VisualFilter getDefaultFilter(Class columnClass)
Returns the visual filter to use for the class defined by columnClass.

Parameters:
columnClass - the class to which a visual filter is associated.
Returns:
the visual filter that corresponds to columnClass.

getFieldBox

public JComboBox getFieldBox()
Returns a combobox that contains the fields that we are able to filter.

Returns:
the combobox containing the available filter columns

getFilterButton

public JButton getFilterButton()
Returns a button that when clicked, fires the filter event.

Returns:
the 'filter' button

getFilterModel

public FilterModel getFilterModel()
Returns the filter model.

Returns:
the filter model.

getFilterOn

public JCheckBox getFilterOn()
Returns a checkbox that shows if the filter displayed is active or not.

Returns:
the 'filter' checkbox

makePanel

protected void makePanel()
Adds the gui components to the FilterTablePanel using a box layout with horizontal orientation. If you override this method, you only need to supply code to add the components to the panel, since an instance of those has already been created.


setDefaultFilter

public void setDefaultFilter(Class columnClass,
                             VisualFilter filter)
Sets the default visual filter for columnClass.

Parameters:
columnClass - the Class with which a visual filter we want to associate
filter - the visual filter to set

update

public void update(TableModel model)
Updates the FilterTablePanel by querying model and recreating the fields that we are able to filter.

Parameters:
model - the TableModel to query

updateUI

public void updateUI()
Resets the UI property with a value from the current look and feel.

Overrides:
updateUI in class JPanel
See Also:
JComponent.updateUI()

Copyright © 2005 Scientific Applications. All Rights Reserved.