Mercurial > dive4elements > river
annotate 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 |
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 |
6272
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
11 import com.smartgwt.client.types.FormMethod; |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
12 import com.smartgwt.client.widgets.form.DynamicForm; |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
13 import com.smartgwt.client.widgets.form.fields.LinkItem; |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
14 import com.smartgwt.client.widgets.form.fields.events.ClickEvent; |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
15 import com.smartgwt.client.widgets.form.fields.events.ClickHandler; |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
16 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
|
17 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
|
18 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
|
19 |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
20 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
|
21 |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
22 public class WikiLinks |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
23 { |
6230
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
24 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
|
25 String saml = null; |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
26 if (instance != null && instance.getCurrentUser() != null) { |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
27 saml = instance.getCurrentUser().getSamlXMLBase64(); |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
28 } |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
29 String quotedUrl = SafeHtmlUtils.htmlEscape(url); |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
30 String quotedImage = SafeHtmlUtils.htmlEscape(imageUrl); |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
31 |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
32 if (saml != null) { |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
33 return "<form method=\"POST\" target=\"_blank\" action=\"" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
34 + quotedUrl + "\">" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
35 + "<input type=\"hidden\" name=\"saml\" value=\"" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
36 + SafeHtmlUtils.htmlEscape(saml) + "\">" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
37 + "<input type=\"image\" src=\""+ quotedImage + "\">" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
38 + "</form>"; |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
39 } |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
40 else { |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
41 return "<a href=\"" + quotedUrl + "\"><img src=\"" + quotedImage + "\"></a>"; |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
42 } |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
43 } |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
44 |
6272
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
45 public static DynamicForm linkHTML(FLYS flys, String url, String text) { |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 if (saml != null) { |
6272
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
50 final DynamicForm form = new DynamicForm(); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
51 form.setMethod(FormMethod.POST); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
52 form.setTarget("_blank"); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
53 form.setAction(quotedUrl); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
54 form.setCanSubmit(true); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
55 LinkItem item = new LinkItem("saml"); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
56 item.setShowTitle(false); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
57 item.setLinkTitle(quotedText); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
58 item.setValue(SafeHtmlUtils.htmlEscape(saml)); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
59 item.addClickHandler(new ClickHandler() { |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
60 @Override |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
61 public void onClick(ClickEvent event) { |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
62 form.submitForm(); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
63 } |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
64 }); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
65 form.setFields(item); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
66 return form; |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
67 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
68 else { |
6272
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
69 DynamicForm form = new DynamicForm(); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
70 LinkItem item = new LinkItem(quotedText); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
71 item.setShowTitle(false); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
72 item.setTarget(quotedUrl); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
73 return form; |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
74 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
75 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
76 } |