changeset 6272:24be0cc1c67c

Replaced the 'old school' wiki link buttons with default links.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 11 Jun 2013 12:57:51 +0200
parents 9b7f1288e6c4
children 3d8f9e3bbf2e 2d495b504c74
files gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeListGrid.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoListGrid.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationListGrid.java
diffstat 5 files changed, 77 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java	Tue Jun 11 12:41:33 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java	Tue Jun 11 12:57:51 2013 +0200
@@ -10,18 +10,17 @@
 
 import java.util.Iterator;
 
+import org.dive4elements.river.client.client.FLYS;
+import org.dive4elements.river.client.client.FLYSConstants;
+import org.dive4elements.river.client.shared.model.RiverInfo;
+
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.i18n.client.NumberFormat;
-import com.google.gwt.user.client.ui.Anchor;
 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.google.gwt.user.client.ui.HTML;
-
-import org.dive4elements.river.client.client.FLYS;
-import org.dive4elements.river.client.client.FLYSConstants;
-
-import org.dive4elements.river.client.shared.model.RiverInfo;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
 
 /**
  * Panel to display information about a river.
@@ -98,8 +97,12 @@
         String url = number != null ?
             MSG.gauge_river_url() + number :
             MSG.gauge_river_url();
-        add(new HTML(WikiLinks.linkHTML(this.flys, url,
-                                        MSG.gauge_river_info_link())));
+        DynamicForm infoLink = WikiLinks.linkHTML(this.flys, url,
+                                        MSG.gauge_river_info_link());
+        infoLink.setTop(5);
+        LinkItem item = (LinkItem)infoLink.getField("saml");
+        item.setTextBoxStyle("font-size: large;");
+        add(infoLink);
     }
 
     public static int getStaticHeight() {
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java	Tue Jun 11 12:41:33 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java	Tue Jun 11 12:57:51 2013 +0200
@@ -8,6 +8,11 @@
 
 package org.dive4elements.river.client.client.ui;
 
+import com.smartgwt.client.types.FormMethod;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
 import com.smartgwt.client.widgets.grid.CellFormatter;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
 import com.google.gwt.safehtml.shared.SafeHtmlUtils;
@@ -37,29 +42,35 @@
         }
     }
 
-    public static String linkHTML(FLYS flys, String url, String text) {
+    public static DynamicForm linkHTML(FLYS flys, String url, String text) {
         String saml = flys.getCurrentUser().getSamlXMLBase64();
         String quotedUrl = SafeHtmlUtils.htmlEscape(url);
         String quotedText = SafeHtmlUtils.htmlEscape(text);
         if (saml != null) {
-            return "<form method=\"POST\" target=\"_blank\" action=\""
-                + quotedUrl + "\">"
-                + "<input type=\"hidden\" name=\"saml\" value=\""
-                + SafeHtmlUtils.htmlEscape(saml) + "\">"
-                + "<input type=\"submit\" value=\"" + quotedText + "\">"
-                + "</form>";
+            final DynamicForm form = new DynamicForm();
+            form.setMethod(FormMethod.POST);
+            form.setTarget("_blank");
+            form.setAction(quotedUrl);
+            form.setCanSubmit(true);
+            LinkItem item = new LinkItem("saml");
+            item.setShowTitle(false);
+            item.setLinkTitle(quotedText);
+            item.setValue(SafeHtmlUtils.htmlEscape(saml));
+            item.addClickHandler(new ClickHandler() {
+                @Override
+                public void onClick(ClickEvent event) {
+                    form.submitForm();
+                }
+            });
+            form.setFields(item);
+            return form;
         }
         else {
-            return "<a href=\"" + quotedUrl + "\">" + quotedText + "</a>";
+            DynamicForm form = new DynamicForm();
+            LinkItem item = new LinkItem(quotedText);
+            item.setShowTitle(false);
+            item.setTarget(quotedUrl);
+            return form;
         }
     }
-
-    public static CellFormatter cellFormatter(final FLYS flys) {
-        return new CellFormatter() {
-            public String format(Object value, ListGridRecord record,
-                                 int rowNum, int colNum) {
-                return linkHTML(flys, (String)value, record.getLinkText());
-            }
-        };
-    }
 }
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeListGrid.java	Tue Jun 11 12:41:33 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeListGrid.java	Tue Jun 11 12:57:51 2013 +0200
@@ -15,6 +15,7 @@
 import com.smartgwt.client.types.ListGridFieldType;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.WidgetCanvas;
+import com.smartgwt.client.widgets.form.DynamicForm;
 import com.smartgwt.client.widgets.grid.ListGridField;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
 import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
@@ -43,12 +44,12 @@
         ListGridField sfield = new ListGridField("kmstart", "Start [km]", 60);
         ListGridField efield = new ListGridField("kmend", "Ende [km]", 60);
         ListGridField stfield = new ListGridField("station", "Station [km]");
-        ListGridField lfield = new ListGridField("link", "Info");
-        lfield.setType(ListGridFieldType.LINK);
-        lfield.setCellFormatter(WikiLinks.cellFormatter(flys));
+        ListGridField lfield = new ListGridField("infolink", "Info");
         ListGridField cfield = new ListGridField("curvelink", MSG.gauge_curve_link());
         cfield.addRecordClickHandler(this);
 
+        this.setShowRecordComponents(true);
+        this.setShowRecordComponentsByCell(true);
         this.setFields(nfield, sfield, efield, stfield, lfield, cfield);
     }
 
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoListGrid.java	Tue Jun 11 12:41:33 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoListGrid.java	Tue Jun 11 12:57:51 2013 +0200
@@ -16,6 +16,7 @@
 
 import org.dive4elements.river.client.client.FLYS;
 import org.dive4elements.river.client.client.FLYSConstants;
+import org.dive4elements.river.client.client.ui.WikiLinks;
 import org.dive4elements.river.client.shared.model.Data;
 import org.dive4elements.river.client.shared.model.DataList;
 import org.dive4elements.river.client.shared.model.RiverInfo;
@@ -38,6 +39,23 @@
         this.setCanExpandMultipleRecords(true);
     }
 
+    @Override
+    protected Canvas createRecordComponent(
+        final ListGridRecord record,
+        Integer colNum
+    ) {
+        String name = this.getFieldName(colNum);
+        if (name.equals("infolink")) {
+            return WikiLinks.linkHTML(
+                flys,
+                record.getAttribute("link"),
+                record.getLinkText());
+        }
+        else {
+            return null;
+        }
+    }
+
     public void openAll() {
         GWT.log("InfoListGrid - openAll");
         for (ListGridRecord record: this.getRecords()) {
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationListGrid.java	Tue Jun 11 12:41:33 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationListGrid.java	Tue Jun 11 12:57:51 2013 +0200
@@ -39,11 +39,12 @@
         ListGridField sfield = new ListGridField("kmstart", "Start [km]", 60);
         ListGridField efield = new ListGridField("kmend", "Ende [km]", 60);
         ListGridField stfield = new ListGridField("station", "Station [km]");
-        ListGridField lfield = new ListGridField("link", "Link");
-        lfield.setType(ListGridFieldType.LINK);
-        lfield.setCellFormatter(WikiLinks.cellFormatter(flys));
+        ListGridField lfield = new ListGridField("infolink", "Link");
         ListGridField cfield = new ListGridField("curvelink", "SQ");
         cfield.addRecordClickHandler(this);
+
+        this.setShowRecordComponents(true);
+        this.setShowRecordComponentsByCell(true);
         this.setFields(nfield, sfield, efield, stfield, lfield, cfield);
     }
 
@@ -112,4 +113,15 @@
         flys.newSQRelation(station.getRiverName(), station.getID());
     }
 
+    @Override
+    public String getCellCSSText(ListGridRecord record, int rowNum,
+            int colNum) {
+        if (colNum == 6) {
+            return "text-decoration: underline; color: #0000EE; cursor: pointer;";
+        }
+        else {
+            return super.getCellCSSText(record, rowNum, colNum);
+        }
+    }
+
 }

http://dive4elements.wald.intevation.org