Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jdesktop.swingx.search
Class SearchFactory

    java.lang.Object
      org.jdesktop.swingx.search.SearchFactory

All Implemented Interfaces:
  UIDependent

    public class SearchFactory

extends java.lang.Object
implements UIDependent

Factory to create, configure and show application consistent search and find widgets. Typically a shared JXFindBar is used for incremental search, while a shared JXFindPanel is used for batch search. This implementation

- JXFindBar - adds and shows it in the target's toplevel container's toolbar (assuming a JXRootPane)
- JXFindPanel - creates a JXDialog, adds and shows the findPanel in the Dialog

PENDING: JW - update (?) views/wiring on focus change. Started brute force - stop searching. This looks extreme confusing for findBars added to ToolBars which are empty except for the findbar. Weird problem if triggered from menu - find widget disappears after having been shown for an instance. Where's the focus? PENDING: add methods to return JXSearchPanels (for use by PatternMatchers).

Author:
  Jeanette Winzenburg

Nested Class Summary
`class` | `SearchFactory.FindRemover`

Field Summary
`protected JXFindBar` | `findBar` the shared find widget for incremental-find.
`protected JXFindPanel` | `findPanel` the shared find widget for batch-find.
`protected javax.swing.JComponent` | `lastFindBarTarget` this is a temporary hack: need to remove the useSearchHighlighter property.

Constructor Summary
`SearchFactory()`

Method Summary
`protected void` | `configureSharedFindBar()` Configures the shared FindBar.
`protected void` | `configureSharedFindPanel()` Configures the shared FindPanel.
`JXFindBar` | `createFindBar()` Factory method to create a JXFindBar.
`JXFindPanel` | `createFindPanel()` Factory method to create a JXFindPanel.
`static SearchFactory` | `getInstance()` Returns the shared SearchFactory.
`javax.swing.KeyStroke` | `getSearchAccelerator()` Returns a common Keystroke for triggering a search.
`JXFindBar` | `getSharedFindBar()` Returns the shared JXFindBar.
`JXFindPanel` | `getSharedFindPanel()` Returns the shared JXFindPanel.
`protected java.awt.Point` | `hideSharedFindPanel(boolean dispose)` Hides the findPanel's toplevel window and returns its location.
`protected void` | `installFindRemover(java.awt.Container target, java.awt.Container findWidget)`
`boolean` | `isUseFindBar(javax.swing.JComponent target, Searchable searchable)` Returns decision about using a batch- vs.
`protected void` | `releaseFindBar()` Pre: findbar != null.
`protected void` | `removeFromParent(javax.swing.JComponent component)` convenience method to remove a component from its parent and revalidate the parent
`static void` | `setInstance(SearchFactory factory)` Sets the shared SearchFactory.
`void` | `setUseFindBar(boolean incremental)` Sets the default search type to incremental or batch, for a true/false boolean.
`void` | `showFindBar(javax.swing.JComponent target, Searchable searchable)` Show a incremental-find widget targeted at the searchable.
`void` | `showFindDialog(javax.swing.JComponent target, Searchable searchable)` Show a batch-find widget targeted at the given Searchable.
`void` | `showFindInput(javax.swing.JComponent target, Searchable searchable)` Shows an appropriate find widget targeted at the searchable.
`protected void` | `stopSearching()`
`void` | `updateUI()` Updates all internal visuals after changing a UI-delegate.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### findPanel

    protected JXFindPanel findPanel

  the shared find widget for batch-find.

### findBar

    protected JXFindBar findBar

  the shared find widget for incremental-find.

### lastFindBarTarget

    protected javax.swing.JComponent lastFindBarTarget

  this is a temporary hack: need to remove the useSearchHighlighter property.

Constructor Detail

### SearchFactory

    public SearchFactory()

Method Detail

### getInstance

    public static SearchFactory getInstance()

  Returns the shared SearchFactory.

  Returns:
    the shared `SearchFactory`

### setInstance

    public static void setInstance(SearchFactory factory)

  Sets the shared SearchFactory.

  Parameters:
    `factory` -

