Changeset 8620 in josm for trunk/src/org


Ignore:
Timestamp:
2015-07-26T23:01:55+02:00 (5 years ago)
Author:
wiktorn
Message:

autozoom checkbox display fix in right-menu click

  • proper display of state of checkbox on right-click menu (autoZoom, autoLoad, showErrors)
  • add WMTS layer to session exporter
Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r8612 r8620  
    2020import java.io.File;
    2121import java.io.IOException;
     22import java.lang.reflect.Field;
    2223import java.net.MalformedURLException;
    2324import java.net.URL;
     
    3839import javax.swing.Action;
    3940import javax.swing.BorderFactory;
     41import javax.swing.DefaultButtonModel;
    4042import javax.swing.JCheckBoxMenuItem;
    4143import javax.swing.JLabel;
     
    471473    }
    472474
     475    private class BooleanButtonModel extends DefaultButtonModel {
     476        private Field field;
     477
     478        public BooleanButtonModel(Field field) {
     479            this.field = field;
     480        }
     481
     482        @Override
     483        public boolean isSelected() {
     484            try {
     485                return field.getBoolean(AbstractTileSourceLayer.this);
     486            } catch (IllegalArgumentException | IllegalAccessException e) {
     487                throw new RuntimeException(e);
     488            }
     489        }
     490
     491    }
    473492    /**
    474493     * Creates popup menu items and binds to mouse actions
     
    480499        initTileSource(this.tileSource);
    481500
     501        ;
    482502        // keep them final here, so we avoid namespace clutter in the class
    483503        final JPopupMenu tileOptionMenu = new JPopupMenu();
    484504        final TileHolder clickedTileHolder = new TileHolder();
     505        Field autoZoomField;
     506        Field autoLoadField;
     507        Field showErrorsField;
     508        try {
     509            autoZoomField = AbstractTileSourceLayer.class.getField("autoZoom");
     510            autoLoadField = AbstractTileSourceLayer.class.getDeclaredField("autoLoad");
     511            showErrorsField = AbstractTileSourceLayer.class.getDeclaredField("showErrors");
     512        } catch (NoSuchFieldException | SecurityException e) {
     513            // shoud not happen
     514            throw new RuntimeException(e);
     515        }
    485516
    486517        autoZoom = PROP_DEFAULT_AUTOZOOM.get();
    487518        JCheckBoxMenuItem autoZoomPopup = new JCheckBoxMenuItem();
     519        autoZoomPopup.setModel(new BooleanButtonModel(autoZoomField));
    488520        autoZoomPopup.setAction(new AutoZoomAction());
    489         autoZoomPopup.setSelected(autoZoom);
    490521        tileOptionMenu.add(autoZoomPopup);
    491522
     
    493524        JCheckBoxMenuItem autoLoadPopup = new JCheckBoxMenuItem();
    494525        autoLoadPopup.setAction(new AutoLoadTilesAction());
    495         autoLoadPopup.setSelected(autoLoad);
     526        autoLoadPopup.setModel(new BooleanButtonModel(autoLoadField));
    496527        tileOptionMenu.add(autoLoadPopup);
    497528
     
    504535            }
    505536        });
    506         showErrorsPopup.setSelected(showErrors);
     537        showErrorsPopup.setModel(new BooleanButtonModel(showErrorsField));
    507538        tileOptionMenu.add(showErrorsPopup);
    508539
  • trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java

    r8510 r8620  
    3838import org.openstreetmap.josm.gui.layer.TMSLayer;
    3939import org.openstreetmap.josm.gui.layer.WMSLayer;
     40import org.openstreetmap.josm.gui.layer.WMTSLayer;
    4041import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer;
    4142import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
     
    5455        registerSessionLayerExporter(TMSLayer.class , ImagerySessionExporter.class);
    5556        registerSessionLayerExporter(WMSLayer.class , ImagerySessionExporter.class);
     57        registerSessionLayerExporter(WMTSLayer.class , ImagerySessionExporter.class);
    5658        registerSessionLayerExporter(GpxLayer.class , GpxTracksSessionExporter.class);
    5759        registerSessionLayerExporter(GeoImageLayer.class , GeoImageSessionExporter.class);
Note: See TracChangeset for help on using the changeset viewer.