Move locallization addon
authormbaudier <mbaudier@europe>
Tue, 3 Jul 2018 07:40:29 +0000 (09:40 +0200)
committermbaudier <mbaudier@europe>
Tue, 3 Jul 2018 07:40:29 +0000 (09:40 +0200)
org.argeo.cms.e4/src/org/argeo/cms/e4/addons/LocaleAddon.java [new file with mode: 0644]
org.argeo.cms.e4/src/org/argeo/cms/e4/handlers/LocaleAddon.java [deleted file]

diff --git a/org.argeo.cms.e4/src/org/argeo/cms/e4/addons/LocaleAddon.java b/org.argeo.cms.e4/src/org/argeo/cms/e4/addons/LocaleAddon.java
new file mode 100644 (file)
index 0000000..5bc0d69
--- /dev/null
@@ -0,0 +1,51 @@
+package org.argeo.cms.e4.addons;
+
+import java.security.AccessController;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import javax.annotation.PostConstruct;
+import javax.security.auth.Subject;
+
+import org.argeo.eclipse.ui.specific.UiContext;
+import org.eclipse.e4.core.services.nls.ILocaleChangeService;
+import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
+import org.eclipse.e4.ui.workbench.modeling.ElementMatcher;
+import org.eclipse.swt.SWT;
+
+/** Integrate workbench with the locale provided at log in. */
+public class LocaleAddon {
+       private final static String STYLE_OVERRIDE = "styleOverride";
+
+       // Right to left languages
+       private final static String ARABIC = "ar";
+       private final static String HEBREW = "he";
+
+       @PostConstruct
+       public void init(ILocaleChangeService localeChangeService, EModelService modelService, MApplication application) {
+               Subject subject = Subject.getSubject(AccessController.getContext());
+               Set<Locale> locales = subject.getPublicCredentials(Locale.class);
+               if (!locales.isEmpty()) {
+                       Locale locale = locales.iterator().next();
+                       localeChangeService.changeApplicationLocale(locale);
+                       UiContext.setLocale(locale);
+
+                       if (locale.getLanguage().equals(ARABIC) || locale.getLanguage().equals(HEBREW)) {
+                               List<MWindow> windows = modelService.findElements(application, MWindow.class, EModelService.ANYWHERE,
+                                               new ElementMatcher(null, null, (String) null));
+                               for (MWindow window : windows) {
+                                       String currentStyle = window.getPersistedState().get(STYLE_OVERRIDE);
+                                       int style = 0;
+                                       if (currentStyle != null) {
+                                               style = Integer.parseInt(currentStyle);
+                                       }
+                                       style = style | SWT.RIGHT_TO_LEFT;
+                                       window.getPersistedState().put(STYLE_OVERRIDE, Integer.toString(style));
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.argeo.cms.e4/src/org/argeo/cms/e4/handlers/LocaleAddon.java b/org.argeo.cms.e4/src/org/argeo/cms/e4/handlers/LocaleAddon.java
deleted file mode 100644 (file)
index 94140a6..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.argeo.cms.e4.handlers;
-
-import java.security.AccessController;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-
-import javax.annotation.PostConstruct;
-import javax.security.auth.Subject;
-
-import org.argeo.eclipse.ui.specific.UiContext;
-import org.eclipse.e4.core.services.nls.ILocaleChangeService;
-import org.eclipse.e4.ui.model.application.MApplication;
-import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
-import org.eclipse.e4.ui.workbench.modeling.EModelService;
-import org.eclipse.e4.ui.workbench.modeling.ElementMatcher;
-import org.eclipse.swt.SWT;
-
-/** Integrate workbench with the locale provided at log in. */
-public class LocaleAddon {
-       private final static String STYLE_OVERRIDE = "styleOverride";
-
-       // Right to left languages
-       private final static String ARABIC = "ar";
-       private final static String HEBREW = "he";
-
-       @PostConstruct
-       public void init(ILocaleChangeService localeChangeService, EModelService modelService, MApplication application) {
-               Subject subject = Subject.getSubject(AccessController.getContext());
-               Set<Locale> locales = subject.getPublicCredentials(Locale.class);
-               if (!locales.isEmpty()) {
-                       Locale locale = locales.iterator().next();
-                       localeChangeService.changeApplicationLocale(locale);
-                       UiContext.setLocale(locale);
-
-                       if (locale.getLanguage().equals(ARABIC) || locale.getLanguage().equals(HEBREW)) {
-                               List<MWindow> windows = modelService.findElements(application, MWindow.class, EModelService.ANYWHERE,
-                                               new ElementMatcher(null, null, (String) null));
-                               for (MWindow window : windows) {
-                                       String currentStyle = window.getPersistedState().get(STYLE_OVERRIDE);
-                                       int style = 0;
-                                       if (currentStyle != null) {
-                                               style = Integer.parseInt(currentStyle);
-                                       }
-                                       style = style | SWT.RIGHT_TO_LEFT;
-                                       window.getPersistedState().put(STYLE_OVERRIDE, Integer.toString(style));
-                               }
-                       }
-               }
-       }
-}