Revision: 5593
          http://sourceforge.net/p/jump-pilot/code/5593
Author:   edso
Date:     2017-11-28 16:13:54 +0000 (Tue, 28 Nov 2017)
Log Message:
-----------
restore formatting keeping added WMS Urls

Modified Paths:
--------------
    core/trunk/src/org/openjump/core/ui/plugin/wms/AddWmsLayerWizard.java

Modified: core/trunk/src/org/openjump/core/ui/plugin/wms/AddWmsLayerWizard.java
===================================================================
--- core/trunk/src/org/openjump/core/ui/plugin/wms/AddWmsLayerWizard.java       
2017-11-28 15:01:34 UTC (rev 5592)
+++ core/trunk/src/org/openjump/core/ui/plugin/wms/AddWmsLayerWizard.java       
2017-11-28 16:13:54 UTC (rev 5593)
@@ -1,13 +1,5 @@
 package org.openjump.core.ui.plugin.wms;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.openjump.core.ui.plugin.file.open.ChooseProjectPanel;
-import org.openjump.core.ui.swing.wizard.AbstractWizardGroup;
-
 import com.vividsolutions.jump.I18N;
 import com.vividsolutions.jump.task.TaskMonitor;
 import com.vividsolutions.jump.workbench.WorkbenchContext;
@@ -26,136 +18,131 @@
 import com.vividsolutions.jump.workbench.ui.wizard.WizardDialog;
 import com.vividsolutions.wms.MapLayer;
 import com.vividsolutions.wms.WMService;
+import org.openjump.core.ui.plugin.file.open.ChooseProjectPanel;
+import org.openjump.core.ui.swing.wizard.AbstractWizardGroup;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
 public class AddWmsLayerWizard extends AbstractWizardGroup {
+    
+  public static final String CACHED_URL_KEY = "AddWMSQueryPlugin.CACHED_URL";
 
-    public static final String CACHED_URL_KEY = "AddWMSQueryPlugin.CACHED_URL";
+  public static final String KEY = AddWmsLayerWizard.class.getName();
 
-    public static final String KEY = AddWmsLayerWizard.class.getName();
+  private WorkbenchContext workbenchContext;
 
-    private WorkbenchContext workbenchContext;
+  public static final String[] DEFAULT_URLS = new String[] {
+    "http://deegree3-demo.deegree.org/utah-workspace/services";,
+    "http://demo.opengeo.org/geoserver/wms";,
+    //"http://wiki.openstreetmap.org/wiki/WMS";, // does not work (missing 
WMT_MS_Capabilities)
+    //"http://openaerialmap.org/wms/";,          // does not work (2013-06-09)
+    "http://wms.jpl.nasa.gov/wms.cgi";,
+    //"http://wms.latlon.org/?";,                // does not work (missing 
WMT_MS_Capabilities)
+    "http://ows.terrestris.de/osm/service";,
+    "http://maps.omniscale.net/wms/demo/default/service";,
+    // addresses added on 2013-06-19
+    "http://www2.demis.nl/WMS/wms.ashx?wms=WorldMap";,
+    
"http://gridca.grid.unep.ch/cgi-bin/mapserv?map=/www/geodataportal/htdocs/mod_map/geo_wms.map&";,
+    "http://demo.mapserver.org/cgi-bin/wms";,
+    
"http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/WMS_v1.3/raster/ortofoto_colore_06.map&";,
 
-    public static final String[] DEFAULT_URLS = new String[] {
-            "http://deegree3-demo.deegree.org/utah-workspace/services";,
-            "http://demo.opengeo.org/geoserver/wms";,
-            // "http://wiki.openstreetmap.org/wiki/WMS";, // does not work
-            // (missing WMT_MS_Capabilities)
-            // "http://openaerialmap.org/wms/";, // does not work (2013-06-09)
-            "http://wms.jpl.nasa.gov/wms.cgi";,
-            // "http://wms.latlon.org/?";, // does not work (missing
-            // WMT_MS_Capabilities)
-            "http://ows.terrestris.de/osm/service";,
-            "http://maps.omniscale.net/wms/demo/default/service";,
-            // addresses added on 2013-06-19
-            "http://www2.demis.nl/WMS/wms.ashx?wms=WorldMap";,
-            
"http://gridca.grid.unep.ch/cgi-bin/mapserv?map=/www/geodataportal/htdocs/mod_map/geo_wms.map&";,
-            "http://demo.mapserver.org/cgi-bin/wms";,
+    // 
"http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/WMS_v1.3/raster/ortofoto_colore_06.map&";
+    // //does not work
+    
"http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/WMS_v1.3/raster/ortofoto_colore_12.map&service=wms&request=getCapabilities&version=1.3.0&";,
+    
"https://www.gebco.net/data_and_products/gebco_web_services/web_map_service/mapserv?
 ",
+    
"https://www.gebco.net/data_and_products/gebco_web_services/north_polar_view_wms/mapserv?";,
+    
"https://www.gebco.net/data_and_products/gebco_web_services/south_polar_view_wms/mapserv?";
+  };
 
