From 8896b102315dd7c3525e72b53abe82ac609b3755 Mon Sep 17 00:00:00 2001
From: Nils Christian Ehmke <nie@informatik.uni-kiel.de>
Date: Mon, 8 Oct 2012 10:21:23 +0200
Subject: [PATCH] Replaced the locale-property with the browser's configuration
 of the user.

---
 .../session/CurrentConfigurationBean.java     | 27 -------------------
 .../kieker/webgui/beans/session/UserBean.java | 16 +++--------
 .../src/main/webapp/AnalysisEditor.xhtml      |  2 +-
 .../src/main/webapp/Controller.xhtml          |  2 +-
 Kieker.WebGUI/src/main/webapp/Login.xhtml     |  2 +-
 .../src/main/webapp/ProjectOverview.xhtml     |  2 +-
 Kieker.WebGUI/src/main/webapp/css/Common.css  |  8 ++++++
 .../main/webapp/dialogs/settingsDialog.xhtml  | 12 ++++-----
 8 files changed, 21 insertions(+), 50 deletions(-)

diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentConfigurationBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentConfigurationBean.java
index cf246f53..76c67761 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentConfigurationBean.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentConfigurationBean.java
@@ -16,7 +16,6 @@
 
 package kieker.webgui.beans.session;
 
-import java.util.Locale;
 import java.util.Map;
 
 import javax.annotation.PostConstruct;
@@ -40,7 +39,6 @@ import kieker.webgui.beans.application.GlobalPropertiesBean;
 @SessionScoped
 public final class CurrentConfigurationBean {
 
-	private String locale;
 	private String lookAndFeel;
 	private String gridColor;
 	private int gridSize;
@@ -160,26 +158,6 @@ public final class CurrentConfigurationBean {
 		}
 	}
 
-	public void setLocale(final String locale) {
-		synchronized (this) {
-			this.locale = locale;
-			CurrentConfigurationBean.saveValueInCookie(this.globalPropertiesBean.getLanguageCookieName(), locale);
-
-		}
-	}
-
-	public String getLocale() {
-		synchronized (this) {
-			return this.locale;
-		}
-	}
-
-	public Locale getLocaleObject() {
-		synchronized (this) {
-			return new Locale(this.locale);
-		}
-	}
-
 	/**
 	 * This method tries to load the default values of the properties from the {@link GlobalPropertiesBean} and the faces context.
 	 */
@@ -197,8 +175,6 @@ public final class CurrentConfigurationBean {
 
 			this.gridColor = this.globalPropertiesBean.getAnalysisEditorDefaultGridColor();
 			this.gridSize = Integer.parseInt(this.globalPropertiesBean.getAnalysisEditorDefaultGridSize());
-
-			this.locale = "en";
 		}
 	}
 
@@ -220,9 +196,6 @@ public final class CurrentConfigurationBean {
 			if (cookies.containsKey(this.globalPropertiesBean.getAnalysisEditorGridSizeCookieName())) {
 				this.gridSize = Integer.parseInt(((Cookie) cookies.get(this.globalPropertiesBean.getAnalysisEditorGridSizeCookieName())).getValue());
 			}
-			if (cookies.containsKey(this.globalPropertiesBean.getLanguageCookieName())) {
-				this.locale = ((Cookie) cookies.get(this.globalPropertiesBean.getLanguageCookieName())).getValue();
-			}
 		}
 	}
 
diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java
index 02e4db07..8141f452 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java
@@ -19,6 +19,7 @@ package kieker.webgui.beans.session;
 import javax.faces.bean.ManagedBean;
 import javax.faces.bean.ManagedProperty;
 import javax.faces.bean.SessionScoped;
+import javax.faces.context.FacesContext;
 
 import kieker.webgui.beans.application.GlobalPropertiesBean;
 
