Class SearchAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.search.SearchAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
,AdaptableAction
,ParameterizedAction
,Destroyable
public class SearchAction extends JosmAction implements ParameterizedAction
The search action allows the user to search the data layer using a complex search string.- See Also:
SearchCompiler
,SearchDialog
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SearchAction.CapturingSearchReceiver
This class stores the result of the search in a local variable.(package private) static interface
SearchAction.SearchReceiver
Interfaces implementing this may receive the result of the current search.static class
SearchAction.SearchSettingsActionParameter
ActionParameter
implementation withSearchSetting
as value type.(package private) static class
SearchAction.SearchTask
private static class
SearchAction.SelectSearchReceiver
Select the search result and display a status text for it.-
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_SEARCH_HISTORY_SIZE
The default size of the search historyprivate static SearchSetting
lastSearch
static int
MAX_LENGTH_SEARCH_EXPRESSION_DISPLAY
Maximum number of characters before the search expression is shortened for display purposes.private static AutoCompComboBoxModel<SearchSetting>
model
private static JosmComboBoxModel.Preferences
prefs
preferences reader/writer with automatic transmogrification to and from Stringprivate static java.lang.String
SEARCH_EXPRESSION
-
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
-
-
Constructor Summary
Constructors Constructor Description SearchAction()
Constructs a newSearchAction
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
void
actionPerformed(java.awt.event.ActionEvent e, java.util.Map<java.lang.String,java.lang.Object> parameters)
Invoke action using the given parameters.java.util.List<ActionParameter<?>>
getActionParameters()
Get the list of parameters that describe the action.static java.util.List<java.lang.String>
getSearchExpressionHistory()
Gets a list of all texts that were recently used in the searchstatic java.util.Collection<SearchSetting>
getSearchHistory()
Gets the search historyprotected boolean
listenToSelectionChange()
Overwrite this ifJosmAction.updateEnabledState()
should be called when the selection changed.private static void
loadPrefs()
Load preference values into the modelstatic void
saveToHistory(SearchSetting s)
Saves a search to the search history.static void
search()
Launches the dialog for specifying search criteria and runs a searchstatic void
search(java.lang.String search, SearchMode mode)
Performs the search specified by the search stringsearch
and the search modemode
.static java.util.Collection<IPrimitive>
searchAndReturn(java.lang.String search, SearchMode mode)
Performs the search specified by the search stringsearch
and the search modemode
and returns the result of the search.static void
searchStateless(SearchSetting s)
Performs a stateless search specified by the settings ins
.static void
searchWithHistory(SearchSetting s)
Adds the search specified by the settings ins
to the search history and performs the search.static void
searchWithoutHistory(SearchSetting s)
Performs the search specified by the settings ins
without saving it to search history.static SearchSetting
showSearchDialog(SearchSetting initialValues)
Builds and shows the search dialog.protected void
updateEnabledState()
Refreshes the enabled state-
Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, setHelpId, setToolbarId, setTooltip, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuture
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
DEFAULT_SEARCH_HISTORY_SIZE
public static final int DEFAULT_SEARCH_HISTORY_SIZE
The default size of the search history- See Also:
- Constant Field Values
-
MAX_LENGTH_SEARCH_EXPRESSION_DISPLAY
public static final int MAX_LENGTH_SEARCH_EXPRESSION_DISPLAY
Maximum number of characters before the search expression is shortened for display purposes.- See Also:
- Constant Field Values
-
SEARCH_EXPRESSION
private static final java.lang.String SEARCH_EXPRESSION
- See Also:
- Constant Field Values
-
model
private static final AutoCompComboBoxModel<SearchSetting> model
-
prefs
private static final JosmComboBoxModel.Preferences prefs
preferences reader/writer with automatic transmogrification to and from String
-
lastSearch
private static volatile SearchSetting lastSearch
-
-
Constructor Detail
-
SearchAction
public SearchAction()
Constructs a newSearchAction
.
-
-
Method Detail
-
getSearchHistory
public static java.util.Collection<SearchSetting> getSearchHistory()
Gets the search history- Returns:
- The last searched terms.
-
saveToHistory
public static void saveToHistory(SearchSetting s)
Saves a search to the search history.- Parameters:
s
- The search to save
-
getSearchExpressionHistory
public static java.util.List<java.lang.String> getSearchExpressionHistory()
Gets a list of all texts that were recently used in the search- Returns:
- The list of search texts.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e, java.util.Map<java.lang.String,java.lang.Object> parameters)
Description copied from interface:ParameterizedAction
Invoke action using the given parameters.- Specified by:
actionPerformed
in interfaceParameterizedAction
- Parameters:
e
- the ActionEventparameters
- parameter map
-
showSearchDialog
public static SearchSetting showSearchDialog(SearchSetting initialValues)
Builds and shows the search dialog.- Parameters:
initialValues
- A set of initial values needed in order to initialize the search dialog. If isnull
, then default settings are used.- Returns:
- Returns new
SearchSetting
object containing parameters of the search.
-
search
public static void search()
Launches the dialog for specifying search criteria and runs a search
-
loadPrefs
private static void loadPrefs()
Load preference values into the model
-
searchWithHistory
public static void searchWithHistory(SearchSetting s)
Adds the search specified by the settings ins
to the search history and performs the search.- Parameters:
s
- search settings
-
searchWithoutHistory
public static void searchWithoutHistory(SearchSetting s)
Performs the search specified by the settings ins
without saving it to search history.- Parameters:
s
- search settings
-
search
public static void search(java.lang.String search, SearchMode mode)
Performs the search specified by the search stringsearch
and the search modemode
.- Parameters:
search
- the search string to usemode
- the search mode to use
-
searchStateless
public static void searchStateless(SearchSetting s)
Performs a stateless search specified by the settings ins
.- Parameters:
s
- search settings- Since:
- 15356
-
searchAndReturn
public static java.util.Collection<IPrimitive> searchAndReturn(java.lang.String search, SearchMode mode)
Performs the search specified by the search stringsearch
and the search modemode
and returns the result of the search.- Parameters:
search
- the search string to usemode
- the search mode to use- Returns:
- The result of the search.
- Since:
- 10457, 13950 (signature)
-
listenToSelectionChange
protected boolean listenToSelectionChange()
Description copied from class:JosmAction
Overwrite this ifJosmAction.updateEnabledState()
should be called when the selection changed. Default is true.- Overrides:
listenToSelectionChange
in classJosmAction
- Returns:
true
if aDataSelectionListener
should be registered.
-
updateEnabledState
protected void updateEnabledState()
Refreshes the enabled state- Overrides:
updateEnabledState
in classJosmAction
- See Also:
JosmAction.updateEnabledState(Collection)
,JosmAction.initEnabledState()
,JosmAction.listenToLayerChange()
-
getActionParameters
public java.util.List<ActionParameter<?>> getActionParameters()
Description copied from interface:ParameterizedAction
Get the list of parameters that describe the action.- Specified by:
getActionParameters
in interfaceParameterizedAction
- Returns:
- the list of parameters that describe the action
-
-