Skip to content

Commit

Permalink
fix #23430: Resetting preference validator.selectionFilter results in…
Browse files Browse the repository at this point in the history
… broken validator

- always set filter when selection was changed
- updateSelection when preferences were changed so that a change of the preference `validator.selectionFilter` is applied immediately

git-svn-id: https://josm.openstreetmap.de/svn/trunk@18951 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
GerdP authored and GerdP committed Jan 23, 2024
1 parent 047f2c5 commit 180811e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
import org.openstreetmap.josm.io.OsmTransferException;
import org.openstreetmap.josm.spi.preferences.Config;
import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;
import org.openstreetmap.josm.tools.ImageProvider;
import org.openstreetmap.josm.tools.InputMapUtils;
import org.openstreetmap.josm.tools.JosmRuntimeException;
Expand Down Expand Up @@ -587,12 +588,10 @@ public void visit(TestError error) {
* @param newSelection The new selection
*/
public void updateSelection(Collection<? extends OsmPrimitive> newSelection) {
if (!Config.getPref().getBoolean(ValidatorPrefHelper.PREF_FILTER_BY_SELECTION, false))
return;
if (newSelection.isEmpty()) {
if (newSelection.isEmpty() || !Config.getPref().getBoolean(ValidatorPrefHelper.PREF_FILTER_BY_SELECTION, false))
tree.setFilter(null);
}
tree.setFilter(new HashSet<>(newSelection));
else
tree.setFilter(new HashSet<>(newSelection));
}

@Override
Expand Down Expand Up @@ -730,4 +729,16 @@ public void destroy() {
ignoreForNowAction.destroy();
}
}

@Override
public void preferenceChanged(PreferenceChangeEvent e) {
super.preferenceChanged(e);
// see #23430: update selection so that filters are applied
DataSet ds = MainApplication.getLayerManager().getActiveDataSet();
if (ds != null) {
updateSelection(ds.getAllSelected());
}

}

}

0 comments on commit 180811e

Please sign in to comment.