annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java @ 6230:954dbb0806f3

Add imageLinkHTML function to WikiLinks class
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 07 Jun 2013 11:47:47 +0200
parents cefad5546373
children 24be0cc1c67c
rev   line source
6197
cefad5546373 Fix Non-UTF8 Umlaut characters.
Christian Lins <christian.lins@intevation.de>
parents: 6189
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
6189
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
3 *
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
7 */
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
8
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.client.client.ui;
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
10
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
11 import com.smartgwt.client.widgets.grid.CellFormatter;
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
12 import com.smartgwt.client.widgets.grid.ListGridRecord;
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
13 import com.google.gwt.safehtml.shared.SafeHtmlUtils;
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
14
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
15 import org.dive4elements.river.client.client.FLYS;
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
16
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
17 public class WikiLinks
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
18 {
6230
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
19 public static String imageLinkHTML(FLYS instance, String url, String imageUrl) {
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
20 String saml = null;
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
21 if (instance != null && instance.getCurrentUser() != null) {
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
22 saml = instance.getCurrentUser().getSamlXMLBase64();
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
23 }
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
24 String quotedUrl = SafeHtmlUtils.htmlEscape(url);
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
25 String quotedImage = SafeHtmlUtils.htmlEscape(imageUrl);
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
26
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
27 if (saml != null) {
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
28 return "<form method=\"POST\" target=\"_blank\" action=\""
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
29 + quotedUrl + "\">"
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
30 + "<input type=\"hidden\" name=\"saml\" value=\""
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
31 + SafeHtmlUtils.htmlEscape(saml) + "\">"
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
32 + "<input type=\"image\" src=\""+ quotedImage + "\">"
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
33 + "</form>";
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
34 }
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
35 else {
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
36 return "<a href=\"" + quotedUrl + "\"><img src=\"" + quotedImage + "\"></a>";
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
37 }
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
38 }
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
39
6189
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
40 public static String linkHTML(FLYS flys, String url, String text) {
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
41 String saml = flys.getCurrentUser().getSamlXMLBase64();
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
42 String quotedUrl = SafeHtmlUtils.htmlEscape(url);
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
43 String quotedText = SafeHtmlUtils.htmlEscape(text);
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
44 if (saml != null) {
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
45 return "<form method=\"POST\" target=\"_blank\" action=\""
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
46 + quotedUrl + "\">"
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
47 + "<input type=\"hidden\" name=\"saml\" value=\""
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
48 + SafeHtmlUtils.htmlEscape(saml) + "\">"
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
49 + "<input type=\"submit\" value=\"" + quotedText + "\">"
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
50 + "</form>";
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
51 }
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
52 else {
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
53 return "<a href=\"" + quotedUrl + "\">" + quotedText + "</a>";
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
54 }
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
55 }
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
56
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
57 public static CellFormatter cellFormatter(final FLYS flys) {
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
58 return new CellFormatter() {
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
59 public String format(Object value, ListGridRecord record,
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
60 int rowNum, int colNum) {
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
61 return linkHTML(flys, (String)value, record.getLinkText());
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
62 }
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
63 };
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
64 }
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
65 }

http://dive4elements.wald.intevation.org