[PATCH 1 of 3] Replaced plain gwt with smartgwt components in info panels

Wald Commits scm-commit at wald.intevation.org
Tue Jun 17 09:54:49 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1402991148 -7200
# Node ID 900299ab8e6e44d571154caa069886546975c4b3
# Parent  b1393f96c1532a23e97867f4668f83392738714a
Replaced plain gwt with smartgwt components in info panels.

diff -r b1393f96c153 -r 900299ab8e6e gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java	Fri Jun 13 16:34:29 2014 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java	Tue Jun 17 09:45:48 2014 +0200
@@ -10,12 +10,11 @@
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.i18n.client.NumberFormat;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.Widget;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.widgets.Label;
 import com.smartgwt.client.widgets.form.DynamicForm;
-
-import java.util.Iterator;
+import com.smartgwt.client.widgets.layout.HLayout;
 
 import org.dive4elements.river.client.client.Config;
 import org.dive4elements.river.client.client.FLYS;
@@ -26,7 +25,7 @@
  * Panel to display information about a river.
  * @author <a href="mailto:bjoern.ricks at intevation.de">Björn Ricks</a>
  */
-public class RiverInfoPanel extends HorizontalPanel {
+public class RiverInfoPanel extends HLayout {
 
     /** The flys instance */
     protected FLYS flys;
@@ -43,9 +42,9 @@
         this.flys = flys;
 
         setStyleName("riverinfopanel");
-        setHeight("" + HEIGHT + "px");
-        setVerticalAlignment(ALIGN_MIDDLE);
-
+        setHeight(HEIGHT + "px");
+        setAlign(VerticalAlignment.CENTER);
+        setAlign(Alignment.LEFT);
         setRiverInfo(riverinfo);
     }
 
@@ -54,7 +53,7 @@
 
         NumberFormat nf = NumberFormat.getDecimalFormat();
 
-        removeAllLabels();
+        //removeAllLabels();
 
         addLabel(riverinfo.getName(), false);
 
@@ -101,7 +100,8 @@
         DynamicForm infoLink = WikiLinks.linkDynamicForm(this.flys, wikiBaseUrl + url,
                                         MSG.gauge_river_info_link());
         infoLink.setTop(5);
-        add(infoLink);
+        infoLink.setMargin(5);
+        addMember(infoLink);
     }
 
     public static int getStaticHeight() {
@@ -112,21 +112,9 @@
     }
 
     private void addLabel(String text, boolean wordwrap) {
-        Label label = new Label(text, wordwrap);
-        add(label);
-        setCellHeight(label, "" + HEIGHT + "px");
-    }
-
-    private void removeAllLabels() {
-        GWT.log("RiverInfoPanel - removeAllLabels");
-
-        Iterator<Widget> it = this.iterator();
-        while(it.hasNext()) {
-            it.next();
-            it.remove();
-        }
-        /* for (Widget wid: this) { */
-        /*     this.remove(wid); */
-        /* } */
+        Label label = new Label("<span style='font-size:1.3em'>" + text + "</span>");
+        label.setWrap(wordwrap);
+        label.setMargin(5);
+        addMember(label);
     }
 }
diff -r b1393f96c153 -r 900299ab8e6e gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeInfoPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeInfoPanel.java	Fri Jun 13 16:34:29 2014 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeInfoPanel.java	Tue Jun 17 09:45:48 2014 +0200
@@ -9,10 +9,11 @@
 package org.dive4elements.river.client.client.ui.stationinfo;
 
 import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
 import com.google.gwt.i18n.client.NumberFormat;
-import com.google.gwt.user.client.ui.Anchor;
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 import com.smartgwt.client.widgets.Label;
@@ -83,7 +84,9 @@
         }
 
         HLayout line5 = new HLayout();
