swingx
Version 2005-08-19

org.jdesktop.swingx
Class SearchFactory

java.lang.Object
  extended by org.jdesktop.swingx.SearchFactory

public class SearchFactory
extends Object

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

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).


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  JComponent lastFindBarTarget
          this is a temporary hack: need to remove the useSearchHighlighter property.
 
Constructor Summary
SearchFactory()
           
 
Method Summary
protected  void configureSharedFindBar()
          called after creation of shared FindBar.
protected  void configureSharedFindPanel()
          called after creation of 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.
 JXFindBar getSharedFindBar()
          returns the shared JXFindBar.
 JXFindPanel getSharedFindPanel()
          returns the shared JXFindPanel.
protected  Point hideSharedFilePanel()
           
protected  void installFindRemover(Container target, Container findWidget)
           
 boolean isUseFindBar(JComponent target, Searchable searchable)
          Returns decision about using a batch- vs. incremental-find for the searchable.
protected  void releaseFindBar()
          Pre: findbar !
protected  void removeFromParent(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 inToolBar)
           
 void showFindBar(JComponent target, Searchable searchable)
          Show a incremental-find widget targeted at the searchable.
 void showFindDialog(JComponent target, Searchable searchable)
          Show a batch-find widget targeted at the given Searchable.
 void showFindInput(JComponent target, Searchable searchable)
          Shows an appropriate find widget targeted at the searchable.
protected  void stopSearching()
           
 
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 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 -

showFindInput

public void showFindInput(JComponent target,
                          Searchable searchable)
Shows an appropriate find widget targeted at the searchable. This implementation opens a batch-find or incremental-find widget based on the showFindInToolBar property (which defaults to false).

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

showFindBar

public void showFindBar(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.

installFindRemover

protected void installFindRemover(Container target,
                                  Container findWidget)

removeFromParent

protected void removeFromParent(JComponent component)
convenience method to remove a component from its parent and revalidate the parent


getSharedFindBar

public JXFindBar getSharedFindBar()
returns the shared JXFindBar. Creates and configures on first call.

Returns:
the shared JXFindBar

configureSharedFindBar

protected void configureSharedFindBar()
called after creation of shared FindBar. Subclasses can add configuration code. Here: registers a custom action to remove the findbar from its ancestor container. PRE: findBar != null.


createFindBar

public JXFindBar createFindBar()
Factory method to create a JXFindBar.

Returns:
the JXFindBar

getSharedFindPanel

public JXFindPanel getSharedFindPanel()
returns the shared JXFindPanel. Creates and configures on first call.

Returns:
the shared JXFindPanel

configureSharedFindPanel

protected void configureSharedFindPanel()
called after creation of shared FindPanel. Subclasses can add configuration code. Here: no-op PRE: findPanel != null.


createFindPanel

public JXFindPanel createFindPanel()
Factory method to create a JXFindPanel.

Returns:
JXFindPanel

showFindDialog

public void showFindDialog(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.

hideSharedFilePanel

protected Point hideSharedFilePanel()

stopSearching

protected void stopSearching()

releaseFindBar

protected void releaseFindBar()
Pre: findbar != null.


isUseFindBar

public boolean isUseFindBar(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 inToolBar)
Parameters:
inToolBar -

swingx
Version 2005-08-19