# HG changeset patch # User Ingo Weinzierl # Date 1321629509 0 # Node ID 6c8a29abbe30acf9bdad21be5cbc40bb6682095f # Parent 442ce7d6bc39fedd533c344b008dc7f830a412e2 Added an initial control that allows (when it is finished) adding map layers from external WMS. flys-client/trunk@3291 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 442ce7d6bc39 -r 6c8a29abbe30 flys-client/ChangeLog --- a/flys-client/ChangeLog Fri Nov 18 13:47:07 2011 +0000 +++ b/flys-client/ChangeLog Fri Nov 18 15:18:29 2011 +0000 @@ -1,3 +1,20 @@ +2011-11-18 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java: + New. This control is used to add map layers from external WMS. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.java, + src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties: + Added links to icon and tooltip for ExternalWMSWindow control. + + * src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java: + Added the ExternalWMSWindow control. + + * src/main/webapp/images/addWMS.png: New. Icon for ExternalWMSWindow + control. + 2011-11-18 Ingo Weinzierl * src/main/java/de/intevation/flys/client/server/GFIServiceImpl.java: diff -r 442ce7d6bc39 -r 6c8a29abbe30 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Fri Nov 18 13:47:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Fri Nov 18 15:18:29 2011 +0000 @@ -452,6 +452,10 @@ String getFeatureInfoWindowTitle(); + String addWMS(); + + String addWMSTooltip(); + String adjustElevation(); String adjustElevationTooltip(); diff -r 442ce7d6bc39 -r 6c8a29abbe30 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Fri Nov 18 13:47:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Fri Nov 18 15:18:29 2011 +0000 @@ -233,6 +233,8 @@ getFeatureInfo = images/getFeatureInfo.png getFeatureInfoTooltip = Information Tool getFeatureInfoWindowTitle = Informations for Map Layers. +addWMS = images/addWMS.png +addWMSTooltip = Load layers from external WMS service. adjustElevation = images/adjustElevation.png measureLine = images/measureLine.png measurePolygon = images/measurePolygon.png diff -r 442ce7d6bc39 -r 6c8a29abbe30 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Fri Nov 18 13:47:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Fri Nov 18 15:18:29 2011 +0000 @@ -233,6 +233,8 @@ getFeatureInfo = images/getFeatureInfo.png getFeatureInfoTooltip = Informationswerkzeug getFeatureInfoWindowTitle = Informationen zu Kartenebenen +addWMS = images/addWMS.png +addWMSTooltip = Laden von Kartenebenen eines externen WMS Dienstes. adjustElevation = images/adjustElevation.png measureLine = images/measureLine.png measurePolygon = images/measurePolygon.png diff -r 442ce7d6bc39 -r 6c8a29abbe30 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Fri Nov 18 13:47:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Fri Nov 18 15:18:29 2011 +0000 @@ -233,6 +233,8 @@ getFeatureInfo = images/getFeatureInfo.png getFeatureInfoTooltip = Information Tool getFeatureInfoWindowTitle = Informations for Map Layers. +addWMS = images/addWMS.png +addWMSTooltip = Load layers from external WMS service. adjustElevation = images/adjustElevation.png measureLine = images/measureLine.png measurePolygon = images/measurePolygon.png diff -r 442ce7d6bc39 -r 6c8a29abbe30 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java Fri Nov 18 15:18:29 2011 +0000 @@ -0,0 +1,277 @@ +package de.intevation.flys.client.client.ui.map; + +import com.google.gwt.user.client.ui.TextBox; + +import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.Button; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.Window; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.Layout; +import com.smartgwt.client.widgets.layout.VLayout; + + +public class ExternalWMSWindow extends Window { + + protected Layout inputPanel; + protected Layout infoPanel; + protected Layout layersPanel; + + protected String url; + + + public ExternalWMSWindow() { + super(); + } + + + protected void setUrl(String url) { + this.url = url; + } + + + protected String getUrl() { + return url; + } + + + public void start() { + show(); + centerInPage(); + + goToInputPanel(); + } + + + protected void goToInputPanel() { + clearItems(); + + inputPanel = createInputPanel(); + + addItem(inputPanel); + + setWidth(380); + setHeight(140); + } + + + protected void goToInfoPanel() { + clearItems(); + + infoPanel = createInfoPanel(); + + addItem(infoPanel); + + setWidth(500); + setHeight(500); + } + + + protected void goToLayersPanel() { + clearItems(); + + layersPanel = createLayersPanel(); + + addItem(layersPanel); + + setWidth(500); + setHeight(500); + } + + + protected void clearItems() { + Canvas[] items = getItems(); + + if (items != null) { + for (Canvas item: items) { + removeItem(item); + } + } + } + + + protected Layout createInputPanel() { + // TODO I18N + setTitle("Basis URL des WMS Dienstes"); + + final TextBox url = new TextBox(); + url.setHeight("25px"); + url.setWidth("326px"); + + String oldUrl = getUrl(); + if (oldUrl != null && oldUrl.length() > 0) { + url.setValue(oldUrl); + } + + ClickHandler goHandler = new ClickHandler() { + @Override + public void onClick(ClickEvent e) { + String newUrl = url.getValue(); + + if (!isUrlValid(newUrl)) { + // TODO I18N + SC.warn("Enter a valid URL!"); + return; + } + + setUrl(url.getValue()); + goToInfoPanel(); + } + }; + + ClickHandler cancelHandler = new ClickHandler() { + @Override + public void onClick(ClickEvent e) { + quit(); + } + }; + + VLayout root = new VLayout(); + root.setHeight(75); + root.setMargin(10); + root.setLayoutMargin(10); + + root.addMember(url); + root.addMember(createButtonPanel(null, goHandler, cancelHandler)); + + return root; + } + + + protected Layout createInfoPanel() { + // TODO I18N + setTitle("Informationen des WMS Dienstes"); + + ClickHandler backHandler = new ClickHandler() { + @Override + public void onClick(ClickEvent e) { + goToInputPanel(); + } + }; + + ClickHandler goHandler = new ClickHandler() { + @Override + public void onClick(ClickEvent e) { + goToLayersPanel(); + } + }; + + ClickHandler cancelHandler = new ClickHandler() { + @Override + public void onClick(ClickEvent e) { + quit(); + } + }; + + VLayout root = new VLayout(); + + root.addMember(new Label("STEP 2: " + getUrl())); + + // TODO IMPLEMENT ME + + root.addMember(createButtonPanel(backHandler, goHandler, cancelHandler)); + + return root; + } + + + protected Layout createLayersPanel() { + // TODO I18N + setTitle("Ebene auswählen"); + + ClickHandler backHandler = new ClickHandler() { + @Override + public void onClick(ClickEvent e) { + goToInfoPanel(); + } + }; + + ClickHandler goHandler = new ClickHandler() { + @Override + public void onClick(ClickEvent e) { + goToLayersPanel(); + } + }; + + ClickHandler cancelHandler = new ClickHandler() { + @Override + public void onClick(ClickEvent e) { + quit(); + } + }; + + VLayout root = new VLayout(); + + root.addMember(new Label("STEP 3")); + + // TODO IMPLEMENT ME + + root.addMember(createButtonPanel(backHandler, goHandler, cancelHandler)); + + return root; + } + + + /** + * @param back + * @param ok + * @param cancel + * + * @return + */ + protected Layout createButtonPanel( + ClickHandler backHandler, + ClickHandler goHandler, + ClickHandler cancelHandler + ) { + Button back = new Button("Back"); + Button go = new Button("Go on"); + Button cancel = new Button("Cancel"); + + if (backHandler != null) { + back.addClickHandler(backHandler); + } + else { + back.setDisabled(true); + } + + if (goHandler != null) { + go.addClickHandler(goHandler); + } + else { + go.setDisabled(true); + } + + if (cancelHandler != null) { + cancel.addClickHandler(cancelHandler); + } + else { + cancel.setDisabled(true); + } + + HLayout buttonPanel = new HLayout(); + buttonPanel.setHeight(25); + buttonPanel.setMembersMargin(15); + buttonPanel.setLayoutTopMargin(10); + buttonPanel.addMember(back); + buttonPanel.addMember(go); + buttonPanel.addMember(cancel); + + return buttonPanel; + } + + + protected boolean isUrlValid(String url) { + // TODO Improve URL validation + return !(url == null || url.length() == 0); + } + + + protected void quit() { + destroy(); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 442ce7d6bc39 -r 6c8a29abbe30 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java Fri Nov 18 13:47:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java Fri Nov 18 15:18:29 2011 +0000 @@ -40,6 +40,7 @@ protected Button datacageButton; + protected ImgButton addWMSButton; protected ImgButton zoomToMaxButton; protected ImgButton zoomBoxButton; protected ImgButton zoomOutButton; @@ -95,6 +96,9 @@ if (mapTab != null) { datacageButton = createDatacageControl(); addMember(datacageButton); + + addWMSButton = createWMSControl(); + addMember(addWMSButton); } addMember(zoomToMaxButton); @@ -515,5 +519,19 @@ return button; } + + + protected ImgButton createWMSControl() { + ImgButton add = createButton(MSG.addWMS(), new ClickHandler() { + public void onClick(ClickEvent event) { + // TODO + new ExternalWMSWindow().start(); + } + }); + + add.setTooltip(MSG.addWMSTooltip()); + + return add; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 442ce7d6bc39 -r 6c8a29abbe30 flys-client/src/main/webapp/images/addWMS.png Binary file flys-client/src/main/webapp/images/addWMS.png has changed