-            // 
"http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/WMS_v1.3/raster/ortofoto_colore_06.map&";
-            // //does not work
-            
"http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/WMS_v1.3/raster/ortofoto_colore_12.map&service=wms&request=getCapabilities&version=1.3.0&";,
-            
"https://www.gebco.net/data_and_products/gebco_web_services/web_map_service/mapserv?
 ",
-            
"https://www.gebco.net/data_and_products/gebco_web_services/north_polar_view_wms/mapserv?";,
-            
"https://www.gebco.net/data_and_products/gebco_web_services/south_polar_view_wms/mapserv?";
+  private String lastWMSVersion = WMService.WMS_1_1_1;
 
-    };
+  private ChooseProjectPanel chooseProjectPanel;
 
-    private String lastWMSVersion = WMService.WMS_1_1_1;
+  public AddWmsLayerWizard(WorkbenchContext workbenchContext) {
+    
super(I18N.get("org.openjump.core.ui.plugin.wms.AddWmsLayerWizard.Add-WMS-Layer"),
 IconLoader.icon("globe3_16.png"),
+      URLWizardPanel.class.getName());
+    this.workbenchContext = workbenchContext;
+  }
 
-    private ChooseProjectPanel chooseProjectPanel;
+  public void initialize(WorkbenchContext workbenchContext, WizardDialog 
dialog) {
+    removeAllPanels();
 
-    public AddWmsLayerWizard(WorkbenchContext workbenchContext) {
-        super(
-                
I18N.get("org.openjump.core.ui.plugin.wms.AddWmsLayerWizard.Add-WMS-Layer"),
-                IconLoader.icon("globe3_16.png"), URLWizardPanel.class
-                        .getName());
-        this.workbenchContext = workbenchContext;
-    }
 
-    @Override
-    public void initialize(WorkbenchContext workbenchContext,
-            WizardDialog dialog) {
-        removeAllPanels();
+    URLWizardPanel urlPanel = URLWizardPanel.getInstance();
+    chooseProjectPanel = new ChooseProjectPanel(workbenchContext,
+      urlPanel.getID());
+    addPanel(chooseProjectPanel);
 
-        URLWizardPanel urlPanel = URLWizardPanel.getInstance();
-        chooseProjectPanel = new ChooseProjectPanel(workbenchContext,
-                urlPanel.getID());
-        addPanel(chooseProjectPanel);
+    addPanel(urlPanel);
+    addPanel(new MapLayerWizardPanel());
+    addPanel(new SRSWizardPanel());
+    addPanel(new OneSRSWizardPanel());
+  }
 
-        addPanel(urlPanel);
-        addPanel(new MapLayerWizardPanel());
-        addPanel(new SRSWizardPanel());
-        addPanel(new OneSRSWizardPanel());
+  public String getFirstId() {
+    String firstId = super.getFirstId();
+    if (!chooseProjectPanel.hasActiveTaskFrame()
+      && chooseProjectPanel.hasTaskFrames()) {
+      chooseProjectPanel.setNextID(firstId);
+      return chooseProjectPanel.getID();
+    } else {
+      return firstId;
     }
+  }
 
-    @Override
-    public String getFirstId() {
-        String firstId = super.getFirstId();
-        if (!chooseProjectPanel.hasActiveTaskFrame()
-                && chooseProjectPanel.hasTaskFrames()) {
-            chooseProjectPanel.setNextID(firstId);
-            return chooseProjectPanel.getID();
-        } else {
-            return firstId;
-        }
-    }
+  public void run(WizardDialog dialog, TaskMonitor monitor) {
+    chooseProjectPanel.activateSelectedProject();
+    try {
+      PlugInContext context = workbenchContext.createPlugInContext();
+      List<MapLayer> mapLayers = 
(List<MapLayer>)dialog.getData(MapLayerWizardPanel.LAYERS_KEY);
+      String title = mapLayers.get(0).getTitle();
+      List<String> layerNames = toLayerNames(mapLayers);
 
-    @Override
-    public void run(WizardDialog dialog, TaskMonitor monitor) {
-        chooseProjectPanel.activateSelectedProject();
-        try {
-            PlugInContext context = workbenchContext.createPlugInContext();
-            List<MapLayer> mapLayers = (List<MapLayer>) dialog
-                    .getData(MapLayerWizardPanel.LAYERS_KEY);
-            String title = mapLayers.get(0).getTitle();
-            List<String> layerNames = toLayerNames(mapLayers);
+      WMService service = 
(WMService)dialog.getData(URLWizardPanel.SERVICE_KEY);
+      String srs = (String)dialog.getData(SRSWizardPanel.SRS_KEY);
+      String format = ((String)dialog.getData(URLWizardPanel.FORMAT_KEY));
+      WMSLayer layer = new WMSLayer(title, context.getLayerManager(), service,
+        srs, layerNames, format);
 
-            WMService service = (WMService) dialog
-                    .getData(URLWizardPanel.SERVICE_KEY);
-            String srs = (String) dialog.getData(SRSWizardPanel.SRS_KEY);
-            String format = ((String) 
dialog.getData(URLWizardPanel.FORMAT_KEY));
-            WMSLayer layer = new WMSLayer(title, context.getLayerManager(),
-                    service, srs, layerNames, format);
+      LayerNamePanel layerNamePanel = context.getLayerNamePanel();
+      Collection<Category> selectedCategories = 
layerNamePanel.getSelectedCategories();
+      LayerManager mgr = context.getLayerManager();
+      String categoryName = StandardCategoryNames.WORKING;
+      if (!selectedCategories.isEmpty()) {
+        categoryName = selectedCategories.iterator().next().getName();
+      }
+      mgr.addLayerable(categoryName, layer);
+      String[] lastURLs = (String[])dialog.getData(URLWizardPanel.URL_KEY);
+      lastWMSVersion = (String)dialog.getData(URLWizardPanel.VERSION_KEY);
 
-            LayerNamePanel layerNamePanel = context.getLayerNamePanel();
-            Collection<Category> selectedCategories = layerNamePanel
-                    .getSelectedCategories();
-            LayerManager mgr = context.getLayerManager();
-            String categoryName = StandardCategoryNames.WORKING;
-            if (!selectedCategories.isEmpty()) {
-                categoryName = selectedCategories.iterator().next().getName();
-            }
-            mgr.addLayerable(categoryName, layer);
-            String[] lastURLs = (String[]) dialog
-                    .getData(URLWizardPanel.URL_KEY);
-            lastWMSVersion = (String) dialog
-                    .getData(URLWizardPanel.VERSION_KEY);
+      PersistentBlackboardPlugIn.get(context.getWorkbenchContext()).put(
+        CACHED_URL_KEY, toCommaString(lastURLs));
+    } catch (IOException e) {
+      monitor.report(e);
+    }
 
-            PersistentBlackboardPlugIn.get(context.getWorkbenchContext()).put(
-                    CACHED_URL_KEY, toCommaString(lastURLs));
-        } catch (IOException e) {
-            monitor.report(e);
-        }
+  }
 
+  private String toCommaString(String[] values) {
+    StringBuilder string = new StringBuilder();
+    for (int i = 0; i < values.length; i++) {
+      string.append(values[i]);
+      if (i != values.length - 1) {
+        string.append(",");
+      }
     }
+    return string.toString();
+  }
 
-    private String toCommaString(String[] values) {
-        StringBuilder string = new StringBuilder();
-        for (int i = 0; i < values.length; i++) {
-            string.append(values[i]);
-            if (i != values.length - 1) {
-                string.append(",");
-            }
-        }
-        return string.toString();
+  private List<String> toLayerNames(List<MapLayer> mapLayers) {
+    ArrayList<String> names = new ArrayList<String>();
+    for (MapLayer layer : mapLayers) {
+      names.add(layer.getName());
     }
+    return names;
+  }
 
-    private List<String> toLayerNames(List<MapLayer> mapLayers) {
-        ArrayList<String> names = new ArrayList<String>();
-        for (MapLayer layer : mapLayers) {
-            names.add(layer.getName());
-        }
-        return names;
-    }
-
 }


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to