changeset 9068:a5cf8d7bff3c

access uinfo.salx; tablePanel edit/non-edit merge
author gernotbelger
date Mon, 14 May 2018 18:24:35 +0200
parents 2ed3824a3d53
children 1ffd38826175
files artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SuperVegZonesTablePanel.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java
diffstat 6 files changed, 310 insertions(+), 369 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java	Mon May 14 14:59:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java	Mon May 14 18:24:35 2018 +0200
@@ -27,6 +27,11 @@
 
     static final String FIELD_DIFFID_CURRENT = "diffid_current";
     static final String FIELD_DIFFID_HIST = "diffid_historical";
+    // calculation_mode
+    // ld_from , ld_to
+    // use_scenario (boolean)
+    // ld_from_part; ld_to_part
+    // scenario_selection (mögliche Werte:"scenarioType.option1" "scenarioType.option2" "scenarioType.option3"
 
     public SalixLineAccess(final UINFOArtifact artifact) {
         super(artifact);
@@ -42,4 +47,22 @@
         return new DoubleRange(from, to);
     }
 
+    public boolean getUseScenario() {
+        return super.getBoolean("use_scenario");
+    }
+
+    public String getScenario() {
+        if (getUseScenario()) {
+            return getString("scenario_selection");
+        }
+        return null;
+    }
+
+    public double getFromPart() {
+        return super.getDouble("ld_from_part");
+    }
+
+    public double getToPart() {
+        return super.getDouble("ld_to_part");
+    }
 }
\ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java	Mon May 14 14:59:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java	Mon May 14 18:24:35 2018 +0200
@@ -49,6 +49,18 @@
         final DoubleRange calcRange = null;
         final RiverInfo riverInfo = new RiverInfo(river);
 
+        final SalixLineAccess accessSalix = new SalixLineAccess(uinfo);
+        final DoubleRange range = accessSalix.getRange();
+        final boolean useScenario = accessSalix.getUseScenario();
+        final String selectedScenario = accessSalix.getScenario();
+        final double fromPart = accessSalix.getFromPart();
+        final double toPart = accessSalix.getToPart();
+        // calculation_mode
+        // ld_from , ld_to
+        // use_scenario (boolean)
+        // ld_from_part; ld_to_part
+        // scenario_selection (mögliche Werte:"scenarioType.option1" "scenarioType.option2" "scenarioType.option3"
+
         final SalixLineCalculationResults results = new SalixLineCalculationResults(calcModeLabel, user, riverInfo, calcRange);
 
         final Collection<ResultRow> rows = new ArrayList<>();
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java	Mon May 14 14:59:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java	Mon May 14 18:24:35 2018 +0200
@@ -51,7 +51,7 @@
         final VegetationZonesCalculationResults results = new VegetationZonesCalculationResults(calcModeLabel, user, riverInfo, calcRange);
 
         final Collection<ResultRow> rows = new ArrayList<>();
