Improve CMS dialogs and localisation.
[lgpl/argeo-commons.git] / org.argeo.cms.ui.rap / src / org / argeo / cms / web / CmsWebEntryPoint.java
index 470aa5edc0ccc7630e9caee2ace4f73d274212e7..4f2521fd4fa718f0a99cc3a73cd56f5f2b4561ad 100644 (file)
@@ -4,6 +4,7 @@ import static org.eclipse.rap.rwt.internal.service.ContextProvider.getApplicatio
 
 import java.security.PrivilegedAction;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 import java.util.UUID;
 
@@ -14,6 +15,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.LocaleUtils;
 import org.argeo.cms.auth.CmsSession;
 import org.argeo.cms.auth.CurrentUser;
 import org.argeo.cms.auth.HttpRequestCallbackHandler;
@@ -103,6 +105,14 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL
                                try {
                                        uxContext = new SimpleUxContext();
                                        imageManager = new DefaultImageManager();
+                                       CmsSession cmsSession = getCmsSession();
+                                       if (cmsSession != null) {
+                                               UiContext.setLocale(cmsSession.getLocale());
+                                               LocaleUtils.setThreadLocale(cmsSession.getLocale());
+                                       } else {
+                                               Locale rwtLocale = RWT.getUISession().getLocale();
+                                               LocaleUtils.setThreadLocale(rwtLocale);
+                                       }
                                        ui = cmsWebApp.getCmsApp().initUi(parent);
                                        ui.setData(CmsApp.UI_NAME_PROPERTY, uiName);
                                        ui.setLayoutData(CmsUiUtils.fillAll());
@@ -205,7 +215,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);
        }