Class AbstractPatternPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable
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
Author:
Jeanette Winzenburg
See Also:
  • Field Details

    • SEARCH_FIELD_LABEL

      public static final String SEARCH_FIELD_LABEL
      property name for nls label name
      See Also:
    • SEARCH_FIELD_MNEMONIC

      public static final String SEARCH_FIELD_MNEMONIC
      property name for nls mnemonic
      See Also:
    • SEARCH_TITLE

      public static final String SEARCH_TITLE
      property name for nls title
      See Also:
    • MATCH_ACTION_COMMAND

      public static final String MATCH_ACTION_COMMAND
      property name for nls command
      See Also:
    • searchLabel

      protected JLabel searchLabel
      label of the search combo.
    • searchField

      protected JTextField searchField
      textFlield of the search combo.
    • matchCheck

      protected JCheckBox matchCheck
      checkBox of the search combo.
    • patternModel

      protected PatternModel patternModel
      Presentation Pattern Model for the Widget
  • Constructor Details

    • AbstractPatternPanel

      public AbstractPatternPanel()
  • Method Details

    • match

      public abstract void match()
      Callback action bound to MATCH_ACTION_COMMAND.
    • getAction

      protected AbstractActionExt getAction(String key)
      convenience method for type-cast to AbstractActionExt.
      Parameters:
      key - Key to retrieve action
      Returns:
      Action bound to this key
      See Also:
    • 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 String getUIString(String key)
      Returns a potentially localized value from the UIManager. The given key is prefixed by this component|s UIPREFIX before doing the lookup. The lookup respects this table's current locale 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 String getUIString(String key, Locale locale)
      Returns a potentially localized value from the UIManager for the given locale. The given key is prefixed by this component's UIPREFIX 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(String command, 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 resources
      methodName - the method on the PatternModel to call on item state changed
      initial - the initial value of the property
      Returns:
      newly created action
    • createBoundAction

      protected AbstractActionExt createBoundAction(String actionCommand, 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 resources
      methodName - the method to call an actionPerformed.
      Returns:
      newly created action
    • setLocale

      public void setLocale(Locale l)

      Overridden to update locale-dependent properties.

      Overrides:
      setLocale in class Component
      Parameters:
      l - the local language
      See Also:
    • updateLocaleState

      protected void updateLocaleState(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?

      Parameters:
      locale - the local language
      See Also:
    • 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 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 DocumentListener getSearchFieldListener()
      Create DocumentListener 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(Locale locale)
      Configures the searchLabel. Here: sets text and mnenomic properties form ui values, configures as label for searchField.
      Parameters:
      locale - the local language
    • 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