]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/UiContext.java
ec3b2e96a62eb18cd162a25b167625223e03e984
1 package org
.argeo
.eclipse
.ui
.specific
;
3 import java
.util
.Locale
;
5 import javax
.servlet
.http
.HttpServletRequest
;
7 import org
.eclipse
.rap
.rwt
.RWT
;
8 import org
.eclipse
.swt
.widgets
.Display
;
10 /** Singleton class providing single sources infos about the UI context. */
11 public class UiContext
{
12 /** Can be null, thus indicating that we are not in a web context. */
13 public static HttpServletRequest
getHttpRequest() {
14 return RWT
.getRequest();
17 public static Locale
getLocale() {
18 if (Display
.getCurrent() != null)
19 return RWT
.getUISession().getLocale();
21 return Locale
.getDefault();
24 public static void setLocale(Locale locale
) {
25 if (Display
.getCurrent() != null)
26 RWT
.getUISession().setLocale(locale
);
28 Locale
.setDefault(locale
);
31 /** Can always be null */
32 @SuppressWarnings("unchecked")
33 public static <T
> T
getData(String key
) {
34 Display display
= getDisplay();
37 return (T
) display
.getData(key
);
40 public static void setData(String key
, Object value
) {
41 Display display
= getDisplay();
43 throw new SingleSourcingException(
44 "Not display available in RAP context");
45 display
.setData(key
, value
);
48 private static Display
getDisplay() {
49 return Display
.getCurrent();