diff flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java @ 5312:2c1045a1e3fe

Added new states and transitions to UESK calculation and adjusted states and UI. TODO: Some refactoring and code cleanup.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 14 Mar 2013 17:25:00 +0100
parents 4bf3b89b38d5
children ef32ab3c1679
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java	Thu Mar 14 17:21:00 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java	Thu Mar 14 17:25:00 2013 +0100
@@ -1,22 +1,21 @@
 package de.intevation.flys.client.client.ui;
 
+import java.util.List;
+
+import org.gwtopenmaps.openlayers.client.Map;
+import org.gwtopenmaps.openlayers.client.control.Attribution;
+import org.gwtopenmaps.openlayers.client.layer.WMS;
+import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
+import org.gwtopenmaps.openlayers.client.layer.WMSParams;
+
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
-
-import com.smartgwt.client.types.Encoding;
 import com.smartgwt.client.types.VerticalAlignment;
 import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Button;
 import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLPane;
 import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
 import com.smartgwt.client.widgets.events.VisibilityChangedEvent;
 import com.smartgwt.client.widgets.events.VisibilityChangedHandler;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.widgets.form.fields.UploadItem;
 import com.smartgwt.client.widgets.layout.VLayout;
 import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
@@ -35,17 +34,6 @@
 import de.intevation.flys.client.shared.model.DefaultDataItem;
 import de.intevation.flys.client.shared.model.MapInfo;
 
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import org.gwtopenmaps.openlayers.client.Map;
-import org.gwtopenmaps.openlayers.client.control.Attribution;
-import org.gwtopenmaps.openlayers.client.feature.VectorFeature;
-import org.gwtopenmaps.openlayers.client.format.GeoJSON;
-import org.gwtopenmaps.openlayers.client.layer.WMS;
-import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
-import org.gwtopenmaps.openlayers.client.layer.WMSParams;
-
 
 public class DigitizePanel
 extends SelectProvider
@@ -71,37 +59,17 @@
     @Override
     public Canvas create(DataList list) {
         List<Data> data = list.getAll();
-
         helperContainer.addVisibilityChangedHandler(this);
 
-        Data barriers = null;
-        for (int i = data.size()-1; i >= 0; i--) {
-            Data d = data.get(i);
-            if (d.getLabel().equals(UESK_BARRIERS)) {
-                barriers = d;
-                data.remove(d);
-            }
-        }
-
         DataList clone = (DataList) list.clone();
         List<Data> all = clone.getAll();
         all.remove(UESK_BARRIERS);
 
-        Canvas selectBox = super.create(clone);
+        Canvas widget = createWidget(list);
 
         final Config cfg    = Config.getInstance();
         final String locale = cfg.getLocale();
 
-        DataItem[] obj = barriers.getItems();
-
-        final String[] geojson = new String[1];
-        for (DataItem item: obj) {
-            if (item.getLabel().equals(UESK_BARRIERS)) {
-                geojson[0] = item.getStringValue();
-                break;
-            }
-        }
-
         String river = getDataValue("state.winfo.river", "river");
         mapInfo.getMapInfo(locale, river, new AsyncCallback<MapInfo>() {
             @Override
@@ -114,11 +82,11 @@
 
             @Override
             public void onSuccess(MapInfo info) {
-                createMapWidget(info, geojson[0]);
+                createMapWidget(info);
             }
         });
 
-        return selectBox;
+        return widget;
     }
 
 
@@ -137,10 +105,6 @@
         layout.setAlign(VerticalAlignment.TOP);
         layout.setHeight(25);
 
