Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java @ 6512:c28f13c80979
GWT client: Removed obsolete imports.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 28 Jun 2013 20:36:51 +0200 |
parents | 24be0cc1c67c |
children | 7106f9b75004 |
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.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
|
17 |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
18 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
|
19 |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
20 public class WikiLinks |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
21 { |
6230
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
22 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
|
23 String saml = null; |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
24 if (instance != null && instance.getCurrentUser() != null) { |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
25 saml = instance.getCurrentUser().getSamlXMLBase64(); |
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 String quotedUrl = SafeHtmlUtils.htmlEscape(url); |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
28 String quotedImage = SafeHtmlUtils.htmlEscape(imageUrl); |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
29 |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
30 if (saml != null) { |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
31 return "<form method=\"POST\" target=\"_blank\" action=\"" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
32 + quotedUrl + "\">" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
33 + "<input type=\"hidden\" name=\"saml\" value=\"" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
34 + SafeHtmlUtils.htmlEscape(saml) + "\">" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
35 + "<input type=\"image\" src=\""+ quotedImage + "\">" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
36 + "</form>"; |
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 else { |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
39 return "<a href=\"" + quotedUrl + "\"><img src=\"" + quotedImage + "\"></a>"; |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
40 } |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
41 } |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
42 |
6272
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
43 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
|
44 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
|
45 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
|
46 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
|
47 if (saml != null) { |
6272
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
48 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
|
49 form.setMethod(FormMethod.POST); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
50 form.setTarget("_blank"); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
51 form.setAction(quotedUrl); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
52 form.setCanSubmit(true); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
53 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
|
54 item.setShowTitle(false); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
55 item.setLinkTitle(quotedText); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
56 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
|
57 item.addClickHandler(new ClickHandler() { |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
58 @Override |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
59 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
|
60 form.submitForm(); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
61 } |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
62 }); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
63 form.setFields(item); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
64 return form; |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
65 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
66 else { |
6272
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
67 DynamicForm form = new DynamicForm(); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
68 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
|
69 item.setShowTitle(false); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
70 item.setTarget(quotedUrl); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
71 return form; |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
72 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
73 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
74 } |