public class QuickSearch extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
QuickSearch.Callback
Call back interface, that is notified with the submissions to the quick search field.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public static QuickSearch attach(JComponent component, Object constraints, QuickSearch.Callback callback)
component
- The component to attach toconstraints
- 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.public static QuickSearch attach(JComponent component, Object constraints, QuickSearch.Callback callback, boolean asynchronous)
component
- The component to attach toconstraints
- 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.public static QuickSearch attach(JComponent component, Object constraints, QuickSearch.Callback callback, JMenu popupMenu)
component
- The component to attach toconstraints
- 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()
.public static QuickSearch attach(JComponent component, Object constraints, QuickSearch.Callback callback, boolean asynchronous, JMenu popupMenu)
component
- The component to attach toconstraints
- 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()
.public void detach()
public boolean isAlwaysShown()
false
by default.true
when the search field is always shown,
false
otherwise.public void setAlwaysShown(boolean alwaysShown)
alwaysShown
- true
to always show the search field,
false
otherwise.public boolean isEnabled()
true
by default.true
when the quick search is enabled,
false
otherwise.public void setEnabled(boolean enabled)
enabled
- true
to enable the quick search,
false
otherwise.public void processKeyEvent(KeyEvent ke)
ke
- a key event to process.protected void maybeShowPopup(MouseEvent evt, Component comp)
public static String findMaxPrefix(String str1, String str2, boolean ignoreCase)
str1
- The first stringstr2
- The second stringignoreCase
- Whether to ignore case in the comparisons