net.coderazzi.filters.gui.editor
Class FilterEditor
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
net.coderazzi.filters.gui.editor.FilterEditor
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable
public class FilterEditor
- extends JComponent
Custom component to handle the filter' editors
It includes:
- A editor component, usually a text field to enter the filter text.
- A popup menu that contains both history and predefined option elements.
- An arrow button to display the popup menu.
The component keeps the same look and feel under all cases (being editable or not, having
custom cell renderers or not). Mixing therefore different editors under the same filter header
should keep the look and feel consistency.
- See Also:
- Serialized Form
|
Method Summary |
void |
addOptions(Collection<?> options)
Adds the options to the current set. |
void |
clearOptions()
Clears any options currently defined, including the current history |
void |
detach()
Diposes the editor, not to be used again |
Object |
getContent()
Returns the current editor's content |
Color |
getDisabledForeground()
Returns the color used to represent disabled state |
Color |
getErrorForeground()
Returns the color used to show filter's errors |
IFilter |
getFilter()
Returns the IFilter associated to the editor's content |
int |
getFilterPosition()
Returns the filter position associated to this editor |
ListCellRenderer |
getListCellRenderer()
Returns the associated ListCellRenderer |
int |
getMaxHistory()
Returns the maximum history size, as defined by the user.
This is not the real maximum history size, as it depends on the max number of visible rows
and whether the popup contains also options or only history |
int |
getMaxVisibleRows()
Returns the maximum number of visible rows in the popup menu |
IFilterTextParser |
getTextParser()
Returns the associated IFilterTextParser |
boolean |
isAutoOptions()
Returns true if the editor is using autoOptions |
boolean |
isEditable()
Returns the editable flag |
void |
resetFilter()
Resets the filter, which implies:
Content set to empty
If it has autooptions, they are recreated
Without autooptions, if there is a renderer, nothing else is done
Without autoptions, and with no renderer:
History is lost
Options are removed
It becomes editable
|
void |
setAutoOptions(TableModel tableModel)
Using autoOptions, the options displayed on the popup menu are automatically extracted
from the associated TableModel. |
void |
setBackground(Color bg)
|
void |
setContent(Object content)
Sets the content, adapted to the editors' type |
void |
setDisabledForeground(Color fg)
Sets the color used to represent disabled state |
void |
setEditable(boolean enable)
Defines the editor, if text based -i.e., without associated ListCellRenderer,
as editable: this flag means that the user can enter any text, not being limited to the
existing options |
void |
setEnabled(boolean enabled)
Enabled/Disables the editor, and the associate filter |
void |
setErrorForeground(Color fg)
Sets the color used to show filter's errors (invalid syntax) |
void |
setFilterPosition(int filterPosition)
Defines the filter position associated to this editor. |
void |
setFont(Font font)
|
void |
setForeground(Color fg)
|
void |
setFormat(Format format)
Defines the format, used in the options list to convert content into strings -if needed- |
void |
setListCellRenderer(ListCellRenderer renderer)
Sets the ListCellRenderer for the options / history. |
void |
setMaxHistory(int size)
Limits the history size. |
void |
setMaxVisibleRows(int maxVisibleRows)
Sets the maximum number of visible rows in the popup menu (a minimum is always enforced) |
void |
setOptions(Collection<?> options)
Sets the available options, shown on the popup menu |
void |
setTextParser(IFilterTextParser parser)
Sets the IFilterTextParser; if the editor does not have a
ListCellRenderer, a parser is mandatory |
void |
unsetAutoOptions()
Unsets the autoOptions flag |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
| 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, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, 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, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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 |
FilterEditor
public FilterEditor()
setMaxVisibleRows
public void setMaxVisibleRows(int maxVisibleRows)
- Sets the maximum number of visible rows in the popup menu (a minimum is always enforced)
getMaxVisibleRows
public int getMaxVisibleRows()
- Returns the maximum number of visible rows in the popup menu
setMaxHistory
public void setMaxHistory(int size)
- Limits the history size.
This limit is only used when the popup contains also options. Otherwise, the
maximum history size corresponds to the maximum number of visible rows
getMaxHistory
public int getMaxHistory()
- Returns the maximum history size, as defined by the user.
This is not the real maximum history size, as it depends on the max number of visible rows
and whether the popup contains also options or only history
getFilter
public IFilter getFilter()
- Returns the
IFilter associated to the editor's content
getContent
public Object getContent()
- Returns the current editor's content
setContent
public void setContent(Object content)
- Sets the content, adapted to the editors' type
setEnabled
public void setEnabled(boolean enabled)
- Enabled/Disables the editor, and the associate filter
- Overrides:
setEnabled in class JComponent
setBackground
public void setBackground(Color bg)
- Overrides:
setBackground in class JComponent
setErrorForeground
public void setErrorForeground(Color fg)
- Sets the color used to show filter's errors (invalid syntax)
getErrorForeground
public Color getErrorForeground()
- Returns the color used to show filter's errors
setDisabledForeground
public void setDisabledForeground(Color fg)
- Sets the color used to represent disabled state
getDisabledForeground
public Color getDisabledForeground()
- Returns the color used to represent disabled state
setForeground
public void setForeground(Color fg)
- Overrides:
setForeground in class JComponent
setFont
public void setFont(Font font)
- Overrides:
setFont in class JComponent
detach
public void detach()
- Diposes the editor, not to be used again
resetFilter
public void resetFilter()
- Resets the filter, which implies:
- Content set to empty
- If it has autooptions, they are recreated
- Without autooptions, if there is a renderer, nothing else is done
- Without autoptions, and with no renderer:
- History is lost
-
- Options are removed
- It becomes editable
setTextParser
public void setTextParser(IFilterTextParser parser)
- Sets the
IFilterTextParser; if the editor does not have a
ListCellRenderer, a parser is mandatory
getTextParser
public IFilterTextParser getTextParser()
- Returns the associated
IFilterTextParser
setFilterPosition
public void setFilterPosition(int filterPosition)
- Defines the filter position associated to this editor. It corresponds to the table's model
getFilterPosition
public int getFilterPosition()
- Returns the filter position associated to this editor
setFormat
public void setFormat(Format format)
- Defines the format, used in the options list to convert content into strings -if needed-
setOptions
public void setOptions(Collection<?> options)
- Sets the available options, shown on the popup menu
addOptions
public void addOptions(Collection<?> options)
- Adds the options to the current set. If there is no
ListCellRenderer defined,
the content is stringfied and sorted.
Duplicates are always removed.
clearOptions
public void clearOptions()
- Clears any options currently defined, including the current history
setListCellRenderer
public void setListCellRenderer(ListCellRenderer renderer)
- Sets the
ListCellRenderer for the options / history.
It also affectes to how the content is rendered
If not null, the content cannot be text-edited anymore
- Parameters:
renderer -
getListCellRenderer
public ListCellRenderer getListCellRenderer()
- Returns the associated
ListCellRenderer
setEditable
public void setEditable(boolean enable)
- Defines the editor, if text based -i.e., without associated
ListCellRenderer,
as editable: this flag means that the user can enter any text, not being limited to the
existing options
isEditable
public boolean isEditable()
- Returns the editable flag
- See Also:
setEditable(boolean)
setAutoOptions
public void setAutoOptions(TableModel tableModel)
- Using autoOptions, the options displayed on the popup menu are automatically extracted
from the associated
TableModel.
- Parameters:
tableModel - can be set to null unset the flag
isAutoOptions
public boolean isAutoOptions()
- Returns true if the editor is using autoOptions
unsetAutoOptions
public void unsetAutoOptions()
- Unsets the autoOptions flag
Copyright © 2010 coderazzi. All Rights Reserved.