annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java @ 6602:244beb29418e

Fix for SAML authentication in FLYSHeader's Info button (#702).
author Christian Lins <christian.lins@intevation.de>
date Thu, 18 Jul 2013 13:25:29 +0200
parents c949681a0ccb
children 9f3ffb218bc0
rev   line source
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
6 * documentation coming with Dive4Elements River for details.
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 package org.dive4elements.river.client.client.ui;
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import com.google.gwt.core.client.GWT;
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
12 import com.google.gwt.i18n.client.LocaleInfo;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
13 import com.google.gwt.user.client.Window;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
14 import com.google.gwt.user.client.rpc.AsyncCallback;
6602
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
15 import com.google.gwt.user.client.ui.HTML;
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import com.smartgwt.client.types.Alignment;
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
17 import com.smartgwt.client.types.VerticalAlignment;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
18 import com.smartgwt.client.util.BooleanCallback;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
19 import com.smartgwt.client.util.SC;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
20 import com.smartgwt.client.widgets.Button;
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import com.smartgwt.client.widgets.Img;
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import com.smartgwt.client.widgets.Label;
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
23 import com.smartgwt.client.widgets.events.ClickEvent;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
24 import com.smartgwt.client.widgets.events.ClickHandler;
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
25 import com.smartgwt.client.widgets.layout.HLayout;
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
27 import org.dive4elements.river.client.client.Config;
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
28 import org.dive4elements.river.client.client.FLYS;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
29 import org.dive4elements.river.client.client.FLYSConstants;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
30 import org.dive4elements.river.client.client.services.UserService;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
31 import org.dive4elements.river.client.client.services.UserServiceAsync;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
32 import org.dive4elements.river.client.shared.model.User;
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 /**
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
36 * Header of the FLYS webpage/app.
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
37 *
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 */
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 public class FLYSHeader extends HLayout {
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 /** The interface that provides the message resources. */
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
43 private final FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 /** The height used for this header.*/
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
46 public static final int HEIGHT = 56;
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 /** The height used for the images.*/
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 public static final int IMG_HEIGHT = 50;
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
51 /** The user that is currently logged in. */
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
52 private User currentUser;
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
54 /** The label that displays the current logged in user. */
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
55 private final Label userText;
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
56
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
57 /** The button to log the current user out.*/
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
58 private final Button logout;
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
59
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
60 /** The button to open the project list.*/
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
61 private final Button projectList;
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
62
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
63 /** The button to switch between the english and german version.*/
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
64 private final Button language;
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
65
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
66 /** The button to open an info panel.*/
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
67 private final Button info;
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
68
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
69 private final UserServiceAsync userService =
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
70 GWT.create(UserService.class);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
71
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
72 /** An instance to FLYS.*/
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
73 private final FLYS flys;
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
74
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
75
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
76 public FLYSHeader(FLYS flys) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
77 this.flys = flys;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
78
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
79 String guest = MESSAGES.user() + " " + MESSAGES.guest();
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
80
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
81 userText = new Label(guest);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
82 projectList = new Button(MESSAGES.manage_projects());
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
83 logout = new Button(MESSAGES.logout());
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
84 language = new Button(MESSAGES.switch_language());
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
85 info = new Button(MESSAGES.info());
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
86
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
87 projectList.addClickHandler(new ClickHandler() {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
88 @Override
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
89 public void onClick(ClickEvent event) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
90 GWT.log("Clicked 'Open ProjectList' button.");
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
91 getFlys().openProjectList();
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
92 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
93 });
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
94
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
95 logout.addClickHandler(new ClickHandler() {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
96 @Override
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
97 public void onClick(ClickEvent event) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
98 GWT.log("Clicked 'logout' button.");
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
99 userService.logoutCurrentUser(new AsyncCallback<Void>() {
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
100 @Override
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
101 public void onFailure(Throwable caught) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
102 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
103
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
104 @Override
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
105 public void onSuccess(Void result) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
106 /* Just reload the page. GGInAFilter is goint to redirect
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
107 * to the correct login page */
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
108 Window.Location.reload();
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
109 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
110 });
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
111
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
112 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
113 });
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
114
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
115 language.addClickHandler(new ClickHandler() {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
116 @Override
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
117 public void onClick(ClickEvent event) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
118 LocaleInfo info = LocaleInfo.getCurrentLocale();
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
119 final String currentLocale = info.getLocaleName();
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
120 final String newLocale = currentLocale.equals("de")
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
121 ? "en"
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
122 : "de";
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
123
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
124 SC.confirm(MESSAGES.warning(), MESSAGES.warning_language(),
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
125 new BooleanCallback() {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
126 @Override
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
127 public void execute(Boolean value) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
128 if (value) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
129 switchLanguage(currentLocale, newLocale);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
130 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
131 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
132 });
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
133 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
134 });
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
135
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
136 info.addClickHandler(new ClickHandler() {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
137 @Override
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
138 public void onClick(ClickEvent event) {
6437
0341504e9deb Info-Button now leads to $WIKI_URL/Info. Ticket for authentication not implemented yet.
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
139 String wikiLink = Config.getInstance().getWikiUrl() + "/Info";
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6437
diff changeset
140
6602
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
141 // Create a form which contains the SAML session
6546
7106f9b75004 Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents: 6437
diff changeset
142 // for the user which is currently logged in
6602
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
143 String html = WikiLinks.imageLinkForm(
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
144 getFlys(), wikiLink, "", "wikiLinkForm");
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
145 HTML htmlObj = new HTML(html);
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
146 info.addChild(htmlObj);
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
147 fireWikiLinkSubmit();
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
148 htmlObj.removeFromParent();
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
149 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
150 });
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 init();
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 }
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153
6602
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
154 /**
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
155 * Calls the JS submit() function on the dynamically added
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
156 * wikiLinkForm. This is a workaround for a SmartGWT issue(?) that
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
157 * clears all form fields when using DynamicForm.submit() or .submitForm().
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
158 */
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
159 protected native void fireWikiLinkSubmit() /*-{
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
160 $doc.wikiLinkForm.submit();
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
161 }-*/;
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
162
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 public void init() {
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
164 setStyleName("header");
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 setWidth100();
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166 setHeight(HEIGHT);
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
167 setBackgroundColor("#a9c9e6");
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 setLayoutLeftMargin(5);
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 setLayoutRightMargin(5);
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170
1399
748e7c828d03 Issue312.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 211
diff changeset
171 String baseUrl = GWT.getHostPageBaseURL();
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 Img flys = new Img(
1399
748e7c828d03 Issue312.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 211
diff changeset
174 baseUrl + MESSAGES.flysLogo(),
748e7c828d03 Issue312.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 211
diff changeset
175 50,
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 IMG_HEIGHT);
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
178 Img bfg = new Img(
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
179 baseUrl + MESSAGES.bfgLogoSmall(),
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
180 150,
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
181 IMG_HEIGHT);
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 Label fullname = new Label(MESSAGES.fullname());
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184 fullname.setHeight(HEIGHT - IMG_HEIGHT);
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
185 fullname.setStyleName("fontBlackMid");
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
187 HLayout left = new HLayout();
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
188 left.setDefaultLayoutAlign(VerticalAlignment.CENTER);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
189 left.setMembersMargin(3);
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 left.addMember(flys);
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 left.addMember(fullname);
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 HLayout right = new HLayout();
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194 right.setAlign(Alignment.RIGHT);
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
195 right.setDefaultLayoutAlign(Alignment.RIGHT);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
196 right.setDefaultLayoutAlign(VerticalAlignment.CENTER);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
197 right.setMembersMargin(3);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
198 right.setLayoutRightMargin(5);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
199
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
200 projectList.setStyleName("manageProjects");
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
201 userText.setStyleName("fontBlackSmall");
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
202 logout.setStyleName("fontLightSmall");
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
203 language.setStyleName("fontLightSmall");
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
204 info.setStyleName("fontLightSmall");
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
205
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
206 userText.setAlign(Alignment.RIGHT);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
207 userText.setWidth(200);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
208 logout.setWidth(70);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
209 info.setWidth(40);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
210 language.setWidth(70);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
211
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
212 left.addMember(projectList);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
213 if (this.flys.isProjectListVisible()) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
214 hideProjectButton();
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
215 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
216 else {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
217 showProjectButton();
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
218 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
219
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
220 right.addMember(userText);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
221 right.addMember(logout);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
222 right.addMember(language);
6602
244beb29418e Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents: 6558
diff changeset
223 right.addMember(info);
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 right.addMember(bfg);
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226 addMember(left);
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
227 addMember(right);
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228 }
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
229
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
230 /**
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
231 * Returns the FLYS instance stored in this class.
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
232 *
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
233 * @return the flys instance.
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
234 */
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
235 private FLYS getFlys() {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
236 return flys;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
237 }
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
238
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
239 /**
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
240 * This method triggers the language switch between the <i>currentLocale</i>
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
241 * and the <i>newLocale</i>. The switch is done by replacing a "locale="
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
242 * parameter in the url of the application. We could use the GWT UrlBuilder
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
243 * class to create a new URL, but - in my eyes - this class is a bit
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
244 * inconsistens in its implementation.
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245 *
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
246 * @param currentLocale The current locale string (e.g. "en").
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
247 * @param newLocale The new locale string (e.g. "de").
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248 */
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
249 private void switchLanguage(String currentLocale, String newLocale) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
250 String newLocation = Window.Location.getHref();
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
252 if (newLocation.endsWith("/")) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
253 newLocation = newLocation.substring(0, newLocation.length()-1);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
254 }
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255
4602
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
256 String replace = null;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
257 String replaceWith = null;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
258
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
259 if (newLocation.indexOf("&locale=") >= 0) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
260 replace = currentLocale.equals("de")
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
261 ? "&locale=de"
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
262 : "&locale=en";
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
263
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
264 replaceWith = "&locale=" + newLocale;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
265 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
266 else if (newLocation.indexOf("?locale=") >= 0) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
267 replace = currentLocale.equals("de")
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
268 ? "?locale=de"
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
269 : "?locale=en";
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
270
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
271 replaceWith = "?locale=" + newLocale;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
272 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
273 else {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
274 newLocation += newLocation.indexOf("?") >= 0
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
275 ? "&locale=" + newLocale
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
276 : "?locale=" + newLocale;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
277 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
278
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
279 if (replace != null && replaceWith != null) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
280 newLocation = newLocation.replace(replace, replaceWith);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
281 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
282
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
283 Window.open(newLocation, "_self", "");
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
284 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
285
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
286 /**
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
287 * Update the text field that shows the current user. If no user is
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
288 * currently logged in, the text will display {@link FLYSConstants.guest()}.
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
289 */
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
290 private void updateCurrentUser() {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
291 String name = currentUser != null
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
292 ? currentUser.getName()
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
293 : MESSAGES.guest();
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
294
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
295 GWT.log("Update the current user: " + name);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
296
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
297 String username = MESSAGES.user() + " " + name;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
298 userText.setContents(username);
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
299 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
300
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
301 /**
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
302 * Set the current {@link User} and call {@link updateCurrentUser()}
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
303 * afterwards.
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
304 *
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
305 * @param user the new user.
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
306 */
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
307 public void setCurrentUser(User currentUser) {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
308 this.currentUser = currentUser;
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
309
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
310 updateCurrentUser();
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
311 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
312
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
313 public void hideProjectButton() {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
314 this.projectList.hide();
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
315 }
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
316
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
317 public void showProjectButton() {
33bb8bf3899a Merge the MainMenu into the FLYSHeader
Björn Ricks <bjoern.ricks@intevation.de>
parents: 1401
diff changeset
318 this.projectList.show();
27
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
319 }
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
320 }
e4155a6833a9 Integrated a header that contains a FLYS and a BfG logo.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
321 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org