Package org.jdesktop.swingx
Class AbstractPatternPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.jdesktop.swingx.JXPanel
-
- org.jdesktop.swingx.AbstractPatternPanel
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
,javax.swing.Scrollable
,AlphaPaintable
,BackgroundPaintable
- Direct Known Subclasses:
JXFindPanel
,JXSearchPanel
public abstract class AbstractPatternPanel extends JXPanel
Common base class of ui clients. Implements basic synchronization between PatternModel state and actions bound to it. PENDING: extending JXPanel is a convenience measure, should be extracted into a dedicated controller. PENDING: should be re-visited when swingx goes binding-aware- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description private ActionContainerFactory
actionFactory
static java.lang.String
MATCH_ACTION_COMMAND
protected javax.swing.JCheckBox
matchCheck
protected PatternModel
patternModel
static java.lang.String
SEARCH_FIELD_LABEL
static java.lang.String
SEARCH_FIELD_MNEMONIC
static java.lang.String
SEARCH_TITLE
protected javax.swing.JTextField
searchField
protected javax.swing.JLabel
searchLabel
-
Fields inherited from class org.jdesktop.swingx.JXPanel
fakeTransparent
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description AbstractPatternPanel()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
bind()
configure and bind components to/from PatternModelprotected void
bindSearchLabel(java.util.Locale locale)
Configures the searchLabel.protected AbstractActionExt
createBoundAction(java.lang.String actionCommand, java.lang.String methodName)
creates, configures and returns a bound action to the given method of this.protected AbstractActionExt
createModelStateAction(java.lang.String command, java.lang.String methodName, boolean initial)
creates, configures and returns a bound state action on a boolean property of the PatternModel.protected PatternModel
createPatternModel()
factory method to create the PatternModel.protected AbstractActionExt
getAction(java.lang.String key)
convenience method for type-cast to AbstractActionExt.protected ActionContainerFactory
getActionContainerFactory()
protected PatternModel
getPatternModel()
returns the patternModel.protected java.beans.PropertyChangeListener
getPatternModelListener()
creates and returns a PropertyChangeListener to the PatternModel.protected javax.swing.event.DocumentListener
getSearchFieldListener()
CreateDocumentListener
for the search field that calls corresponding callback method whenever the search field contents is being changedprotected int
getSearchFieldWidth()
protected java.lang.String
getUIString(java.lang.String key)
Returns a potentially localized value from the UIManager.protected java.lang.String
getUIString(java.lang.String key, java.util.Locale locale)
Returns a potentially localized value from the UIManager for the given locale.protected void
initActions()
creates and registers all actions for the default the actionMap.protected void
initComponents()
Initialize all the incorporated components and modelsprotected void
initExecutables()
creates and registers all "executable" actions.protected void
initPatternActions()
creates actions bound to PatternModel's state.abstract void
match()
Callback action bound to MATCH_ACTION_COMMAND.protected void
refreshDocumentFromModel()
callback method that updates document from the search fieldprotected void
refreshEmptyFromModel()
called from listening to empty property of PatternModel.protected void
refreshModelFromDocument()
callback method from listening to searchField.protected void
refreshPatternFromModel()
called from listening to pattern property of PatternModel.void
setLocale(java.util.Locale l)
protected void
updateLocaleState(java.util.Locale locale)
Updates locale-dependent state.-
Methods inherited from class org.jdesktop.swingx.JXPanel
getAlpha, getBackgroundPainter, getEffectiveAlpha, getPainterChangeListener, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableHeightHint, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollableWidthHint, installRepaintManager, isAlpha, isInheritAlpha, isOpaque, isOpaquePatch, isPaintBorderInsets, isPaintingBackground, isPaintingOrigin, isPatch, isTransparentBackground, paint, paintComponent, paintComponentPatch, setAlpha, setBackgroundPainter, setInheritAlpha, setOpaque, setOpaquePatch, setPaintBorderInsets, setScrollableHeightHint, setScrollableTracksViewportHeight, setScrollableTracksViewportWidth, setScrollableWidthHint, uninstallRepaintManager
-
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintImmediately, paintImmediately, 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
SEARCH_FIELD_LABEL
public static final java.lang.String SEARCH_FIELD_LABEL
- See Also:
- Constant Field Values
-
SEARCH_FIELD_MNEMONIC
public static final java.lang.String SEARCH_FIELD_MNEMONIC
- See Also:
- Constant Field Values
-
SEARCH_TITLE
public static final java.lang.String SEARCH_TITLE
- See Also:
- Constant Field Values
-
MATCH_ACTION_COMMAND
public static final java.lang.String MATCH_ACTION_COMMAND
- See Also:
- Constant Field Values
-
searchLabel
protected javax.swing.JLabel searchLabel
-
searchField
protected javax.swing.JTextField searchField
-
matchCheck
protected javax.swing.JCheckBox matchCheck
-
patternModel
protected PatternModel patternModel
-
actionFactory
private ActionContainerFactory actionFactory
-
-
Method Detail
-
match
public abstract void match()
Callback action bound to MATCH_ACTION_COMMAND.
-
getAction
protected AbstractActionExt getAction(java.lang.String key)
convenience method for type-cast to AbstractActionExt.- Parameters:
key
- Key to retrieve action- Returns:
- Action bound to this key
- See Also:
AbstractActionExt
-
initActions
protected void initActions()
creates and registers all actions for the default the actionMap.
-
initExecutables
protected void initExecutables()
creates and registers all "executable" actions. Meaning: the actions bound to a callback method on this. PENDING: not quite correctly factored? Name?
-
initPatternActions
protected void initPatternActions()
creates actions bound to PatternModel's state.
-
getUIString
protected java.lang.String getUIString(java.lang.String key)
Returns a potentially localized value from the UIManager. The given key is prefixed by this component|sUIPREFIX
before doing the lookup. The lookup respects this table's currentlocale
property. Returns the key, if no value is found.- Parameters:
key
- the bare key to look up in the UIManager.- Returns:
- the value mapped to UIPREFIX + key or key if no value is found.
-
getUIString
protected java.lang.String getUIString(java.lang.String key, java.util.Locale locale)
Returns a potentially localized value from the UIManager for the given locale. The given key is prefixed by this component'sUIPREFIX
before doing the lookup. Returns the key, if no value is found.- Parameters:
key
- the bare key to look up in the UIManager.locale
- the locale use for lookup- Returns:
- the value mapped to UIPREFIX + key in the given locale, or key if no value is found.
-
createModelStateAction
protected AbstractActionExt createModelStateAction(java.lang.String command, java.lang.String methodName, boolean initial)
creates, configures and returns a bound state action on a boolean property of the PatternModel.- Parameters:
command
- the actionCommand - same as key to find localizable resourcesmethodName
- the method on the PatternModel to call on item state changedinitial
- the initial value of the property- Returns:
- newly created action
-
createBoundAction
protected AbstractActionExt createBoundAction(java.lang.String actionCommand, java.lang.String methodName)
creates, configures and returns a bound action to the given method of this.- Parameters:
actionCommand
- the actionCommand, same as key to find localizable resourcesmethodName
- the method to call an actionPerformed.- Returns:
- newly created action
-
setLocale
public void setLocale(java.util.Locale l)
Overridden to update locale-dependent properties.
- Overrides:
setLocale
in classjava.awt.Component
- See Also:
updateLocaleState(Locale)
-
updateLocaleState
protected void updateLocaleState(java.util.Locale locale)
Updates locale-dependent state. Here: updates registered column actions' locale-dependent state.PENDING: Try better to find all column actions including custom additions? Or move to columnControl?
- See Also:
setLocale(Locale)
-
refreshPatternFromModel
protected void refreshPatternFromModel()
called from listening to pattern property of PatternModel. This implementation calls match() if the model is in incremental state.
-
getPatternModel
protected PatternModel getPatternModel()
returns the patternModel. Lazyly creates and registers a propertyChangeListener if null.- Returns:
- current
PatternModel
if it exists or newly created one if it was not initialized before this call
-
createPatternModel
protected PatternModel createPatternModel()
factory method to create the PatternModel. Hook for subclasses to install custom models.- Returns:
- newly created
PatternModel
-
getPatternModelListener
protected java.beans.PropertyChangeListener getPatternModelListener()
creates and returns a PropertyChangeListener to the PatternModel. NOTE: the patternModel is totally under control of this class - currently there's no need to keep a reference to the listener.- Returns:
- created and bound to appropriate callback methods
PropertyChangeListener
-
refreshEmptyFromModel
protected void refreshEmptyFromModel()
called from listening to empty property of PatternModel. this implementation synch's the enabled state of the action with MATCH_ACTION_COMMAND to !empty.
-
refreshModelFromDocument
protected void refreshModelFromDocument()
callback method from listening to searchField.
-
refreshDocumentFromModel
protected void refreshDocumentFromModel()
callback method that updates document from the search field
-
getSearchFieldListener
protected javax.swing.event.DocumentListener getSearchFieldListener()
CreateDocumentListener
for the search field that calls corresponding callback method whenever the search field contents is being changed- Returns:
- newly created
DocumentListener
-
bind
protected void bind()
configure and bind components to/from PatternModel
-
bindSearchLabel
protected void bindSearchLabel(java.util.Locale locale)
Configures the searchLabel. Here: sets text and mnenomic properties form ui values, configures as label for searchField.
-
getActionContainerFactory
protected ActionContainerFactory getActionContainerFactory()
- Returns:
- current
ActionContainerFactory
. Will lazily create new factory if it does not exist
-
initComponents
protected void initComponents()
Initialize all the incorporated components and models
-
getSearchFieldWidth
protected int getSearchFieldWidth()
- Returns:
- width in characters of the search field
-
-