]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/UiContext.java
Move JCR utilities from API to CMS JCR
[lgpl/argeo-commons.git] / org.argeo.eclipse.ui.rap / src / org / argeo / eclipse / ui / specific / UiContext.java
index ce50873f8b185589684492670c8cc97a6f944e6e..dac270026311815f71d8cd5b20c358c03546a310 100644 (file)
@@ -1,17 +1,38 @@
 package org.argeo.eclipse.ui.specific;
 
+import java.util.Locale;
+
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import org.eclipse.rap.rwt.RWT;
 import org.eclipse.swt.widgets.Display;
 
 /** Singleton class providing single sources infos about the UI context. */
 public class UiContext {
-
+       /** Can be null, thus indicating that we are not in a web context. */
        public static HttpServletRequest getHttpRequest() {
                return RWT.getRequest();
        }
 
+       public static HttpServletResponse getHttpResponse() {
+               return RWT.getResponse();
+       }
+
+       public static Locale getLocale() {
+               if (Display.getCurrent() != null)
+                       return RWT.getUISession().getLocale();
+               else
+                       return Locale.getDefault();
+       }
+
+       public static void setLocale(Locale locale) {
+               if (Display.getCurrent() != null)
+                       RWT.getUISession().setLocale(locale);
+               else
+                       Locale.setDefault(locale);
+       }
+
        /** Can always be null */
        @SuppressWarnings("unchecked")
        public static <T> T getData(String key) {
@@ -24,8 +45,7 @@ public class UiContext {
        public static void setData(String key, Object value) {
                Display display = getDisplay();
                if (display == null)
-                       throw new SingleSourcingException(
-                                       "Not display available in RAP context");
+                       throw new SingleSourcingException("Not display available in RAP context");
                display.setData(key, value);
        }