### getSearchAccelerator

    public javax.swing.KeyStroke getSearchAccelerator()

  Returns a common Keystroke for triggering a search. Tries to be OS-specific.

  PENDING: this should be done in the LF and the keyStroke looked up in the UIManager.

  Returns:
    the keyStroke to register with a findAction.

### isUseFindBar

    public boolean isUseFindBar(javax.swing.JComponent target,
                                Searchable searchable)

  Returns decision about using a batch- vs. incremental-find for the searchable. This implementation returns the useFindBar property directly.

  Parameters:
    `target` - - the component associated with the searchable
    `searchable` - - the object to search.
  Returns:
    true if a incremental-find should be used, false otherwise.

### setUseFindBar

    public void setUseFindBar(boolean incremental)

  Sets the default search type to incremental or batch, for a true/false boolean. The default value is false (== batch).

  Parameters:
    `incremental` - a boolean to indicate the default search type, true for incremental and false for batch.

### showFindInput

    public void showFindInput(javax.swing.JComponent target,
                              Searchable searchable)

  Shows an appropriate find widget targeted at the searchable. Opens a batch-find or incremental-find widget based on the return value of `isUseFindBar`.

  Parameters:
    `target` - - the component associated with the searchable
    `searchable` - - the object to search.
  See Also:
    `isUseFindBar(JComponent, Searchable)`, `setUseFindBar(boolean)`

### showFindBar

    public void showFindBar(javax.swing.JComponent target,
                            Searchable searchable)

  Show a incremental-find widget targeted at the searchable. This implementation uses a JXFindBar and inserts it into the target's toplevel container toolbar. PENDING: Nothing shown if there is no toolbar found.

  Parameters:
    `target` - - the component associated with the searchable
    `searchable` - - the object to search.

### getSharedFindBar

    public JXFindBar getSharedFindBar()

  Returns the shared JXFindBar. Creates and configures on first call.

  Returns:
    the shared `JXFindBar`

### createFindBar

    public JXFindBar createFindBar()

  Factory method to create a JXFindBar.

  Returns:
    the `JXFindBar`

### installFindRemover

    protected void installFindRemover(java.awt.Container target,
                                      java.awt.Container findWidget)

### removeFromParent

    protected void removeFromParent(javax.swing.JComponent component)

  convenience method to remove a component from its parent and revalidate the parent

### stopSearching

    protected void stopSearching()

### releaseFindBar

    protected void releaseFindBar()

  Pre: findbar != null.

### configureSharedFindBar

    protected void configureSharedFindBar()

  Configures the shared FindBar. This method is called once after creation of the shared FindBar. Subclasses can override to add configuration code.

  Here: registers a custom action to remove the findbar from its ancestor container. PRE: findBar != null.

### showFindDialog

    public void showFindDialog(javax.swing.JComponent target,
                               Searchable searchable)

  Show a batch-find widget targeted at the given Searchable. This implementation uses a shared JXFindPanel contained JXDialog.

  Parameters:
    `target` - - the component associated with the searchable
    `searchable` - - the object to search.

### getSharedFindPanel

    public JXFindPanel getSharedFindPanel()

  Returns the shared JXFindPanel. Lazyly creates and configures on first call.

  Returns:
    the shared `JXFindPanel`

### createFindPanel

    public JXFindPanel createFindPanel()

  Factory method to create a JXFindPanel.

  Returns:
    `JXFindPanel`

### configureSharedFindPanel

    protected void configureSharedFindPanel()

  Configures the shared FindPanel. This method is called once after creation of the shared FindPanel. Subclasses can override to add configuration code.

  Here: no-op PRE: findPanel != null.

### hideSharedFindPanel

    protected java.awt.Point hideSharedFindPanel(boolean dispose)

  Hides the findPanel's toplevel window and returns its location. If the dispose is true, the findPanel is removed from its parent and the toplevel window is disposed.

  Parameters:
    `dispose` - boolean to indicate whether the findPanels toplevel window should be disposed.
  Returns:
    the location of the window if visible, or the last known location.

### updateUI

    public void updateUI()

  Updates all internal visuals after changing a UI-delegate.

  Specified by:
    `updateUI` in interface `UIDependent`
  See Also:
    `JComponent.updateUI()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010. All Rights Reserved.