annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java @ 8870:c26fb37899ca

Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui. Also using now the localization info from the server instead of localizing the modules again on the client side.
author gernotbelger
date Wed, 07 Feb 2018 11:59:13 +0100
parents 5e38e2924c07
children
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
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
11 import com.google.gwt.core.client.GWT;
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
12 import com.google.gwt.safehtml.shared.SafeHtmlUtils;
6272
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.types.FormMethod;
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.DynamicForm;
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
15 import com.smartgwt.client.widgets.form.fields.HiddenItem;
6272
24be0cc1c67c Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents: 6230
diff changeset
16 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
17 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
18 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
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;
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
21 import org.dive4elements.river.client.shared.model.User;
6189
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
22
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
23 public class WikiLinks
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
24 {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
25 public static String imageLinkForm(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
26 FLYS instance,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
27 String url,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
28 String imageUrl,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
29 String formName
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
30 ) {
6230
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
31 String saml = null;
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
32 if (instance != null && instance.getCurrentUser() != null) {
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
33 saml = instance.getCurrentUser().getSamlXMLBase64();
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 String quotedUrl = SafeHtmlUtils.htmlEscape(url);
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
36 String quotedImage = SafeHtmlUtils.htmlEscape(imageUrl);
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 if (saml != null) {
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
39 return "<form method=\"POST\" target=\"_blank\" action=\""
6602
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6546
diff changeset
40 + quotedUrl + "\" " + "name=\"" + formName + "\">"
6230
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
41 + "<input type=\"hidden\" name=\"saml\" value=\""
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
42 + SafeHtmlUtils.htmlEscape(saml) + "\">"
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
43 + "<input type=\"image\" src=\""+ quotedImage + "\">"
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
44 + "</form>";
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
45 }
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
46 else {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
47 return "<a href=\"" + quotedUrl
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
48 + "\"><img src=\"" + quotedImage + "\"></a>";
6230
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
49 }
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
50 }
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
51
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
52 public static DynamicForm linkDynamicForm(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
53 FLYS flys,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
54 String url,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
55 String text
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7943
diff changeset
56 ) {
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
57 User currentUser = flys.getCurrentUser();
6189
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
58 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
59 String quotedText = SafeHtmlUtils.htmlEscape(text);
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
60
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
61 if (currentUser != null) {
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
62 String saml = currentUser.getSamlXMLBase64();
6986
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
63 if (saml != null) {
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
64 final DynamicForm form = new DynamicForm();
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
65 form.setMethod(FormMethod.POST);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
66 form.setTarget("_blank");
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
67 form.setAction(quotedUrl);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
68 form.setCanSubmit(true);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
69 LinkItem item = new LinkItem("saml");
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
70 item.setTextBoxStyle("font-size: large;");
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
71 item.setShowTitle(false);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
72 item.setLinkTitle(quotedText);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
73 item.setValue(SafeHtmlUtils.htmlEscape(saml));
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
74 item.addClickHandler(new ClickHandler() {
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
75 @Override
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
76 public void onClick(ClickEvent event) {
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
77 form.submitForm();
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
78 }
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
79 });
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
80 form.setFields(item);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
81 return form;
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
82 }
6189
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
83 }
6986
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
84 DynamicForm form = new DynamicForm();
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
85 LinkItem item = new LinkItem(quotedText);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
86 item.setShowTitle(false);
7943
bef9937a2dd9 Fixed "pegelinfo"-wiki links.
Raimund Renkert <rrenkert@intevation.de>
parents: 6986
diff changeset
87 item.setLinkTitle(quotedText);
6986
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
88 item.setTarget(quotedUrl);
7943
bef9937a2dd9 Fixed "pegelinfo"-wiki links.
Raimund Renkert <rrenkert@intevation.de>
parents: 6986
diff changeset
89 form.setItems(item);
6986
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
90 return form;
6189
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
91 }
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
92
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
93 public static DynamicForm dynamicForm(FLYS flys, String url) {
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
94 User currentUser = flys.getCurrentUser();
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
95 String quotedUrl = SafeHtmlUtils.htmlEscape(url);
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
96
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
97 if (currentUser != null) {
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
98 String saml = currentUser.getSamlXMLBase64();
6986
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
99 if (saml != null) {
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
100 saml = SafeHtmlUtils.htmlEscape(saml);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
101 GWT.log("saml=" + saml);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
102 DynamicForm form = new DynamicForm();
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
103 form.setID("wikiDynamicForm");
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
104 form.setMethod(FormMethod.POST);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
105 form.setTarget("_blank");
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
106 form.setAction(quotedUrl);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
107 form.setCanSubmit(true);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
108 HiddenItem item = new HiddenItem("saml");
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
109 item.setDefaultValue(saml);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
110 item.setValue(saml);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
111 form.setFields(item);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
112 //form.setValue("saml", saml);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
113 return form;
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
114 }
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
115 }
6986
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
116 DynamicForm form = new DynamicForm();
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
117 form.setTarget("_blank");
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
118 form.setAction(quotedUrl);
e562a9a42495 GWT client: Do not assumed there is always a SAML ticket when generating Wiki links.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6602
diff changeset
119 return form;
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
120 }
6189
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
121 }

http://dive4elements.wald.intevation.org