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

issue1596: Store table (cell) data twice: Once as (formatted) string as coming from server, once transformed into float (or string). The benefit is that now we can sort table data numerically, while keeping the formatted and i18ned display of values.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 27 Nov 2013 14:55:25 +0100
parents e562a9a42495
children bef9937a2dd9
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 {
6602
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6546
diff changeset
25 public static String imageLinkForm(FLYS instance, String url, String imageUrl, String formName) {
6230
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
26 String saml = null;
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
27 if (instance != null && instance.getCurrentUser() != null) {
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
28 saml = instance.getCurrentUser().getSamlXMLBase64();
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 String quotedUrl = SafeHtmlUtils.htmlEscape(url);
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
31 String quotedImage = SafeHtmlUtils.htmlEscape(imageUrl);
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
32
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
33 if (saml != null) {
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
34 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
35 + quotedUrl + "\" " + "name=\"" + formName + "\">"
6230
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
36 + "<input type=\"hidden\" name=\"saml\" value=\""
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
37 + SafeHtmlUtils.htmlEscape(saml) + "\">"
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
38 + "<input type=\"image\" src=\""+ quotedImage + "\">"
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
39 + "</form>";
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 else {
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
42 return "<a href=\"" + quotedUrl + "\"><img src=\"" + quotedImage + "\"></a>";
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 }
954dbb0806f3 Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents: 6197
diff changeset
45
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
46 public static DynamicForm linkDynamicForm(FLYS flys, String url, String text) {
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
47 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
48 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
49 String quotedText = SafeHtmlUtils.htmlEscape(text);
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
50
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
51 if (currentUser != null) {
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 @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
66 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
67 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
68 }
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 });
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 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
71 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
72 }
6189
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
73 }
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
74 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
75 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
76 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
77 item.setTarget(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
78 return form;
6189
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
79 }
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
80
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
81 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
82 User currentUser = flys.getCurrentUser();
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
83 String quotedUrl = SafeHtmlUtils.htmlEscape(url);
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
84
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
85 if (currentUser != null) {
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
86 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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97 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
98 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
99 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
100 //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
101 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
102 }
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
103 }
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
104 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
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 return form;
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6512
diff changeset
108 }
6189
4365320750bb Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
109 }

http://dive4elements.wald.intevation.org