Changeset 18631 in josm


Ignore:
Timestamp:
2023-01-11T17:10:44+01:00 (15 months ago)
Author:
taylor.smock
Message:

See #22378: Fix hover preview setting changes not being applied immediately (patch by Woazboat)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r18586 r18631  
    268268    public static final CachingProperty<Boolean> PROP_PREVIEW_ON_HOVER_PRIORITIZE_SELECTION =
    269269        new BooleanProperty("propertiesdialog.preview-on-hover.always-show-selected", true).cached();
     270    private final HoverPreviewPreferSelectionPropListener hoverPreviewPrioritizeSelectionPropListener =
     271        new HoverPreviewPreferSelectionPropListener();
    270272
    271273    /**
     
    328330
    329331        PROP_PREVIEW_ON_HOVER.addListener(hoverPreviewPropListener);
     332        PROP_PREVIEW_ON_HOVER_PRIORITIZE_SELECTION.addListener(hoverPreviewPrioritizeSelectionPropListener);
    330333    }
    331334
     
    645648        TaggingPresets.removeListener(this);
    646649        PROP_PREVIEW_ON_HOVER.removeListener(hoverPreviewPropListener);
     650        PROP_PREVIEW_ON_HOVER_PRIORITIZE_SELECTION.removeListener(hoverPreviewPrioritizeSelectionPropListener);
    647651        Container parent = pluginHook.getParent();
    648652        if (parent != null) {
     
    665669
    666670        // Temporarily disable listening to primitive mouse hover events while we have a selection as that takes priority
    667         if (PROP_PREVIEW_ON_HOVER.get() && PROP_PREVIEW_ON_HOVER_PRIORITIZE_SELECTION.get()) {
     671        if (Boolean.TRUE.equals(PROP_PREVIEW_ON_HOVER.get())) {
    668672            if (newSel.isEmpty()) {
    669673                MainApplication.getMap().mapView.addPrimitiveHoverListener(this);
    670             } else {
     674            } else if (Boolean.TRUE.equals(PROP_PREVIEW_ON_HOVER_PRIORITIZE_SELECTION.get())) {
    671675                MainApplication.getMap().mapView.removePrimitiveHoverListener(this);
    672676            }
     
    15271531        @Override
    15281532        public void valueChanged(ValueChangeEvent<? extends Boolean> e) {
    1529             if (e.getProperty().get() && isDialogShowing()) {
     1533            if (Boolean.TRUE.equals(e.getProperty().get()) && isDialogShowing()) {
    15301534                MainApplication.getMap().mapView.addPrimitiveHoverListener(PropertiesDialog.this);
    1531             } else if (!e.getProperty().get()) {
     1535            } else if (Boolean.FALSE.equals(e.getProperty().get())) {
    15321536                MainApplication.getMap().mapView.removePrimitiveHoverListener(PropertiesDialog.this);
    15331537            }
    15341538        }
    15351539    }
     1540
     1541    /*
     1542     * Ensure HoverListener is re-added when selection priority is disabled while something is selected.
     1543     * Otherwise user would need to change selection to see the preference change take effect.
     1544     */
     1545    private class HoverPreviewPreferSelectionPropListener implements ValueChangeListener<Boolean> {
     1546        @Override
     1547        public void valueChanged(ValueChangeEvent<? extends Boolean> e) {
     1548            if (Boolean.FALSE.equals(e.getProperty().get()) &&
     1549                Boolean.TRUE.equals(PROP_PREVIEW_ON_HOVER.get()) &&
     1550                isDialogShowing()) {
     1551                MainApplication.getMap().mapView.addPrimitiveHoverListener(PropertiesDialog.this);
     1552            }
     1553        }
     1554    }
    15361555}
Note: See TracChangeset for help on using the changeset viewer.