comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java @ 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 954dbb0806f3
children c28f13c80979
comparison
equal deleted inserted replaced
6271:9b7f1288e6c4 6272:24be0cc1c67c
6 * documentation coming with Dive4Elements River for details. 6 * documentation coming with Dive4Elements River for details.
7 */ 7 */
8 8
9 package org.dive4elements.river.client.client.ui; 9 package org.dive4elements.river.client.client.ui;
10 10
11 import com.smartgwt.client.types.FormMethod;
12 import com.smartgwt.client.widgets.form.DynamicForm;
13 import com.smartgwt.client.widgets.form.fields.LinkItem;
14 import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
15 import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
11 import com.smartgwt.client.widgets.grid.CellFormatter; 16 import com.smartgwt.client.widgets.grid.CellFormatter;
12 import com.smartgwt.client.widgets.grid.ListGridRecord; 17 import com.smartgwt.client.widgets.grid.ListGridRecord;
13 import com.google.gwt.safehtml.shared.SafeHtmlUtils; 18 import com.google.gwt.safehtml.shared.SafeHtmlUtils;
14 19
15 import org.dive4elements.river.client.client.FLYS; 20 import org.dive4elements.river.client.client.FLYS;
35 else { 40 else {
36 return "<a href=\"" + quotedUrl + "\"><img src=\"" + quotedImage + "\"></a>"; 41 return "<a href=\"" + quotedUrl + "\"><img src=\"" + quotedImage + "\"></a>";
37 } 42 }
38 } 43 }
39 44
40 public static String linkHTML(FLYS flys, String url, String text) { 45 public static DynamicForm linkHTML(FLYS flys, String url, String text) {
41 String saml = flys.getCurrentUser().getSamlXMLBase64(); 46 String saml = flys.getCurrentUser().getSamlXMLBase64();
42 String quotedUrl = SafeHtmlUtils.htmlEscape(url); 47 String quotedUrl = SafeHtmlUtils.htmlEscape(url);
43 String quotedText = SafeHtmlUtils.htmlEscape(text); 48 String quotedText = SafeHtmlUtils.htmlEscape(text);
44 if (saml != null) { 49 if (saml != null) {
45 return "<form method=\"POST\" target=\"_blank\" action=\"" 50 final DynamicForm form = new DynamicForm();
46 + quotedUrl + "\">" 51 form.setMethod(FormMethod.POST);
47 + "<input type=\"hidden\" name=\"saml\" value=\"" 52 form.setTarget("_blank");
48 + SafeHtmlUtils.htmlEscape(saml) + "\">" 53 form.setAction(quotedUrl);
49 + "<input type=\"submit\" value=\"" + quotedText + "\">" 54 form.setCanSubmit(true);
50 + "</form>"; 55 LinkItem item = new LinkItem("saml");
56 item.setShowTitle(false);
57 item.setLinkTitle(quotedText);
58 item.setValue(SafeHtmlUtils.htmlEscape(saml));
59 item.addClickHandler(new ClickHandler() {
60 @Override
61 public void onClick(ClickEvent event) {
62 form.submitForm();
63 }
64 });
65 form.setFields(item);
66 return form;
51 } 67 }
52 else { 68 else {
53 return "<a href=\"" + quotedUrl + "\">" + quotedText + "</a>"; 69 DynamicForm form = new DynamicForm();
70 LinkItem item = new LinkItem(quotedText);
71 item.setShowTitle(false);
72 item.setTarget(quotedUrl);
73 return form;
54 } 74 }
55 } 75 }
56
57 public static CellFormatter cellFormatter(final FLYS flys) {
58 return new CellFormatter() {
59 public String format(Object value, ListGridRecord record,
60 int rowNum, int colNum) {
61 return linkHTML(flys, (String)value, record.getLinkText());
62 }
63 };
64 }
65 } 76 }

http://dive4elements.wald.intevation.org