Set CmsSession locale as RWT locale.
[lgpl/argeo-commons.git] / org.argeo.cms.ui.rap / src / org / argeo / cms / web / CmsWebEntryPoint.java
index 3d353d6b15ea18f816367ad574a6cbbe9fa5c40c..9a023d6bc780f999ee3afa281f46209be413ae7c 100644 (file)
@@ -14,6 +14,7 @@ import javax.security.auth.login.LoginException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.api.NodeConstants;
+import org.argeo.cms.auth.CmsSession;
 import org.argeo.cms.auth.CurrentUser;
 import org.argeo.cms.auth.HttpRequestCallbackHandler;
 import org.argeo.cms.ui.CmsApp;
@@ -102,6 +103,9 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL
                                try {
                                        uxContext = new SimpleUxContext();
                                        imageManager = new DefaultImageManager();
+                                       CmsSession cmsSession = getCmsSession();
+                                       if (cmsSession != null)
+                                               RWT.setLocale(cmsSession.getLocale());
                                        ui = cmsWebApp.getCmsApp().initUi(parent);
                                        ui.setData(CmsApp.UI_NAME_PROPERTY, uiName);
                                        ui.setLayoutData(CmsUiUtils.fillAll());
@@ -158,10 +162,12 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL
 
        @Override
        public void exception(final Throwable e) {
-               CmsFeedback.show("Unexpected exception in CMS", e).block();
-               exception = e;
+               ui.getDisplay().syncExec(() -> {
+                       CmsFeedback.show("Unexpected exception in CMS", e);
+                       exception = e;
 //             log.error("Unexpected exception in CMS", e);
-               doRefresh();
+                       doRefresh();
+               });
        }
 
        protected synchronized void doRefresh() {
@@ -202,7 +208,8 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL
        public void navigateTo(String state) {
                exception = null;
                String title = setState(state);
-               doRefresh();
+               if (title != null)
+                       doRefresh();
                if (browserNavigation != null)
                        browserNavigation.pushState(state, title);
        }
@@ -215,7 +222,7 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL
        @Override
        public void navigated(BrowserNavigationEvent event) {
                setState(event.getState());
-               doRefresh();
+               // doRefresh();
        }
 
        @Override
@@ -229,6 +236,17 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL
                eventAdmin.sendEvent(new Event(topic, properties));
        }
 
+       @Override
+       public void stateChanged(String state, String title) {
+               browserNavigation.pushState(state, title);
+       }
+
+       @Override
+       public CmsSession getCmsSession() {
+               CmsSession cmsSession = CmsSession.getCmsSession(cmsWebApp.getBundleContext(), getSubject());
+               return cmsSession;
+       }
+
        /*
         * EntryPoint IMPLEMENTATION
         */