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 classSearchAction.CapturingSearchReceiverThis class stores the result of the search in a local variable.(package private) static interfaceSearchAction.SearchReceiverInterfaces implementing this may receive the result of the current search.static classSearchAction.SearchSettingsActionParameterActionParameterimplementation withSearchSettingas value type.(package private) static classSearchAction.SearchTaskprivate static classSearchAction.SelectSearchReceiverSelect 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 intDEFAULT_SEARCH_HISTORY_SIZEThe default size of the search historyprivate static SearchSettinglastSearchstatic intMAX_LENGTH_SEARCH_EXPRESSION_DISPLAYMaximum number of characters before the search expression is shortened for display purposes.private static AutoCompComboBoxModel<SearchSetting>modelprivate static JosmComboBoxModel.Preferencesprefspreferences reader/writer with automatic transmogrification to and from Stringprivate static java.lang.StringSEARCH_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 voidactionPerformed(java.awt.event.ActionEvent e)voidactionPerformed(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 booleanlistenToSelectionChange()Overwrite this ifJosmAction.updateEnabledState()should be called when the selection changed.private static voidloadPrefs()Load preference values into the modelstatic voidsaveToHistory(SearchSetting s)Saves a search to the search history.static voidsearch()Launches the dialog for specifying search criteria and runs a searchstatic voidsearch(java.lang.String search, SearchMode mode)Performs the search specified by the search stringsearchand the search modemode.static java.util.Collection<IPrimitive>searchAndReturn(java.lang.String search, SearchMode mode)Performs the search specified by the search stringsearchand the search modemodeand returns the result of the search.static voidsearchStateless(SearchSetting s)Performs a stateless search specified by the settings ins.static voidsearchWithHistory(SearchSetting s)Adds the search specified by the settings insto the search history and performs the search.static voidsearchWithoutHistory(SearchSetting s)Performs the search specified by the settings inswithout saving it to search history.static SearchSettingshowSearchDialog(SearchSetting initialValues)Builds and shows the search dialog.protected voidupdateEnabledState()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:
actionPerformedin 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:ParameterizedActionInvoke action using the given parameters.- Specified by:
actionPerformedin 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
SearchSettingobject 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 insto 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 inswithout 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 stringsearchand 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 stringsearchand the search modemodeand 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:JosmActionOverwrite this ifJosmAction.updateEnabledState()should be called when the selection changed. Default is true.- Overrides:
listenToSelectionChangein classJosmAction- Returns:
trueif aDataSelectionListenershould be registered.
-
updateEnabledState
protected void updateEnabledState()
Refreshes the enabled state- Overrides:
updateEnabledStatein classJosmAction- See Also:
JosmAction.updateEnabledState(Collection),JosmAction.initEnabledState(),JosmAction.listenToLayerChange()
-
getActionParameters
public java.util.List<ActionParameter<?>> getActionParameters()
Description copied from interface:ParameterizedActionGet the list of parameters that describe the action.- Specified by:
getActionParametersin interfaceParameterizedAction- Returns:
- the list of parameters that describe the action
-
-