org.openide.awt 7.55.1

org.openide.awt
Class QuickSearch

java.lang.Object
  extended by org.openide.awt.QuickSearch

public class QuickSearch
extends Object

Quick search infrastructure for an arbitrary component. When quick search is attached to a component, it listens on key events going to the component and displays a quick search field.

Since:
7.43

Nested Class Summary
static interface QuickSearch.Callback
          Call back interface, that is notified with the submissions to the quick search field.
 
Method Summary
static QuickSearch attach(JComponent component, Object constraints, QuickSearch.Callback callback)
          Attach quick search to a component with given constraints.
static QuickSearch attach(JComponent component, Object constraints, QuickSearch.Callback callback, boolean asynchronous)
          Attach quick search to a component with given constraints.
static QuickSearch attach(JComponent component, Object constraints, QuickSearch.Callback callback, boolean asynchronous, JMenu popupMenu)
          Attach quick search to a component with given constraints.
static QuickSearch attach(JComponent component, Object constraints, QuickSearch.Callback callback, JMenu popupMenu)
          Attach quick search to a component with given constraints.
 void detach()
          Detach the quick search from the component it was attached to.
static String findMaxPrefix(String str1, String str2, boolean ignoreCase)
          Utility method, that finds a greatest common prefix of two supplied strings.
 boolean isAlwaysShown()
          Test whether the quick search field is always shown.
 boolean isEnabled()
          Test whether the quick search is enabled.
protected  void maybeShowPopup(MouseEvent evt, Component comp)
           
 void processKeyEvent(KeyEvent ke)
          Process this key event in addition to the key events obtained from the component we're attached to.
 void setAlwaysShown(boolean alwaysShown)
          Set whether the quick search field should always be shown.
 void setEnabled(boolean enabled)
          Set the enabled state of the quick search.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

attach

public static QuickSearch attach(JComponent component,
                                 Object constraints,
                                 QuickSearch.Callback callback)
Attach quick search to a component with given constraints. It listens on key events going to the component and displays a quick search field.

Parameters:
component - The component to attach to
constraints - The constraints that are used to add the search field to the component. It's passed to Container.add(java.awt.Component, java.lang.Object) when adding the quick search UI to the component.
callback - The call back implementation, which is notified from the quick search field submissions.
Returns:
An instance of QuickSearch class.

attach

public static QuickSearch attach(JComponent component,
                                 Object constraints,
                                 QuickSearch.Callback callback,
                                 boolean asynchronous)
Attach quick search to a component with given constraints. It listens on key events going to the component and displays a quick search field.

Parameters:
component - The component to attach to
constraints - The constraints that are used to add the search field to the component. It's passed to Container.add(java.awt.Component, java.lang.Object) when adding the quick search UI to the component.
callback - The call back implementation, which is notified from the quick search field submissions.
Returns:
An instance of QuickSearch class.

attach

public static QuickSearch attach(JComponent component,
                                 Object constraints,
                                 QuickSearch.Callback callback,
                                 JMenu popupMenu)
Attach quick search to a component with given constraints. It listens on key events going to the component and displays a quick search field.

Parameters:
component - The component to attach to
constraints - The constraints that are used to add the search field to the component. It's passed to Container.add(java.awt.Component, java.lang.Object) when adding the quick search UI to the component.
callback - The call back implementation, which is notified from the quick search field submissions.
popupMenu - A pop-up menu, that is displayed on the find icon, next to the search field. This allows customization of the search criteria. The pop-up menu is taken from JMenu.getPopupMenu().
Returns:
An instance of QuickSearch class.

attach

public static QuickSearch attach(JComponent component,
                                 Object constraints,
                                 QuickSearch.Callback callback,
                                 boolean asynchronous,
                                 JMenu popupMenu)
Attach quick search to a component with given constraints. It listens on key events going to the component and displays a quick search field.

Parameters:
component - The component to attach to
constraints - The constraints that are used to add the search field to the component. It's passed to Container.add(java.awt.Component, java.lang.Object) when adding the quick search UI to the component.
callback - The call back implementation, which is notified from the quick search field submissions.
asynchronous - Set whether the quick search notifies the call back asynchronously, or not. By default, Callback is notified synchronously on EQ thread. If true, three notification methods are called asynchronously on a background thread. These are QuickSearch.Callback.quickSearchUpdate(java.lang.String), Callback#showNextSelection(javax.swing.text.Position.Bias), QuickSearch.Callback.findMaxPrefix(java.lang.String). If false all methods are called synchronously on EQ thread.
popupMenu - A pop-up menu, that is displayed on the find icon, next to the search field. This allows customization of the search criteria. The pop-up menu is taken from JMenu.getPopupMenu().
Returns:
An instance of QuickSearch class.

detach

public void detach()
Detach the quick search from the component it was attached to.


isAlwaysShown

public boolean isAlwaysShown()
Test whether the quick search field is always shown. This is false by default.

Returns:
true when the search field is always shown, false otherwise.
Since:
7.49

setAlwaysShown

public void setAlwaysShown(boolean alwaysShown)
Set whether the quick search field should always be shown.

Parameters:
alwaysShown - true to always show the search field, false otherwise.
Since:
7.49

isEnabled

public boolean isEnabled()
Test whether the quick search is enabled. This is true by default.

Returns:
true when the quick search is enabled, false otherwise.

setEnabled

public void setEnabled(boolean enabled)
Set the enabled state of the quick search. This allows to activate/deactivate the quick search functionality.

Parameters:
enabled - true to enable the quick search, false otherwise.

processKeyEvent

public void processKeyEvent(KeyEvent ke)
Process this key event in addition to the key events obtained from the component we're attached to.

Parameters:
ke - a key event to process.

maybeShowPopup

protected void maybeShowPopup(MouseEvent evt,
                              Component comp)

findMaxPrefix

public static String findMaxPrefix(String str1,
                                   String str2,
                                   boolean ignoreCase)
Utility method, that finds a greatest common prefix of two supplied strings.

Parameters:
str1 - The first string
str2 - The second string
ignoreCase - Whether to ignore case in the comparisons
Returns:
The greatest common prefix of the two strings.

org.openide.awt 7.55.1

Built on June 6 2013.  |  Portions Copyright 1997-2013 Oracle. All rights reserved.