# HG changeset patch # User Raimund Renkert # Date 1370948271 -7200 # Node ID 24be0cc1c67cf11ee1fd66023dcb041b9c77f752 # Parent 9b7f1288e6c439c26d8bc23ff16ab4a6ed21b867 Replaced the 'old school' wiki link buttons with default links. diff -r 9b7f1288e6c4 -r 24be0cc1c67c 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 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() { diff -r 9b7f1288e6c4 -r 24be0cc1c67c gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java --- 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 "
" - + "" - + "" - + "
"; + 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 "" + quotedText + ""; + 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()); - } - }; - } } diff -r 9b7f1288e6c4 -r 24be0cc1c67c gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeListGrid.java --- 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); } diff -r 9b7f1288e6c4 -r 24be0cc1c67c gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoListGrid.java --- 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()) { diff -r 9b7f1288e6c4 -r 24be0cc1c67c gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationListGrid.java --- 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); + } + } + }