Skip to content

Commit 189bbb0

Browse files
GerdPGerdP
authored andcommitted
fix #24333: Search dialog should not offer some options when nothing is selected and a selection is needed
- disable radio buttons which need a selection, set mode to replace if search dialog is opened with empty collection (but not when a Filter is created) git-svn-id: https://josm.openstreetmap.de/svn/trunk@19414 0c6e7542-c601-0410-84e7-c038aed88b3b
1 parent 18f7f9f commit 189bbb0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/org/openstreetmap/josm/gui/dialogs/SearchDialog.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import javax.swing.text.Document;
2929
import javax.swing.text.JTextComponent;
3030

31+
import org.openstreetmap.josm.data.osm.DataSet;
3132
import org.openstreetmap.josm.data.osm.Filter;
3233
import org.openstreetmap.josm.data.osm.search.SearchCompiler;
3334
import org.openstreetmap.josm.data.osm.search.SearchMode;
@@ -91,6 +92,20 @@ protected SearchDialog(SearchSetting initialValues, AutoCompComboBoxModel<Search
9192
hcbSearchString = new AutoCompComboBox<>(model);
9293
this.searchSettings = new SearchSetting(initialValues);
9394
setContent(buildPanel(options));
95+
96+
// See #24333
97+
if (!(initialValues instanceof Filter)) {
98+
DataSet data = MainApplication.getLayerManager().getActiveDataSet();
99+
if (data != null && data.getSelected().isEmpty()) {
100+
remove.setEnabled(false);
101+
inSelection.setEnabled(false);
102+
if (this.searchSettings.mode == SearchMode.in_selection
103+
|| this.searchSettings.mode == SearchMode.remove) {
104+
this.searchSettings.mode = SearchMode.replace;
105+
replace.setSelected(true);
106+
}
107+
}
108+
}
94109
}
95110

96111
/**

0 commit comments

Comments
 (0)