-        LinkedHashMap<String, String> initial = new LinkedHashMap<String, String>();
-
-        form = new DynamicForm();
-
         int size = data.size();
 
         for (int i = 0; i < size; i++) {
@@ -151,74 +115,10 @@
             label.setHeight(20);
             label.setWidth(400);
 
-            SelectItem combobox = new SelectItem(d.getLabel());
-            combobox.setWidth(250);
-
-            LinkedHashMap<String, String> it = new LinkedHashMap<String, String>();
-
-            boolean  defaultSet = false;
-            boolean  first      = true;
-
-            DataItem def      = d.getDefault();
-            String   defValue = def != null ? def.getStringValue() : null;
-
-            if (defValue != null && defValue.length() > 0) {
-                initial.put(d.getLabel(), def.getStringValue());
-                defaultSet = true;
-            }
-
-            for (DataItem item: d.getItems()) {
-                if (!defaultSet && first) {
-                    initial.put(d.getLabel(), item.getStringValue());
-                    first = false;
-                }
-
-                it.put(item.getStringValue(), item.getLabel());
-            }
-
-            label.setWidth(50);
-            combobox.setValueMap(it);
-            combobox.setShowTitle(false);
-            form.setItems(combobox);
-
-            HTMLPane uploadTargetFrame = new HTMLPane();
-            uploadTargetFrame.setWidth("200px");
-            uploadTargetFrame.setHeight("50px");
-            uploadTargetFrame.setContents(
-                    "<iframe id='uploadTarget' name='uploadTarget' scrolling='no' width=200 height=50 style='border: 0px'></iframe>");
-            uploadTargetFrame.setBorder("0px");
-            uploadTargetFrame.setScrollbarSize(0);
-
-            final DynamicForm uploadForm = new DynamicForm();
-            uploadForm.setAction("flys/fileupload?uuid=" + artifact.getUuid());
-            uploadForm.setTarget("uploadTarget");
-            uploadForm.setEncoding(Encoding.MULTIPART);
-            Label uploadLabel = new Label(MSG.shape_file_upload());
-            uploadLabel.setHeight(20);
-            UploadItem uploadItem = new UploadItem();
-            uploadItem.setShowTitle(false);
-            uploadForm.setFields(uploadItem);
-            Button submit = new Button(MSG.upload_file());
-            submit.addClickHandler(new ClickHandler() {
-                @Override
-                public void onClick(ClickEvent e) {
-                    uploadForm.submitForm();
-                }
-            });
-
             layout.addMember(label);
-            layout.addMember(form);
-            layout.addMember(uploadLabel);
-            layout.addMember(uploadForm);
-            layout.addMember(submit);
             layout.addMember(getNextButton());
-
-            layout.setMembersMargin(10);
-            layout.addMember(uploadTargetFrame);
         }
 
-        form.setValues(initial);
-
         layout.setAlign(VerticalAlignment.TOP);
 
         return layout;
@@ -227,14 +127,12 @@
 
     @Override
     protected Data[] getData() {
-        Data[] data  = super.getData();
-        Data[] total = new Data[2];
+        Data[] total = new Data[1];
 
         if (floodMap != null) {
             DataItem item = new DefaultDataItem(
                 UESK_BARRIERS, UESK_BARRIERS, floodMap.getFeaturesAsGeoJSON());
-            total[0] = data[0];
-            total[1] = new DefaultData(
+            total[0] = new DefaultData(
                 UESK_BARRIERS, null, null, new DataItem[] { item });
         }
         else {
@@ -246,7 +144,7 @@
     }
 
 
-    public void createMapWidget(MapInfo mapInfo, String geojson) {
+    public void createMapWidget(MapInfo mapInfo) {
         mapPanel = new MapPanel(mapInfo, true);
 
         floodMap = mapPanel.getFloodMap();
@@ -266,9 +164,25 @@
         map.addLayer(back);
         map.addLayer(axis);
 
-        if (geojson != null && geojson.length() > 0) {
-            VectorFeature[] features = new GeoJSON().read(geojson);
-            floodMap.getBarrierLayer().addFeatures(features);
+        String hws = getDataValue("state.winfo.uesk.dc-hws", "uesk.hws");
+        if (hws != null && hws.length() > 0) {
+            WMS hwsLayer = getLayer(
+            //TODO: Use Mapinfo to get hws layer infos.
+                mapInfo.getWmsUrl().replace("river", "user"),
+                "ms_layer-hws-lines" + artifact.getUuid(),
+                mapInfo.getProjection(),
+                false);
+            map.addLayer(hwsLayer);
+        }
+        String userRgd = getDataValue("state.winfo.uesk.user-rgd", "uesk.user-rgd");
+        if (userRgd != null && userRgd.length() > 0) {
+            WMS userLayer = getLayer(
+            //TODO: Use Mapinfo to get hws layer infos.
+                mapInfo.getWmsUrl().replace("river", "user"),
+                "ms_layer-user-rgd" + artifact.getUuid(),
+                mapInfo.getProjection(),
+                false);
+            map.addLayer(userLayer);
         }
         map.addControl(new Attribution());
         map.zoomToMaxExtent();

http://dive4elements.wald.intevation.org