Index: trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java	(revision 2450)
+++ trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java	(revision 2451)
@@ -8,6 +8,9 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.LinkedList;
+import java.util.List;
 
 import javax.swing.ButtonGroup;
@@ -17,14 +20,14 @@
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
-import javax.swing.JTextField;
 
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Filter;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
 import org.openstreetmap.josm.tools.GBC;
 import org.openstreetmap.josm.tools.Shortcut;
-import org.openstreetmap.josm.data.osm.Filter;
-import org.openstreetmap.josm.data.osm.DataSet;
 
 public class SearchAction extends JosmAction{
@@ -49,16 +52,7 @@
         if (!isEnabled())
             return;
-        if (Main.map == null) {
-            JOptionPane.showMessageDialog(
-                    Main.parent,
-                    tr("Can't search because there is no loaded data."),
-                    tr("Warning"),
-                    JOptionPane.WARNING_MESSAGE
-            );
-            return;
-        }
         SearchSetting s = lastSearch;
         if (s == null) {
-            s = new SearchSetting("", SearchMode.replace, false, false);
+            s = new SearchSetting("", SearchMode.replace, false /* case insensitive */, false /* no regexp */);
         }
         SearchSetting se = showSearchDialog(s);
@@ -68,9 +62,29 @@
     }
 
+    public static List<String> getSearchExpressionHistory() {
+        ArrayList<String> ret = new ArrayList<String>(searchHistory.size());
+        for (SearchSetting ss: searchHistory) {
+            ret.add(ss.text);
+        }
+        return ret;
+    }
+
     public static SearchSetting showSearchDialog(SearchSetting initialValues) {
+
+        // -- prepare the combo box with the search expressions
+        //
         JLabel label = new JLabel( initialValues instanceof Filter ? tr("Please enter a filter string.") : tr("Please enter a search string."));
-        final JTextField input = new JTextField(initialValues.text);
-        input.selectAll();
-        input.requestFocusInWindow();
+        final HistoryComboBox hcbSearchString = new HistoryComboBox();
+        hcbSearchString.setText(initialValues.text);
+        hcbSearchString.getEditor().selectAll();
+        hcbSearchString.getEditor().getEditorComponent().requestFocusInWindow();
+        hcbSearchString.setToolTipText(tr("Enter the search expression"));
+        // we have to reverse the history, because ComboBoxHistory will reverse it again
+        // in addElement()
+        //
+        List<String> searchExpressionHistory = getSearchExpressionHistory();
+        Collections.reverse(searchExpressionHistory);
+        hcbSearchString.setPossibleItems(searchExpressionHistory);
+
         JRadioButton replace = new JRadioButton(tr("replace selection"), initialValues.mode == SearchMode.replace);
         JRadioButton add = new JRadioButton(tr("add to selection"), initialValues.mode == SearchMode.add);
@@ -88,7 +102,6 @@
         JPanel left = new JPanel(new GridBagLayout());
         left.add(label, GBC.eop());
-        left.add(input, GBC.eop().fill(GBC.HORIZONTAL));
+        left.add(hcbSearchString, GBC.eop().fill(GBC.HORIZONTAL));
         left.add(replace, GBC.eol());
-        DataSet ds = Main.main.getCurrentDataSet();
         left.add(add, GBC.eol());
         left.add(remove, GBC.eol());
@@ -147,5 +160,5 @@
                 : (add.isSelected() ? SearchAction.SearchMode.add
                         : (remove.isSelected() ? SearchAction.SearchMode.remove : SearchAction.SearchMode.in_selection));
-        initialValues.text = input.getText();
+        initialValues.text = hcbSearchString.getText();
         initialValues.mode = mode;
         initialValues.caseSensitive = caseSensitive.isSelected();
@@ -164,5 +177,6 @@
             searchHistory.addFirst(new SearchSetting(s));
         }
-        while (searchHistory.size() > Main.pref.getInteger("search.history-size", DEFAULT_SEARCH_HISTORY_SIZE)) {
+        int maxsize = Main.pref.getInteger("search.history-size", DEFAULT_SEARCH_HISTORY_SIZE);
+        while (searchHistory.size() > maxsize) {
             searchHistory.removeLast();
         }
