Changeset 15734 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2020-01-19T21:21:54+01:00 (5 years ago)
Author:
simon04
Message:

see #17220 - LayerListDialog: re-enable previous offset on click

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

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

    r15733 r15734  
    655655                final TileSourceDisplaySettings displaySettings = ((AbstractTileSourceLayer<?>) layer).getDisplaySettings();
    656656                if (EastNorth.ZERO.equals(displaySettings.getDisplacement())) {
     657                    final boolean hasPreviousOffset = displaySettings.getPreviousOffsetBookmark() != null;
    657658                    cb.setSelected(false);
    658                     cb.setEnabled(false); // TODO: allow reselecting checkbox and thereby setting the old offset again
    659                     cb.setToolTipText(tr("layer is without a user-defined offset"));
     659                    cb.setEnabled(hasPreviousOffset);
     660                    cb.setToolTipText(tr("layer is without a user-defined offset") +
     661                            (hasPreviousOffset ? " " + tr("(click to activate previous offset)") : ""));
    660662                } else {
    661663                    cb.setSelected(true);
     
    11261128                    // reset layer offset
    11271129                    if (l instanceof AbstractTileSourceLayer<?>) {
    1128                         AbstractTileSourceLayer<?> abstractTileSourceLayer = (AbstractTileSourceLayer<?>) l;
    1129                         OffsetBookmark offsetBookmark = abstractTileSourceLayer.getDisplaySettings().getOffsetBookmark();
     1130                        final TileSourceDisplaySettings displaySettings = ((AbstractTileSourceLayer<?>) l).getDisplaySettings();
     1131                        final OffsetBookmark offsetBookmark = displaySettings.getOffsetBookmark();
    11301132                        if (offsetBookmark != null) {
    1131                             abstractTileSourceLayer.getDisplaySettings().setOffsetBookmark(null);
     1133                            displaySettings.setOffsetBookmark(null);
    11321134                            MainApplication.getMenu().imageryMenu.refreshOffsetMenu();
     1135                        } else {
     1136                            displaySettings.setOffsetBookmark(displaySettings.getPreviousOffsetBookmark());
    11331137                        }
    11341138                    }
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java

    r15733 r15734  
    6767    private boolean showErrors;
    6868
     69    private OffsetBookmark previousOffsetBookmark;
    6970    private OffsetBookmark offsetBookmark;
    7071    /**
     
    216217     */
    217218    public void setOffsetBookmark(OffsetBookmark offsetBookmark) {
     219        if (this.offsetBookmark != null) {
     220            this.previousOffsetBookmark = this.offsetBookmark;
     221        }
    218222        this.offsetBookmark = offsetBookmark;
    219223        if (offsetBookmark == null) {
     
    230234    public OffsetBookmark getOffsetBookmark() {
    231235        return this.offsetBookmark;
     236    }
     237
     238    /**
     239     * Gets the offset bookmark previously in use.
     240     * @return the previously used offset bookmark, may be null
     241     */
     242    public OffsetBookmark getPreviousOffsetBookmark() {
     243        return previousOffsetBookmark;
    232244    }
    233245
Note: See TracChangeset for help on using the changeset viewer.