Index: /trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSearchDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSearchDialog.java	(revision 5070)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSearchDialog.java	(revision 5071)
@@ -36,4 +36,6 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.SelectionChangedListener;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -52,5 +54,5 @@
 import org.openstreetmap.josm.gui.tagging.TaggingPreset.Text;
 
-public class TaggingPresetSearchDialog extends ExtendedDialog {
+public class TaggingPresetSearchDialog extends ExtendedDialog implements SelectionChangedListener {
 
     private static final int CLASSIFICATION_IN_FAVORITES = 300;
@@ -205,4 +207,5 @@
     private JCheckBox ckSearchInTags;
     private final EnumSet<PresetType> typesInSelection = EnumSet.noneOf(PresetType.class);
+    private boolean typesInSelectionDirty = true;
     private final List<PresetClasification> classifications = new ArrayList<PresetClasification>();
     private ResultListModel lsResultModel = new ResultListModel();
@@ -210,5 +213,5 @@
     private TaggingPresetSearchDialog() {
         super(Main.parent, tr("Presets"), new String[] {tr("Select"), tr("Cancel")});
-        getTypesInSelection();
+        DataSet.addSelectionListener(this);
 
         for (TaggingPreset preset: TaggingPresetPreference.taggingPresets) {
@@ -221,11 +224,21 @@
 
         build();
-        filterPresets("");
+        filterPresets();
+    }
+
+    @Override
+    public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
+        typesInSelectionDirty = true;
     }
 
     @Override
     public ExtendedDialog showDialog() {
+
+        ckOnlyApplicable.setEnabled(!getTypesInSelection().isEmpty());
+        ckOnlyApplicable.setSelected(!getTypesInSelection().isEmpty() && ONLY_APPLICABLE.get());
+        edSearchText.setText("");
+        filterPresets();
+
         super.showDialog();
-        edSearchText.setText("");
         lsResult.getSelectionModel().clearSelection();
         return this;
@@ -241,10 +254,10 @@
             @Override
             public void removeUpdate(DocumentEvent e) {
-                filterPresets(edSearchText.getText());
+                filterPresets();
             }
 
             @Override
             public void insertUpdate(DocumentEvent e) {
-                filterPresets(edSearchText.getText());
+                filterPresets();
 
             }
@@ -252,5 +265,5 @@
             @Override
             public void changedUpdate(DocumentEvent e) {
-                filterPresets(edSearchText.getText());
+                filterPresets();
 
             }
@@ -302,17 +315,10 @@
         ckOnlyApplicable.setText(tr("Show only applicable to selection"));
         pnChecks.add(ckOnlyApplicable);
-
-        if (typesInSelection.isEmpty()) {
-            ckOnlyApplicable.setSelected(false);
-            ckOnlyApplicable.setEnabled(false);
-        } else {
-            ckOnlyApplicable.setSelected(ONLY_APPLICABLE.get());
-            ckOnlyApplicable.addItemListener(new ItemListener() {
-                @Override
-                public void itemStateChanged(ItemEvent e) {
-                    filterPresets(edSearchText.getText());
-                }
-            });
-        }
+        ckOnlyApplicable.addItemListener(new ItemListener() {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
+                filterPresets();
+            }
+        });
 
         ckSearchInTags = new JCheckBox();
@@ -322,5 +328,5 @@
             @Override
             public void itemStateChanged(ItemEvent e) {
-                filterPresets(edSearchText.getText());
+                filterPresets();
             }
         });
@@ -352,7 +358,7 @@
      * @param text
      */
-    private void filterPresets(String text) {
+    private void filterPresets() {
         //TODO Save favorites to file
-        text = text.toLowerCase();
+        String text = edSearchText.getText().toLowerCase();
 
         String[] groupWords;
@@ -379,5 +385,5 @@
                     boolean found = false;
                     for (PresetType type: preset.types) {
-                        if (typesInSelection.contains(type)) {
+                        if (getTypesInSelection().contains(type)) {
                             found = true;
                             break;
@@ -427,18 +433,24 @@
     }
 
-
-    private void getTypesInSelection() {
-        for (OsmPrimitive primitive: Main.main.getCurrentDataSet().getSelected()) {
-            if (primitive instanceof Node) {
-                typesInSelection.add(PresetType.NODE);
-            } else if (primitive instanceof Way) {
-                typesInSelection.add(PresetType.WAY);
-                if (((Way)primitive).isClosed()) {
-                    typesInSelection.add(PresetType.CLOSEDWAY);
-                }
-            } else if (primitive instanceof Relation) {
-                typesInSelection.add(PresetType.RELATION);
-            }
-        }
+    private EnumSet<PresetType> getTypesInSelection() {
+        if (typesInSelectionDirty) {
+            synchronized (typesInSelection) {
+                typesInSelectionDirty = false;
+                typesInSelection.clear();
+                for (OsmPrimitive primitive : Main.main.getCurrentDataSet().getSelected()) {
+                    if (primitive instanceof Node) {
+                        typesInSelection.add(PresetType.NODE);
+                    } else if (primitive instanceof Way) {
+                        typesInSelection.add(PresetType.WAY);
+                        if (((Way) primitive).isClosed()) {
+                            typesInSelection.add(PresetType.CLOSEDWAY);
+                        }
+                    } else if (primitive instanceof Relation) {
+                        typesInSelection.add(PresetType.RELATION);
+                    }
+                }
+            }
+        }
+        return typesInSelection;
     }
 