-
+        // TODO: get results from access!
         final ResultRow row2 = ResultRow.create(). //
                 putValue(UInfoResultType.vegname, "Zonaler Wald"). //
                 putValue(UInfoResultType.vegdauervon, 0). //
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SuperVegZonesTablePanel.java	Mon May 14 18:24:35 2018 +0200
@@ -0,0 +1,243 @@
+/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+package org.dive4elements.river.client.client.ui.uinfo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.dive4elements.river.client.client.ui.AbstractUIProvider;
+import org.dive4elements.river.client.shared.model.Data;
+import org.dive4elements.river.client.shared.model.DataItem;
+import org.dive4elements.river.client.shared.model.DataList;
+import org.dive4elements.river.client.shared.model.DefaultData;
+import org.dive4elements.river.client.shared.model.DefaultDataItem;
+
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+/**
+ * @author Domenico Nardi Tironi
+ *
+ */
+public abstract class SuperVegZonesTablePanel extends AbstractUIProvider {
+    private static final long serialVersionUID = 1L;
+    public static final String tableCellSeparator = "tableCellSeparator";
+    public static final String tableRowSeparator = "tableRowSeparator";
+
+    protected static final String datakey = "vegzones";
+
+    protected final ListGrid elements = new ListGrid();
+    protected TextItem vegzone;
+    protected TextItem start;
+    protected TextItem end;
+    private ListGrid table;
+
+    final protected VLayout root = new VLayout();
+    final protected HLayout input = new HLayout();
+    final protected VLayout tableLayout = new VLayout();
+
+    public SuperVegZonesTablePanel() {
+
+    }
+
+    protected final Canvas createHelper() {
+        this.table = new ListGrid();
+        this.table.setShowHeaderContextMenu(false);
+        this.table.setWidth100();
+        this.table.setShowRecordComponents(true);
+        this.table.setShowRecordComponentsByCell(true);
+        this.table.setHeight100();
+        this.table.setEmptyMessage(this.MSG.empty_table());
+        this.table.setCanReorderFields(false);
+
+        /* Input support pins */
+        // final String baseUrl = GWT.getHostPageBaseURL();
+        // final ListGridField pinFrom = new ListGridField("fromIcon", this.MSG.uinfo_vegetation_zones_from());
+        // pinFrom.setWidth(300);
+        // pinFrom.setType(ListGridFieldType.ICON);
+        // pinFrom.setCellIcon(baseUrl + this.MSG.markerGreen());
+        //
+        // final ListGridField pinTo = new ListGridField("toIcon", this.MSG.uinfo_vegetation_zones_to());
+        // pinTo.setType(ListGridFieldType.ICON);
+        // pinTo.setWidth(300);
+        // pinTo.setCellIcon(baseUrl + this.MSG.markerRed());
+        //
+        // pinFrom.addRecordClickHandler(new RecordClickHandler() {
+        // @Override
+        // public void onRecordClick(final RecordClickEvent e) {
+        // final Record r = e.getRecord();
+        // VegetationzonesTableEditPanel.this.vegzone.setValue(r.getAttribute("date")); // date??
+        // }
+        // });
+        //
+        // pinFrom.addRecordClickHandler(new RecordClickHandler() {
+        // @Override
+        // public void onRecordClick(final RecordClickEvent e) {
+        // final Record r = e.getRecord();
+        // VegetationzonesTableEditPanel.this.start.setValue(r.getAttribute("date"));
+        // }
+        // });
+        //
+        // pinTo.addRecordClickHandler(new RecordClickHandler() {
+        // @Override
+        // public void onRecordClick(final RecordClickEvent e) {
+        // final Record r = e.getRecord();
+        // VegetationzonesTableEditPanel.this.end.setValue(r.getAttribute("date"));
+        // }
+        // });
+        //
+        // final ListGridField date = new ListGridField("date", this.MSG.year());
+        // date.setType(ListGridFieldType.TEXT);
+        // date.setWidth(100);
+        //
+        // final ListGridField descr = new ListGridField("description", this.MSG.description());
+        // descr.setType(ListGridFieldType.TEXT);
+        // descr.setWidth("*");
+        //
+        // this.table.setFields(pinFrom, pinTo, date, descr);
+        return this.table;
+    }
+
+    public abstract Canvas createWidget(final DataList data);
+
+    protected final void addDataInit(final DataList data) {
+        for (final Data dataItemContainer : data.getAll()) {
+            if (dataItemContainer.getItems() != null) {
+                for (final DataItem dataItem : dataItemContainer.getItems()) {
+                    if (dataItem.getStringValue() != null && dataItem.getStringValue().contains(tableRowSeparator)) {
+
+                        final String[] rows = dataItem.getStringValue().split(tableRowSeparator);
+                        for (final String row : rows) {
+                            this.elements.addData(createEntry(row));
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public final Canvas create(final DataList data) {
+        final VLayout layout = new VLayout();
+        final Canvas helper = createHelper();
+        this.helperContainer.addMember(helper);
+
+        final Canvas submit = getNextButton();
+        final Canvas widget = createWidget(data);
+
+        layout.addMember(widget);
+        layout.addMember(submit); // TODO: SUBMIT
+
+        // fetchSedimentLoadData(); //TODO: feed from database...
+
+        return layout;
+    }
+
+    @Override
+    public Canvas createOld(final DataList dataList) {
+        final HLayout layout = new HLayout();
+        layout.setWidth("400px");
+        final VLayout vLayout = new VLayout();
+        vLayout.setWidth(130);
+        final Label label = new Label(dataList.getLabel());
+        label.setWidth("200px");
+        label.setHeight(25);
+
+        final List<Data> items = dataList.getAll();
+        final Data str = getData(items, datakey);
+        final DataItem[] strItems = str.getItems();
+
+        final String[] entries = strItems[0].getLabel().split(VegetationzonesTablePanel.tableRowSeparator);
+        for (final String entry : entries) {
+            final String[] vals = entry.split(VegetationzonesTablePanel.tableCellSeparator);
+            final Label dateLabel = new Label(vals[0] + " (" + vals[1] + "-" + vals[2] + ")");
+            dateLabel.setHeight(20);
+            vLayout.addMember(dateLabel);
+        }
+        final Canvas back = getBackButton(dataList.getState());
+        layout.addMember(label);
+        layout.addMember(vLayout);
+        layout.addMember(back);
+
+        return layout;
+    }
+
+    protected static final Data[] getDummyData() {
+        final List<Data> data = new ArrayList<Data>();
+        String d = "";
+        d = d + "Zonaler Wald" + tableCellSeparator + "0" + tableCellSeparator + "5" + tableRowSeparator;
+        d = d + "Hartholzaue, trocken" + tableCellSeparator + "5" + tableCellSeparator + "40" + tableRowSeparator;
+        d = d + "Hartholzaue, feucht" + tableCellSeparator + "40" + tableCellSeparator + "80" + tableRowSeparator;
+        d = d + "Silberweidenwald" + tableCellSeparator + "80" + tableCellSeparator + "140" + tableRowSeparator;
+        d = d + "Weidengebüsch" + tableCellSeparator + "140" + tableCellSeparator + "200" + tableRowSeparator;
+        d = d + "Uferröhricht" + tableCellSeparator + "200" + tableCellSeparator + "260" + tableRowSeparator;
+        d = d + "Uferpioniere" + tableCellSeparator + "260" + tableCellSeparator + "320" + tableRowSeparator;
+        d = d + "Vegetationslos" + tableCellSeparator + "320" + tableCellSeparator + "365" + tableRowSeparator;
+        d = d + "Wasserfläche" + tableCellSeparator + "365" + tableCellSeparator + "365" + tableRowSeparator;
+
+        final DataItem item = new DefaultDataItem(datakey, "entryDescription", d); // DATA-key
+        data.add(new DefaultData(datakey, null, null, new DataItem[] { item }));
+        return data.toArray(new Data[data.size()]);
+    }
+
+    @Override
+    protected final Data[] getData() {
+        final List<Data> data = new ArrayList<Data>();
+
+        final ListGridRecord[] lgr = this.elements.getRecords();
+        if (lgr.length == 0) {
+            return getDummyData();// new Data[0]; // return getDummyData();
+        }
+        String d = "";
+        for (final ListGridRecord element : lgr) {
+            final Record r = element;
+            d += r.getAttribute("vegzone") + VegetationzonesTablePanel.tableCellSeparator + r.getAttribute("from")
+                    + VegetationzonesTablePanel.tableCellSeparator + r.getAttribute("to");
+            d += VegetationzonesTablePanel.tableRowSeparator;
+        }
+
+        final DataItem item = new DefaultDataItem(datakey, null, d); // DATA-key
+        data.add(new DefaultData(datakey, null, null, new DataItem[] { item }));
+        return data.toArray(new Data[data.size()]);
+    }
+
+    public final ListGridRecord createEntry(final String row) {
+
+        if (row.contains(tableCellSeparator)) {
+
+            final String[] vals = row.split(tableCellSeparator);
+            if (vals.length == 3) {
+                final String vegzone = vals[0];
+                final String from = vals[1];
+                final String to = vals[2];
+
+                if (vegzone == null || from == null || to == null) {
+                    return null;
+                }
+
+                final ListGridRecord r = new ListGridRecord();
+                r.setAttribute("vegzone", vegzone);
+                r.setAttribute("from", from);
+                r.setAttribute("to", to);
+                return r;
+
+            }
+
+        }
+        return null;
+    }
+
+}
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java	Mon May 14 14:59:10 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java	Mon May 14 18:24:35 2018 +0200
@@ -8,19 +8,10 @@
 
 package org.dive4elements.river.client.client.ui.uinfo;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.dive4elements.river.client.client.ui.AbstractUIProvider;
 import org.dive4elements.river.client.client.ui.PanelHelper;
-import org.dive4elements.river.client.shared.model.Data;
-import org.dive4elements.river.client.shared.model.DataItem;
 import org.dive4elements.river.client.shared.model.DataList;
-import org.dive4elements.river.client.shared.model.DefaultData;
-import org.dive4elements.river.client.shared.model.DefaultDataItem;
 
 import com.google.gwt.core.client.GWT;
-import com.smartgwt.client.data.Record;
 import com.smartgwt.client.types.ListGridFieldType;
 import com.smartgwt.client.widgets.Button;
 import com.smartgwt.client.widgets.Canvas;
@@ -28,38 +19,26 @@
 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.TextItem;
 import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
 import com.smartgwt.client.widgets.form.validator.IsStringValidator;
-import com.smartgwt.client.widgets.grid.ListGrid;
 import com.smartgwt.client.widgets.grid.ListGridField;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
 import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
 import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
 import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.VLayout;
 
-public class VegetationzonesTableEditPanel extends AbstractUIProvider {
+public class VegetationzonesTableEditPanel extends SuperVegZonesTablePanel {
     private static final long serialVersionUID = 1L;
 
-    protected ListGrid elements;
-    private TextItem vegzone;
-    private TextItem start;
-    private TextItem end;
-    private ListGrid table;
-
-    private static final String datakey = "vegzones";
-
+    @Override
     public Canvas createWidget(final DataList data) {
 
-        final VLayout root = new VLayout();
-        final HLayout input = new HLayout();
-        final VLayout tableLayout = new VLayout();
         final HLayout fields = new HLayout();
         final HLayout fields2 = new HLayout();
 
         final Button add = new Button(this.MSG.add_date()); // TODO: make key more generic or change to more specific
-        this.elements = new ListGrid();
+
+        data.add(VegetationzonesTablePanel.getDummyData());
 
         final Label title = new Label(data.get(0).getDescription());
         title.setHeight("35px"); // orig:25
@@ -108,6 +87,8 @@
         from.setWidth(70);
         to.setWidth(70);
 
+        addDataInit(data);
+
         final ListGridField removeField = new ListGridField("_removeRecord", "Remove Record") {
             {
                 setType(ListGridFieldType.ICON);
@@ -136,144 +117,19 @@
 
         fields.addMember(form1);
         fields2.addMember(form2);
-        // fields2.addMember(add);
-
-        tableLayout.addMember(this.elements);
-        root.addMember(title);
-        root.addMember(input);
-        root.addMember(tableLayout);
-        root.addMember(PanelHelper.getSpacer(10));
-        root.addMember(fields);
-        root.addMember(fields2);
-        root.addMember(PanelHelper.getSpacer(10));
-        root.addMember(add);
-        root.addMember(PanelHelper.getSpacer(20));
-
-        return root;
-    }
-
-    @Override
-    public Canvas createOld(final DataList dataList) {
-        final HLayout layout = new HLayout();
-        layout.setWidth("400px");
-        final VLayout vLayout = new VLayout();
-        vLayout.setWidth(130);
-        final Label label = new Label(dataList.getLabel());
-        label.setWidth("200px");
-        label.setHeight(25);
-
-        final List<Data> items = dataList.getAll();
-        final Data str = getData(items, datakey);
-        final DataItem[] strItems = str.getItems();
-
-        final String[] entries = strItems[0].getLabel().split(";");
-        for (final String entry : entries) {
-            final String[] vals = entry.split(",");
-            final Label dateLabel = new Label(vals[0] + " - " + vals[1]);
-            dateLabel.setHeight(20);
-            vLayout.addMember(dateLabel);
-        }
-        final Canvas back = getBackButton(dataList.getState());
-        layout.addMember(label);
-        layout.addMember(vLayout);
-        layout.addMember(back);
-
-        return layout;
-    }
-
-    @Override
-    public Canvas create(final DataList data) {
-        final VLayout layout = new VLayout();
-        final Canvas helper = createHelper();
-        this.helperContainer.addMember(helper);
-
-        final Canvas submit = getNextButton();
-        final Canvas widget = createWidget(data);
-
-        layout.addMember(widget);
-        layout.addMember(submit); // TODO: SUBMIT
-
-        // fetchSedimentLoadData(); //TODO: feed from database...
-
-        return layout;
-    }
 
-    private Canvas createHelper() {
-        this.table = new ListGrid();
-        this.table.setShowHeaderContextMenu(false);
-        this.table.setWidth100();
-        this.table.setShowRecordComponents(true);
-        this.table.setShowRecordComponentsByCell(true);
-        this.table.setHeight100();
-        this.table.setEmptyMessage(this.MSG.empty_table());
-        this.table.setCanReorderFields(false);
+        this.tableLayout.addMember(this.elements);
+        this.root.addMember(title);
+        this.root.addMember(this.input);
+        this.root.addMember(this.tableLayout);
+        this.root.addMember(PanelHelper.getSpacer(10));
+        this.root.addMember(fields);
+        this.root.addMember(fields2);
+        this.root.addMember(PanelHelper.getSpacer(10));
+        this.root.addMember(add);
+        this.root.addMember(PanelHelper.getSpacer(20));
 
-        /* Input support pins */
-        // final String baseUrl = GWT.getHostPageBaseURL();
-        // final ListGridField pinFrom = new ListGridField("fromIcon", this.MSG.uinfo_vegetation_zones_from());
-        // pinFrom.setWidth(300);
-        // pinFrom.setType(ListGridFieldType.ICON);
-        // pinFrom.setCellIcon(baseUrl + this.MSG.markerGreen());
-        //
-        // final ListGridField pinTo = new ListGridField("toIcon", this.MSG.uinfo_vegetation_zones_to());
-        // pinTo.setType(ListGridFieldType.ICON);
-        // pinTo.setWidth(300);
-        // pinTo.setCellIcon(baseUrl + this.MSG.markerRed());
-        //
-        // pinFrom.addRecordClickHandler(new RecordClickHandler() {
-        // @Override
-        // public void onRecordClick(final RecordClickEvent e) {
-        // final Record r = e.getRecord();
-        // VegetationzonesTableEditPanel.this.vegzone.setValue(r.getAttribute("date")); // date??
-        // }
-        // });
-        //
-        // pinFrom.addRecordClickHandler(new RecordClickHandler() {
-        // @Override
-        // public void onRecordClick(final RecordClickEvent e) {
-        // final Record r = e.getRecord();
-        // VegetationzonesTableEditPanel.this.start.setValue(r.getAttribute("date"));
-        // }
-        // });
-        //
-        // pinTo.addRecordClickHandler(new RecordClickHandler() {
-        // @Override
-        // public void onRecordClick(final RecordClickEvent e) {
-        // final Record r = e.getRecord();
-        // VegetationzonesTableEditPanel.this.end.setValue(r.getAttribute("date"));
-        // }
-        // });
-        //
-        // final ListGridField date = new ListGridField("date", this.MSG.year());
-        // date.setType(ListGridFieldType.TEXT);
-        // date.setWidth(100);
-        //
-        // final ListGridField descr = new ListGridField("description", this.MSG.description());
-        // descr.setType(ListGridFieldType.TEXT);
-        // descr.setWidth("*");
-        //
-        // this.table.setFields(pinFrom, pinTo, date, descr);
-        return this.table;
-    }
-
-    @Override
-    protected Data[] getData() {
-        final List<Data> data = new ArrayList<Data>();
-
-        final ListGridRecord[] lgr = this.elements.getRecords();
-        if (lgr.length == 0) {
-            return new Data[0];
-        }
-        String d = "";
-        for (final ListGridRecord element : lgr) {
-            final Record r = element;
-            d += r.getAttribute("vegzone") + "," + r.getAttribute("from") + "," + r.getAttribute("to");
-            d += ";";
-        }
-
-        final DataItem item = new DefaultDataItem(datakey, null, d); // DATA-key
-        data.add(new DefaultData(datakey, null, null, new DataItem[] { item }));
-        return data.toArray(new Data[data.size()]);
+        return this.root;
     }
 
 }
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java	Mon May 14 14:59:10 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java	Mon May 14 18:24:35 2018 +0200
@@ -8,47 +8,23 @@
 
 package org.dive4elements.river.client.client.ui.uinfo;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.dive4elements.river.client.client.ui.AbstractUIProvider;
 import org.dive4elements.river.client.client.ui.PanelHelper;
-import org.dive4elements.river.client.shared.model.Data;
-import org.dive4elements.river.client.shared.model.DataItem;
 import org.dive4elements.river.client.shared.model.DataList;
-import org.dive4elements.river.client.shared.model.DefaultData;
-import org.dive4elements.river.client.shared.model.DefaultDataItem;
 
-import com.smartgwt.client.data.Record;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.form.fields.TextItem;
 import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
 import com.smartgwt.client.widgets.form.validator.IsStringValidator;
-import com.smartgwt.client.widgets.grid.ListGrid;
 import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.VLayout;
 
-public class VegetationzonesTablePanel extends AbstractUIProvider {
+public class VegetationzonesTablePanel extends SuperVegZonesTablePanel {
+
     private static final long serialVersionUID = 1L;
 
-    protected ListGrid elements;
-    private TextItem vegzone;
-    private TextItem start;
-    private TextItem end;
-    private ListGrid table;
-
-    private static final String datakey = "vegzones";
-
+    @Override
     public Canvas createWidget(final DataList data) {
 
-        final VLayout root = new VLayout();
-        final HLayout input = new HLayout();
-        final VLayout tableLayout = new VLayout();
-
-        this.elements = new ListGrid();
+        data.add(VegetationzonesTablePanel.getDummyData()); // TODO: GET REAL DATA!
 
         final Label title = new Label(data.get(0).getDescription());
         title.setHeight("35px"); // orig:25
@@ -59,8 +35,8 @@
 
         final Label sel = new Label(this.MSG.select());
         sel.setHeight(25);
-        this.elements.setWidth(450); // 185
-        this.elements.setHeight(500); // 120
+        this.elements.setWidth(420); // 185
+        this.elements.setHeight(500); //
         this.elements.setShowHeaderContextMenu(false);
         this.elements.setCanReorderFields(false);
         this.elements.setCanSort(false);
@@ -68,190 +44,21 @@
         final ListGridField vegzone = new ListGridField("vegzone", this.MSG.uinfo_vegetation_zones_label());
         final ListGridField from = new ListGridField("from", this.MSG.uinfo_vegetation_zones_from());
         final ListGridField to = new ListGridField("to", this.MSG.uinfo_vegetation_zones_to());
-        vegzone.setWidth(285);
+        vegzone.setWidth(265);
         from.setWidth(70);
         to.setWidth(70);
 
-        for (final Data dataItem : data.getAll()) {
-            createEntry(dataItem);
-        }
+        addDataInit(data);
 
         this.elements.setFields(vegzone, from, to);
 
-        tableLayout.addMember(this.elements);
-        root.addMember(title);
-        root.addMember(input);
-        root.addMember(tableLayout);
-        root.addMember(PanelHelper.getSpacer(10));
-
-        return root;
-    }
-
-    private void createEntry(final Data data) {
-
-        if (data.getItems() != null) {
-            for (final DataItem dataItem : data.getItems()) {
-                if (dataItem.getStringValue() != null) {
-                    if (dataItem.getStringValue().contains(",")) {
-                        final String[] vals = dataItem.getStringValue().split(",");
-                        if (vals.length == 3) {
-                            final String vegzone = vals[0];
-                            final String from = vals[1];
-                            final String to = vals[2];
-
-                            if (vegzone == null || from == null || to == null) {
-                                return;
-                            }
-
-                            final ListGridRecord r = new ListGridRecord();
-                            r.setAttribute("vegzone", vegzone);
-                            r.setAttribute("from", from);
-                            r.setAttribute("to", to);
-                            this.elements.addData(r);
-
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    @Override
-    public Canvas createOld(final DataList dataList) { // TODO: Veg-Table übersichtlich oben anzeigen, irgendwie abkürzen (etwa "20 Einträge")
-        final HLayout layout = new HLayout();
-        layout.setWidth("400px");
-        final VLayout vLayout = new VLayout();
-        vLayout.setWidth(130);
-        final Label label = new Label(dataList.getLabel());
-        label.setWidth("200px");
-        label.setHeight(25);
-
-        final List<Data> items = dataList.getAll();
-        final Data str = getData(items, datakey);
-        final DataItem[] strItems = str.getItems();
-
-        final String[] entries = strItems[0].getLabel().split(";");
-        for (final String entry : entries) {
-            final String[] vals = entry.split(",");
-            final Label dateLabel = new Label(vals[0] + " TODO: MAKE SELECTED ENTRIES VEGZONE FOR ARTIFACT" + vals[1]);
-            dateLabel.setHeight(20);
-            vLayout.addMember(dateLabel);
-        }
-        final Canvas back = getBackButton(dataList.getState());
-        layout.addMember(label);
-        layout.addMember(vLayout);
-        layout.addMember(back);
-
-        return layout;
-    }
-
-    @Override
-    public Canvas create(final DataList data) {
-        final VLayout layout = new VLayout();
-        final Canvas helper = createHelper();
-        this.helperContainer.addMember(helper);
-
-        final Canvas submit = getNextButton();
-        // if (data.size() == 0) { // TODO: GET DATA
-
-        data.add(getDummyData());
-
-        // }
-        final Canvas widget = createWidget(data);
-
-        layout.addMember(widget);
-        layout.addMember(submit); // TODO: SUBMIT
-
-        // fetchSedimentLoadData(); //TODO: feed from database...
+        this.tableLayout.addMember(this.elements);
+        this.root.addMember(title);
+        this.root.addMember(this.input);
+        this.root.addMember(this.tableLayout);
+        this.root.addMember(PanelHelper.getSpacer(10));
 
-        return layout;
-    }
-
-    private Canvas createHelper() {
-        this.table = new ListGrid();
-        this.table.setShowHeaderContextMenu(false);
-        this.table.setWidth100();
-        this.table.setShowRecordComponents(true);
-        this.table.setShowRecordComponentsByCell(true);
-        this.table.setHeight100();
-        this.table.setEmptyMessage(this.MSG.empty_table());
-        this.table.setCanReorderFields(false);
-
-        /* Input support pins */
-        // final String baseUrl = GWT.getHostPageBaseURL();
-        // final ListGridField pinFrom = new ListGridField("fromIcon", this.MSG.uinfo_vegetation_zones_from());
-        // pinFrom.setWidth(300);
-        // pinFrom.setType(ListGridFieldType.ICON);
-        // pinFrom.setCellIcon(baseUrl + this.MSG.markerGreen());
-        //
-        // final ListGridField pinTo = new ListGridField("toIcon", this.MSG.uinfo_vegetation_zones_to());
-        // pinTo.setType(ListGridFieldType.ICON);
-        // pinTo.setWidth(300);
-        // pinTo.setCellIcon(baseUrl + this.MSG.markerRed());
-        //
-        // pinFrom.addRecordClickHandler(new RecordClickHandler() {
-        // @Override
-        // public void onRecordClick(final RecordClickEvent e) {
-        // final Record r = e.getRecord();
-        // VegetationzonesTableEditPanel.this.vegzone.setValue(r.getAttribute("date")); // date??
-        // }
-        // });
-        //
-        // pinFrom.addRecordClickHandler(new RecordClickHandler() {
-        // @Override
-        // public void onRecordClick(final RecordClickEvent e) {
-        // final Record r = e.getRecord();
-        // VegetationzonesTableEditPanel.this.start.setValue(r.getAttribute("date"));
-        // }
-        // });
-        //
-        // pinTo.addRecordClickHandler(new RecordClickHandler() {
-        // @Override
-        // public void onRecordClick(final RecordClickEvent e) {
-        // final Record r = e.getRecord();
-        // VegetationzonesTableEditPanel.this.end.setValue(r.getAttribute("date"));
-        // }
-        // });
-        //
-        // final ListGridField date = new ListGridField("date", this.MSG.year());
-        // date.setType(ListGridFieldType.TEXT);
-        // date.setWidth(100);
-        //
-        // final ListGridField descr = new ListGridField("description", this.MSG.description());
-        // descr.setType(ListGridFieldType.TEXT);
-        // descr.setWidth("*");
-        //
-        // this.table.setFields(pinFrom, pinTo, date, descr);
-        return this.table;
-    }
-
-    @Override
-    protected Data[] getData() {
-        final List<Data> data = new ArrayList<Data>();
-
-        final ListGridRecord[] lgr = this.elements.getRecords();
-        if (lgr.length == 0) {
-            return getDummyData();// return new Data[0];
-        }
-        String d = "";
-        for (final ListGridRecord element : lgr) {
-            final Record r = element;
-            d += r.getAttribute("vegzone") + "," + r.getAttribute("from") + "," + r.getAttribute("to");
-            d += ";";
-        }
-
-        final DataItem item = new DefaultDataItem(datakey, null, d); // DATA-key
-        data.add(new DefaultData(datakey, null, null, new DataItem[] { item }));
-        return data.toArray(new Data[data.size()]);
-    }
-
-    private Data[] getDummyData() {
-        final List<Data> data = new ArrayList<Data>();
-        String d = "";
-        d = d + "Zonaler Wald" + "," + "0" + "," + "5";
-        final DataItem item = new DefaultDataItem(datakey, "entryDescription", d); // DATA-key
-        data.add(new DefaultData(datakey, null, null, new DataItem[] { item }));
-        return data.toArray(new Data[data.size()]);
+        return this.root;
     }
 
 }

http://dive4elements.wald.intevation.org