-        line5.addMember(new GaugeMainValueAnchor(flys, gauge));
+        DynamicForm line5Form = new DynamicForm();
+        line5Form.setItems(new GaugeMainValueAnchor(flys, gauge));
+        line5.addMember(line5Form);
 
         if (minw != null && maxw != null) {
             grid.addMember(line1);
@@ -105,16 +108,17 @@
      * Clickable anchor that asks application to show window with
      * main values for gauge.
      */
-    class GaugeMainValueAnchor extends Anchor implements ClickHandler {
+    class GaugeMainValueAnchor extends LinkItem implements ClickHandler {
 
         private FLYS flys;
         private GaugeInfo gauge;
 
         public GaugeMainValueAnchor(FLYS flys, GaugeInfo gauge) {
-            super(MSG.show_mainvalues());
+            super();
+            this.setLinkTitle(MSG.show_mainvalues());
+            this.setShowTitle(false);
             this.flys = flys;
             this.gauge = gauge;
-            this.setHeight("5");
 
             addClickHandler(this);
         }
diff -r b1393f96c153 -r 900299ab8e6e gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationInfoPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationInfoPanel.java	Fri Jun 13 16:34:29 2014 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationInfoPanel.java	Tue Jun 17 09:45:48 2014 +0200
@@ -13,7 +13,8 @@
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.i18n.client.DateTimeFormat;
 import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
-import com.google.gwt.user.client.ui.Grid;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
 import org.dive4elements.river.client.client.FLYSConstants;
@@ -28,39 +29,64 @@
         setStyleName("infopanel");
         setWidth100();
 
-        Grid grid = new Grid(5, 2);
+        VLayout grid = new VLayout();
 
+        HLayout line1 = new HLayout();
         String type = station.getMeasurementType();
         if (type != null) {
-            grid.setText(0, 0, MSG.measurement_station_type());
-            grid.setText(0, 1, type);
+            Label key = new Label(MSG.measurement_station_type());
+            Label value = new Label(type);
+            key.setWidth(150);
+            line1.addMember(key);
+            line1.addMember(value);
+            grid.addMember(line1);
         }
 
+        HLayout line2 = new HLayout();
         String riverside = station.getRiverSide();
         if (riverside != null) {
-            grid.setText(1, 0, MSG.riverside());
-            grid.setText(1, 1, riverside);
+            Label key = new Label(MSG.riverside());
+            Label value = new Label(riverside);
+            key.setWidth(150);
+            line2.addMember(key);
+            line2.addMember(value);
+            grid.addMember(line2);
         }
 
+        HLayout line3 = new HLayout();
         String gaugename = station.getGaugeName();
         if (gaugename != null) {
-            grid.setText(2, 0, MSG.measurement_station_gauge_name());
-            grid.setText(2, 1, gaugename);
+            Label key = new Label(MSG.measurement_station_gauge_name());
+            Label value = new Label(gaugename);
+            key.setWidth(150);
+            line3.addMember(key);
+            line3.addMember(value);
+            grid.addMember(line3);
         }
 
+        HLayout line4 = new HLayout();
         DateTimeFormat df = DateTimeFormat.getFormat(
-                PredefinedFormat.DATE_MEDIUM);
+            PredefinedFormat.DATE_MEDIUM);
 
         Date starttime = station.getStartTime();
         if (starttime != null) {
-            grid.setText(3, 0, MSG.measurement_station_start_time());
-            grid.setText(3, 1, df.format(starttime));
+            Label key = new Label(MSG.measurement_station_start_time());
+            Label value = new Label(df.format(starttime));
+            key.setWidth(150);
+            line4.addMember(key);
+            line4.addMember(value);
+            grid.addMember(line4);
         }
 
+        HLayout line5 = new HLayout();
         String moperator = station.getOperator();
         if (moperator != null) {
-            grid.setText(4, 0, MSG.measurement_station_operator());
-            grid.setText(4, 1, moperator);
+            Label key = new Label(MSG.measurement_station_operator());
+            Label value = new Label(moperator);
+            key.setWidth(150);
+            line5.addMember(key);
+            line5.addMember(value);
+            grid.addMember(line5);
         }
 
         addMember(grid);


More information about the Dive4Elements-commits mailing list