]> git.argeo.org Git - lgpl/argeo-commons.git/blob - rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/UiContext.java
Move OS to a dedicated package.
[lgpl/argeo-commons.git] / rcp / org.argeo.eclipse.ui.rcp / src / org / argeo / eclipse / ui / specific / UiContext.java
1 package org.argeo.eclipse.ui.specific;
2
3 import java.util.Locale;
4
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
7
8 import org.eclipse.swt.widgets.Display;
9
10 /** Singleton class providing single sources infos about the UI context. */
11 public class UiContext {
12
13 public static HttpServletRequest getHttpRequest() {
14 return null;
15 }
16
17 public static HttpServletResponse getHttpResponse() {
18 return null;
19 }
20
21 public static Locale getLocale() {
22 return Locale.getDefault();
23 }
24
25 public static void setLocale(Locale locale) {
26 Locale.setDefault(locale);
27 }
28
29 /** Can always be null */
30 @SuppressWarnings("unchecked")
31 public static <T> T getData(String key) {
32 Display display = getDisplay();
33 if (display == null)
34 return null;
35 return (T) display.getData(key);
36 }
37
38 public static void setData(String key, Object value) {
39 Display display = getDisplay();
40 if (display == null)
41 throw new SingleSourcingException(
42 "Not display available in RAP context");
43 display.setData(key, value);
44 }
45
46 private static Display getDisplay() {
47 return Display.getCurrent();
48 }
49
50 private UiContext() {
51 }
52
53 }