Changeset 24572 in osm


Ignore:
Timestamp:
2010-12-04T12:14:12+01:00 (14 years ago)
Author:
upliner
Message:

unify remote control feature for WMS and TMS

Location:
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery
Files:
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPlugin.java

    r24501 r24572  
    2929import org.openstreetmap.josm.plugins.imagery.wms.WMSAdapter;
    3030import org.openstreetmap.josm.plugins.imagery.wms.WMSLayer;
    31 import org.openstreetmap.josm.plugins.imagery.wms.WMSRemoteHandler;
    3231import org.openstreetmap.josm.plugins.imagery.wms.io.WMSLayerExporter;
    3332import org.openstreetmap.josm.plugins.imagery.wms.io.WMSLayerImporter;
     
    124123                    // replace command and class when you copy this to some other plug-in
    125124                    // for compatibility with old remotecontrol add leading "/"
    126                     method.invoke(plugin, "/" + WMSRemoteHandler.command, WMSRemoteHandler.class);
     125                    method.invoke(plugin, "/" + ImageryRemoteHandler.command, ImageryRemoteHandler.class);
    127126                    remoteControlInitialized = true;
    128127                }
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPreferenceEditor.java

    r24567 r24572  
    5757    private JButton btnFadeColor;
    5858    private JSlider fadeAmount = new JSlider(0, 100);
     59    private JCheckBox remoteCheckBox;
     60    boolean allowRemoteControl = true;
    5961
    6062    // WMS Settings
     
    6365    JSpinner spinNorth;
    6466    JSpinner spinSimConn;
    65     JCheckBox remoteCheckBox;
    66     boolean allowRemoteControl = true;
    6767    WMSAdapter wmsAdapter = ImageryPlugin.wmsAdapter;
    6868    ImageryPlugin plugin = ImageryPlugin.instance;
     
    226226        p.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
    227227        p.add(this.fadeAmount, GBC.eol().fill(GBC.HORIZONTAL));
    228 
    229228        this.fadeAmount.setValue(ImageryPreferences.PROP_FADE_AMOUNT.get());
     229
     230        allowRemoteControl = ImageryPreferences.PROP_REMOTE_CONTROL.get();
     231        remoteCheckBox = new JCheckBox(tr("Allow remote control (reqires remotecontrol plugin)"), allowRemoteControl);
     232        p.add(remoteCheckBox,GBC.eol().fill(GBC.HORIZONTAL));
     233
    230234        return p;
    231235    }
     
    270274        p.add(overlapPanelSimConn, GBC.eol().fill(GBC.HORIZONTAL));
    271275
    272         allowRemoteControl = Main.pref.getBoolean("wmsplugin.remotecontrol", true);
    273         remoteCheckBox = new JCheckBox(tr("Allow remote control (reqires remotecontrol plugin)"), allowRemoteControl);
    274         JPanel remotePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    275         remotePanel.add(remoteCheckBox);
    276 
    277         p.add(remotePanel,GBC.eol().fill(GBC.HORIZONTAL));
    278276        return p;
    279277    }
     
    314312        p.add(lbl,GBC.std());
    315313        p.add(new JSeparator(), GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 0));
    316         p.add(section,GBC.eol().insets(20,5,0,5));
     314        p.add(section,GBC.eol().insets(20,5,0,10));
    317315    }
    318316
     
    353351        Main.pref.put("wmsplugin.browser", browser.getEditor().getItem().toString());
    354352
    355         Main.pref.put("wmsplugin.remotecontrol", String.valueOf(allowRemoteControl));
    356353
    357354        TMSPreferences.PROP_DEFAULT_AUTOZOOM.put(this.autozoomActive.isSelected());
     
    360357        TMSPreferences.setMinZoomLvl((Integer)this.minZoomLvl.getValue());
    361358
     359        ImageryPreferences.PROP_REMOTE_CONTROL.put(allowRemoteControl);
    362360        ImageryPreferences.PROP_FADE_AMOUNT.put(this.fadeAmount.getValue());
    363361        ImageryPreferences.setFadeColor(this.colFadeColor);
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPreferences.java

    r24548 r24572  
    44
    55import org.openstreetmap.josm.Main;
     6import org.openstreetmap.josm.data.preferences.BooleanProperty;
    67import org.openstreetmap.josm.data.preferences.IntegerProperty;
    78
    89public class ImageryPreferences {
    910
     11    public static final BooleanProperty PROP_REMOTE_CONTROL = new BooleanProperty("imagery.remotecontrol", true);
    1012    public static final IntegerProperty PROP_FADE_AMOUNT = new IntegerProperty("imagery.fade_amount", 0);
    1113
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryRemoteHandler.java

    r24566 r24572  
    1 package org.openstreetmap.josm.plugins.imagery.wms;
     1package org.openstreetmap.josm.plugins.imagery;
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
     
    99
    1010import org.openstreetmap.josm.Main;
    11 import org.openstreetmap.josm.plugins.imagery.ImageryInfo;
    1211import org.openstreetmap.josm.plugins.remotecontrol.PermissionPrefWithDefault;
    1312import org.openstreetmap.josm.plugins.remotecontrol.RequestHandler;
    1413import org.openstreetmap.josm.plugins.remotecontrol.RequestHandlerErrorException;
    1514
    16 public class WMSRemoteHandler extends RequestHandler {
     15public class ImageryRemoteHandler extends RequestHandler {
    1716
    18     public static final String command = "wms";
     17    public static final String command = "imagery";
    1918
    2019    @Override
    2120    public String getPermissionMessage() {
    22         return tr("Remote Control has been asked to load a WMS layer from the following URL:") +
     21        return tr("Remote Control has been asked to load an imagery layer from the following URL:") +
    2322        "<br>" + args.get("url");
    2423    }
     
    2827    {
    2928        return new PermissionPrefWithDefault(
    30                 "wmsplugin.remotecontrol",
     29                "imagery.remotecontrol",
    3130                true,
    32         "RemoteControl: WMS forbidden by preferences");
     31        "RemoteControl: Imagery forbidden by preferences");
    3332    }
    3433
     
    4140    @Override
    4241    protected void handleRequest() throws RequestHandlerErrorException {
     42        if (Main.map == null) //Avoid exception when creating ImageryLayer with null MapFrame
     43            throw new RequestHandlerErrorException();
    4344        String url = args.get("url");
    4445        String title = args.get("title");
    4546        if((title == null) || (title.length() == 0))
    4647        {
    47             title = tr("Remote WMS");
     48            title = tr("Remote imagery");
    4849        }
    4950        String cookies = args.get("cookies");
    50         WMSLayer wmsLayer = new WMSLayer(new ImageryInfo(title, url, cookies));
    51         Main.main.addLayer(wmsLayer);
     51        ImageryLayer imgLayer = ImageryLayer.create(new ImageryInfo(title, url, cookies));
     52        Main.main.addLayer(imgLayer);
    5253
    5354    }
Note: See TracChangeset for help on using the changeset viewer.