Ticket #24333: 24333.patch

File 24333.patch, 1.4 KB (added by GerdP, 7 months ago)

disable radio buttons with need a selection, set mode to replace if search dialog is opened with empty collection (but not when a Filter is created)

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

     
    2828import javax.swing.text.Document;
    2929import javax.swing.text.JTextComponent;
    3030
     31import org.openstreetmap.josm.data.osm.DataSet;
    3132import org.openstreetmap.josm.data.osm.Filter;
    3233import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    3334import org.openstreetmap.josm.data.osm.search.SearchMode;
     
    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    /**