[Dive4elements-commits] [PATCH 7 of 8] Added new UI provider for HWS inline DC and shapefile upload

Wald Commits scm-commit at wald.intevation.org
Thu Mar 14 17:27:35 CET 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1363278060 -3600
# Node ID ff9dfc58d0cb441bb27f1905acbd4ceeeaa77a37
# Parent  11c853b0854a3cbd642635e2f106a5e977dfdcd3
Added new UI provider for HWS inline DC and shapefile upload.

diff -r 11c853b0854a -r ff9dfc58d0cb flys-client/src/main/java/de/intevation/flys/client/client/ui/HWSDatacagePanel.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/HWSDatacagePanel.java	Thu Mar 14 17:21:00 2013 +0100
@@ -0,0 +1,129 @@
+package de.intevation.flys.client.client.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import de.intevation.flys.client.shared.model.Data;
+import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
+import de.intevation.flys.client.shared.model.DefaultData;
+import de.intevation.flys.client.shared.model.DefaultDataItem;
+import de.intevation.flys.client.shared.model.Recommendation;
+import de.intevation.flys.client.shared.model.ToLoad;
+import de.intevation.flys.client.shared.model.User;
+
+
+public class HWSDatacagePanel
+extends DatacagePanel
+{
+    public static final String OUT        = "floodmap-hws";
+    public static final String PARAMETERS = "hws:true;load-system:true";
+
+
+    public HWSDatacagePanel() {
+        super();
+    }
+
+
+    public HWSDatacagePanel(User user) {
+        super(user);
+    }
+
+
+    @Override
+    protected void createWidget() {
+        super.createWidget();
+        widget.setIsMutliSelectable(true);
+    }
+
+
+    @Override
+    public String getOuts() {
+        return OUT;
+    }
+
+
+    @Override
+    public String getParameters() {
+        return PARAMETERS;
+    }
+
+
+    @Override
+    public List<String> validate() {
+        List<String> errors = new ArrayList<String>();
+
+        return errors;
+    }
+
+    @Override
+    public Canvas createOld(DataList dataList) {
+        GWT.log("old datacage##########################################");
+        HLayout layout  = new HLayout();
+        VLayout vLayout = new VLayout();
+        layout.setWidth("400px");
+
+        Label label = new Label(dataList.getLabel());
+        label.setWidth("200px");
+
+        int size = dataList.size();
+        for (int i = 0; i < size; i++) {
+            Data data        = dataList.get(i);
+            DataItem[] items = data.getItems();
+
+            for (DataItem item: items) {
+                HLayout hLayout = new HLayout();
+
+                hLayout.addMember(label);
+                hLayout.addMember(new Label(item.getLabel()));
+
+                vLayout.addMember(hLayout);
+                vLayout.setWidth("130px");
+            }
+        }
+
+        Canvas back = getBackButton(dataList.getState());
+
+        layout.addMember(label);
+        layout.addMember(vLayout);
+        layout.addMember(back);
+
+        return layout;
+    }
+
+
+    @Override
+    protected Data[] getData() {
+        String[] selection = this.widget.getSelectionTitles();
+        String result = "";
+        boolean first = true;
+        if (selection != null) {
+            for (String record: selection) {
+                if (first) {
+                    result += record;
+                    first = false;
+                }
+                else {
+                    result += ";" + record;
+                }
+            }
+        }
+        if (result.length() == 0) {
+            result = "none";
+        }
+        Data[] data = new Data[1];
+        DataItem item = new DefaultDataItem(
+                "uesk.hws", "uesk.hws", result);
+        data[0] = new DefaultData("uesk.hws", null, null, new DataItem[] {item});
+
+        return data;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
\ No newline at end of file
diff -r 11c853b0854a -r ff9dfc58d0cb flys-client/src/main/java/de/intevation/flys/client/client/ui/UserRGDProvider.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UserRGDProvider.java	Thu Mar 14 17:21:00 2013 +0100
@@ -0,0 +1,133 @@
+package de.intevation.flys.client.client.ui;
+
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.types.Encoding;
+import com.smartgwt.client.types.VerticalAlignment;
+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.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.UploadItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import de.intevation.flys.client.shared.model.Data;
+import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
+import de.intevation.flys.client.shared.model.DefaultData;
+import de.intevation.flys.client.shared.model.DefaultDataItem;
+
+
+public class UserRGDProvider
+extends SelectProvider
+{
+
+    private HTMLPane uploadTargetFrame;
+    private String uploadFile;
+
+    public UserRGDProvider() {
+        uploadTargetFrame = new HTMLPane();
+    }
+
+    @Override
+    public Canvas create(DataList list) {
+        List<Data> data = list.getAll();
+
+        //Canvas selectBox = super.create(clone);
+        Canvas widget = createWidget(list);
+
+        return widget;
+    }
+
+
+    /**
+     * This method creates the content of the widget.
+     *
+     * @param data The {@link DataList} object.
+     *
+     * @return a combobox.
+     */
+    @Override
+    protected Canvas createWidget(DataList data) {
+        GWT.log("DigitizePanel - createWidget()");
+
+        VLayout layout   = new VLayout();
+        layout.setAlign(VerticalAlignment.TOP);
+        layout.setHeight(25);
+
+        int size = data.size();
+
+        for (int i = 0; i < size; i++) {
+            Data d = data.get(i);
+
+            Label label = new Label(d.getDescription());
+            label.setValign(VerticalAlignment.TOP);
+            label.setHeight(20);
+            label.setWidth(400);
+
+            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);
+            final 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) {
+                    uploadFile = uploadItem.getValueAsString();
+                    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);
+        }
+
+        layout.setAlign(VerticalAlignment.TOP);
+
+        return layout;
+    }
+
+    @Override
+    protected Data[] getData() {
+        Data[] total = new Data[1];
+GWT.log("uploadfile: "+ uploadFile);
+        if (uploadFile != null && uploadFile.length() > 0) {
+            DataItem item = new DefaultDataItem(
+                "uesk.user-rgd", "uesk.user-rgd", uploadFile);
+            total[0] = new DefaultData(
+                "uesk.user-rgd", null, null, new DataItem[] { item });
+        }
+        else {
+            // Happens when OpenLayers is missing
+            DataItem item = new DefaultDataItem(
+                "uesk.user-rgd", "uesk.user-rgd", "none");
+            total[0] = new DefaultData(
+                "uesk.user-rgd", null, null, new DataItem[] { item });
+        }
+
+        return total;
+    }
+}


More information about the Dive4elements-commits mailing list