@@ -43,9 +44,6 @@ public final class UserBean {
 	@ManagedProperty(value = "#{globalPropertiesBean}")
 	private GlobalPropertiesBean globalPropertiesBean;
 
-	@ManagedProperty(value = "#{currentConfigurationBean}")
-	private CurrentConfigurationBean currentConfigurationBean;
-
 	/**
 	 * Default constructor. <b>Do not use this constructor. This bean is JSF managed.</b>
 	 */
@@ -112,22 +110,14 @@ public final class UserBean {
 		this.globalPropertiesBean = globalPropertiesBean;
 	}
 
-	public CurrentConfigurationBean getCurrentConfigurationBean() {
-		return this.currentConfigurationBean;
-	}
-
-	public void setCurrentConfigurationBean(final CurrentConfigurationBean currentConfigurationBean) {
-		this.currentConfigurationBean = currentConfigurationBean;
-	}
-
 	/**
 	 * This method shows the welcome message using the growl component and the global properties.
 	 */
 	public void showWelcomeMessage() {
 		if (this.globalPropertiesBean != null) {
 			final String finalMsg = String.format(UserBean.WELCOME_MSG_TEMPLATE,
-					this.globalPropertiesBean.getShortWelcomeMessage(this.currentConfigurationBean.getLocaleObject()),
-					this.globalPropertiesBean.getWelcomeMessage(this.currentConfigurationBean.getLocaleObject()));
+					this.globalPropertiesBean.getShortWelcomeMessage(FacesContext.getCurrentInstance().getELContext().getLocale()),
+					this.globalPropertiesBean.getWelcomeMessage(FacesContext.getCurrentInstance().getELContext().getLocale()));
 
 			RequestContext.getCurrentInstance().execute(finalMsg);
 		}
diff --git a/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml b/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml
index 97f2240b..cc3978dd 100644
--- a/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml
+++ b/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml
@@ -13,7 +13,7 @@
         <f:event type="preRenderView" listener="#{currentAnalysisEditorBean.initialize()}"  />
     </f:metadata>
 
-    <f:view locale="#{currentConfigurationBean.locale}">
+    <f:view>
         <h:head>
             <title>Kieker.WebGUI</title>
             <!-- Load the necessary CSS files. -->
diff --git a/Kieker.WebGUI/src/main/webapp/Controller.xhtml b/Kieker.WebGUI/src/main/webapp/Controller.xhtml
index e0039b07..bff0f0b0 100644
--- a/Kieker.WebGUI/src/main/webapp/Controller.xhtml
+++ b/Kieker.WebGUI/src/main/webapp/Controller.xhtml
@@ -11,7 +11,7 @@
         <f:viewParam name="projectName" value="#{currentControllerBean.projectName}"/>
     </f:metadata>
 
-    <f:view locale="#{currentConfigurationBean.locale}">
+    <f:view>
         <h:head>
             <title>Kieker.WebGUI</title>
             <link rel="stylesheet" type="text/css" href="../css/Common.css" />
diff --git a/Kieker.WebGUI/src/main/webapp/Login.xhtml b/Kieker.WebGUI/src/main/webapp/Login.xhtml
index 0f86c8d3..567d2d51 100644
--- a/Kieker.WebGUI/src/main/webapp/Login.xhtml
+++ b/Kieker.WebGUI/src/main/webapp/Login.xhtml
@@ -5,7 +5,7 @@
       xmlns:p="http://primefaces.org/ui"
       xmlns:f="http://java.sun.com/jsf/core">
 
-    <f:view locale="#{currentConfigurationBean.locale}">
+    <f:view>
         <h:head>
             <title>Kieker.WebGUI</title>
             <link rel="stylesheet" type="text/css" href="../css/Common.css" />
diff --git a/Kieker.WebGUI/src/main/webapp/ProjectOverview.xhtml b/Kieker.WebGUI/src/main/webapp/ProjectOverview.xhtml
index 917acbe5..7bfc480f 100644
--- a/Kieker.WebGUI/src/main/webapp/ProjectOverview.xhtml
+++ b/Kieker.WebGUI/src/main/webapp/ProjectOverview.xhtml
@@ -6,7 +6,7 @@
       xmlns:p="http://primefaces.org/ui"
       xmlns:f="http://java.sun.com/jsf/core">
 
-    <f:view locale="#{currentConfigurationBean.locale}">
+    <f:view>
         <h:head>
             <title>Kieker.WebGUI</title>
             <link rel="stylesheet" type="text/css" href="../css/Common.css" />
diff --git a/Kieker.WebGUI/src/main/webapp/css/Common.css b/Kieker.WebGUI/src/main/webapp/css/Common.css
index da437091..614fbdd5 100644
--- a/Kieker.WebGUI/src/main/webapp/css/Common.css
+++ b/Kieker.WebGUI/src/main/webapp/css/Common.css
@@ -241,4 +241,12 @@
     background: url('../img/icons/ManageLibraries.png') no-repeat !important;
     height:16px;
     width:16px;
+}
+
+.rightAlignedColumn {
+    text-align: right !important;
+}
+
+.normalColumn {
+    
 }
\ No newline at end of file
diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/settingsDialog.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/settingsDialog.xhtml
index 114993ea..addc177d 100644
--- a/Kieker.WebGUI/src/main/webapp/dialogs/settingsDialog.xhtml
+++ b/Kieker.WebGUI/src/main/webapp/dialogs/settingsDialog.xhtml
@@ -10,7 +10,7 @@
         <h:form>
             <p:tabView>
                 <p:tab title="#{localizedMessages.common}">
-                    <h:panelGrid columns="2" cellpadding="10">
+                    <h:panelGrid columns="2" cellpadding="10" columnClasses="rightAlignedColumn, normalColumn">
                         <h:outputText value="#{localizedMessages.lookAndFeel}:" />
                         <p:themeSwitcher value="#{currentConfigurationBean.lookAndFeel}" style="width:150px" effect="fade">
                             <f:selectItem itemLabel="#{localizedMessages.chooseTheme}" itemValue="" />
@@ -18,24 +18,24 @@
                         </p:themeSwitcher>
 
                         <h:outputText value="#{localizedMessages.language}:"/>
-                        <p:selectOneMenu value="#{currentConfigurationBean.locale}" style="width:150px"> 
+                        <p:selectOneMenu value="#{facesContext.ELContext.locale.toString()}" style="width:150px" disabled="true"> 
                             <f:selectItem itemValue="en" itemLabel="English"/>
                             <f:selectItem itemValue="de" itemLabel="Deutsch"/>
                         </p:selectOneMenu>
                     </h:panelGrid>
                 </p:tab>
                 <p:tab title="#{localizedMessages.analysisEditor}">
-                    <h:panelGrid columns="2" cellpadding="10">
+                    <h:panelGrid columns="2" cellpadding="10" columnClasses="rightAlignedColumn, normalColumn">
                         <h:outputText value="#{localizedMessages.toolPalette}:"/>
-                        <p:selectOneMenu style="width:150px">
+                        <p:selectOneMenu style="width: 100%">
                             <f:selectItem itemLabel="#{localizedMessages.lists}"/>
                         </p:selectOneMenu>
 
                         <h:outputText value="#{localizedMessages.gridSize}:"/>
-                        <p:spinner value="#{currentConfigurationBean.gridSize}" valueChangeListener="#{currentAnalysisEditorBean.gridSizeListener}" suffix=" [px]"/>
+                        <p:spinner style="width: 100%" value="#{currentConfigurationBean.gridSize}" valueChangeListener="#{currentAnalysisEditorBean.gridSizeListener}" suffix=" [px]"/>
 
                         <h:outputText value="#{localizedMessages.gridColor}:"/>
-                        <p:colorPicker value="#{currentConfigurationBean.gridColor}" valueChangeListener="#{currentAnalysisEditorBean.gridColorListener}"/>
+                        <p:colorPicker style="width: 100%" value="#{currentConfigurationBean.gridColor}" valueChangeListener="#{currentAnalysisEditorBean.gridColorListener}"/>
                     </h:panelGrid>
                 </p:tab>
                 <p:tab title="#{localizedMessages.analysisController}" disabled="true">
-- 
GitLab