[kune-commits] r1633 - in trunk: . script src/main/java/cc/kune src/main/java/cc/kune/core/client/auth src/main/java/cc/kune/core/client/errors src/main/java/cc/kune/core/client/i18n src/main/java/cc/kune/core/client/init src/main/java/cc/kune/core/client/sitebar/spaces src/main/java/cc/kune/gspace/client/actions src/main/java/cc/kune/gspace/client/options/general

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Mon Dec 5 21:42:43 CET 2011


Author: vjrj_
Date: 2011-12-05 21:42:43 +0100 (Mon, 05 Dec 2011)
New Revision: 1633

Modified:
   trunk/INSTALL
   trunk/pom.xml
   trunk/script/server.sh
   trunk/src/main/java/cc/kune/Kune.gwt.xml
   trunk/src/main/java/cc/kune/core/client/auth/SignInAbstractPresenter.java
   trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java
   trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java
   trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java
   trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java
   trunk/src/main/java/cc/kune/gspace/client/actions/ParticipateInContentBtn.java
   trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralPresenter.java
   trunk/src/main/java/cc/kune/gspace/client/options/general/GroupOptGeneralPresenter.java
   trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java
Log:
CLOSED - # 176: Ask for confirmation before reload to change the UI to your language 
http://kune.ourproject.org/issues/ticket/176

Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/INSTALL	2011-12-05 20:42:43 UTC (rev 1633)
@@ -171,7 +171,7 @@
 ==Production environment instructions==
 
 With
-  mvn package
+  mvn assembly:assembly
 an executable target/kune-VERSION-jar-with-dependencies.jar is generated in target directory. That you can use to start kune:
 
 bin/server.sh -j kune.jar

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/pom.xml	2011-12-05 20:42:43 UTC (rev 1633)
@@ -927,6 +927,7 @@
           </descriptorRefs>
           <dependencySets>
             <dependencySet>
+              <outputDirectory>/</outputDirectory>
               <scope>runtime</scope>
               <unpackOptions>
                 <excludes>
@@ -936,9 +937,23 @@
                   <exclude>**extjs**</exclude>
                   <exclude>**gxt**</exclude>
                 </excludes>
+                <includes>
+                  <include>${basedir}/target/kune-0.1.0-SNAPSHOT/ws/**</include>
+                  <include>${basedir}/src/main/webapp/**</include>
+                </includes>
               </unpackOptions>
             </dependencySet>
           </dependencySets>
+          <fileSets>
+            <fileSet>
+              <directory>${basedir}</directory>
+              <outputDirectory>/</outputDirectory>
+              <includes>
+                <include>**/target/kune-0.1.0-SNAPSHOT/ws/**</include>
+                <include>**src/main/webapp**</include>
+              </includes>
+            </fileSet>
+          </fileSets>
         </configuration>
       </plugin>
       <plugin>

Modified: trunk/script/server.sh
===================================================================
--- trunk/script/server.sh	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/script/server.sh	2011-12-05 20:42:43 UTC (rev 1633)
@@ -7,7 +7,7 @@
     Example: $0 -j target/kune-0.1.0-SNAPSHOT-jar-with-dependencies.jar -l IGNORE -d -p -u 20000
 
 Options:
--j <jar file> : runs jar file generated via mvn package -Dmaven.test.skip=true
+-j <jar file> : runs jar file generated via mvn assembly:assembly
 -a: run as a daemon (only root user)
 -l LOGLEVEL : IGNORE|DEBUG|INFO|WARN
 

Modified: trunk/src/main/java/cc/kune/Kune.gwt.xml
===================================================================
--- trunk/src/main/java/cc/kune/Kune.gwt.xml	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/src/main/java/cc/kune/Kune.gwt.xml	2011-12-05 20:42:43 UTC (rev 1633)
@@ -56,9 +56,12 @@
   <set-configuration-property name="CssResource.style"
     value="pretty" />
   <!-- I18n ===================================================== -->
-  <extend-property name="locale" values="en" />
-  <extend-property name="locale" values="es" />
-  <extend-property name="locale" values="fr" />
+  <!-- http://bit.ly/uCiBDm -->
+  <extend-property name="locale" values="en,es,fr" />
+  <set-property-fallback name="locale" value="en"/>
+
+  <set-property name="locale" value="en,es,fr"/>
+
   <!-- Hardcoded locale (to override emite italian support) ===== -->
   <!--   <set-property name="locale" value="en" /> -->
   <!-- Hardcoded log level ====================================== -->

Modified: trunk/src/main/java/cc/kune/core/client/auth/SignInAbstractPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/auth/SignInAbstractPresenter.java	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/src/main/java/cc/kune/core/client/auth/SignInAbstractPresenter.java	2011-12-05 20:42:43 UTC (rev 1633)
@@ -21,6 +21,7 @@
 
 import cc.kune.core.client.cookies.CookiesManager;
 import cc.kune.core.client.i18n.I18nUITranslationService;
+import cc.kune.core.client.i18n.I18nUITranslationService.I18nLanguageChangeNeeded;
 import cc.kune.core.client.state.Session;
 import cc.kune.core.client.state.StateManager;
 import cc.kune.core.shared.domain.utils.StateToken;
@@ -93,13 +94,22 @@
     session.setCurrentUserInfo(userInfoDTO);
     final I18nLanguageDTO language = userInfoDTO.getLanguage();
     session.setCurrentLanguage(language);
-    if (!i18n.changeToLanguageIfNecessary(language.getCode())) {
-      if (gotoHomePage) {
-        stateManager.gotoStateToken(new StateToken(userInfoDTO.getHomePage()).clearDocument());
-      } else {
-        stateManager.redirectOrRestorePreviousToken();
-      }
-    }
+    i18n.changeToLanguageIfNecessary(language.getCode(), language.getEnglishName(),
+        new I18nLanguageChangeNeeded() {
+
+          @Override
+          public void onChangeNeeded() {
+          }
+
+          @Override
+          public void onChangeNotNeeded() {
+            if (gotoHomePage) {
+              stateManager.gotoStateToken(new StateToken(userInfoDTO.getHomePage()).clearDocument());
+            } else {
+              stateManager.redirectOrRestorePreviousToken();
+            }
+          }
+        });
   }
 
   protected void saveAutocompleteLoginData(final String nickOrEmail, final String password) {

Modified: trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java	2011-12-05 20:42:43 UTC (rev 1633)
@@ -84,7 +84,7 @@
       final String msg = caught.getMessage();
       eventBus.fireEvent(new UserNotifyEvent(NotifyLevel.error,
           i18n.t("You do not have rights to perform that action")
-              + (TextUtils.empty(msg) ? "" : ". " + i18n.t(msg))));
+              + (!TextUtils.empty(msg) && msg.length() > 1 ? ". " + i18n.t(msg) : "")));
       goHome();
     } else if (caught instanceof SessionExpiredException) {
       logException(caught);

Modified: trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java	2011-12-05 20:42:43 UTC (rev 1633)
@@ -27,9 +27,11 @@
 import java.util.Set;
 
 import cc.kune.common.client.log.Log;
+import cc.kune.common.client.notify.NotifyUser;
 import cc.kune.common.client.utils.Location;
 import cc.kune.common.client.utils.MetaUtils;
 import cc.kune.common.client.utils.Pair;
+import cc.kune.common.client.utils.SimpleResponseCallback;
 import cc.kune.common.client.utils.TextUtils;
 import cc.kune.common.client.utils.WindowUtils;
 import cc.kune.core.client.rpcservices.I18nServiceAsync;
@@ -48,6 +50,11 @@
 import com.google.inject.Inject;
 
 public class I18nUITranslationService extends I18nTranslationService {
+  public interface I18nLanguageChangeNeeded {
+    void onChangeNeeded();
+
+    void onChangeNotNeeded();
+  }
   private I18nLanguageDTO currentLang;
   private String currentLanguageCode;
   private final Set<Pair<String, String>> earlyTexts;
@@ -57,6 +64,7 @@
   private final KuneConstants kuneConstants;
   private HashMap<String, String> lexicon;
   private final Session session;
+
   private String siteCommonName;
 
   @Inject
@@ -101,11 +109,20 @@
                 + ", isRTL: " + currentLang.getDirection() + " use properties: "
                 + shouldIuseProperties());
 
-            if (!changeToLanguageIfNecessary(getCurrentGWTlanguage(), currentLang.getCode())) {
-              isCurrentLangRTL = currentLang.getDirection().equals(RTL);
-              eventBus.fireEvent(new I18nReadyEvent());
-            }
-            I18nStyles.setRTL(isCurrentLangRTL);
+            changeToLanguageIfNecessary(getCurrentGWTlanguage(), currentLang.getCode(),
+                currentLang.getEnglishName(), new I18nLanguageChangeNeeded() {
+
+                  @Override
+                  public void onChangeNeeded() {
+                  }
+
+                  @Override
+                  public void onChangeNotNeeded() {
+                    isCurrentLangRTL = currentLang.getDirection().equals(RTL);
+                    eventBus.fireEvent(new I18nReadyEvent());
+                    I18nStyles.setRTL(isCurrentLangRTL);
+                  }
+                });
           }
         });
         session.onUserSignIn(true, new UserSignInHandler() {
@@ -162,8 +179,9 @@
     changeHref("http://" + WindowUtils.getLocation().getHost() + newUrl);
   }
 
-  public boolean changeToLanguageIfNecessary(final String wantedLang) {
-    return changeToLanguageIfNecessary(currentLang.getCode(), wantedLang);
+  public void changeToLanguageIfNecessary(final String wantedLang, final String wantedLangEnglishName,
+      final I18nLanguageChangeNeeded listener) {
+    changeToLanguageIfNecessary(currentLang.getCode(), wantedLang, wantedLangEnglishName, listener);
   }
 
   /**
@@ -172,13 +190,29 @@
    *          to check and to change to
    * @return true if we should reload the client with the new language
    */
-  public boolean changeToLanguageIfNecessary(final String currentLang, final String wantedLang) {
-    if (!currentLang.equals(wantedLang) && isInConstantProperties(wantedLang)) {
-      setCurrentLanguage(wantedLang);
-      changeLanguageInUrl(wantedLang);
-      return true;
+  private void changeToLanguageIfNecessary(final String currentLangCode, final String wantedLang,
+      final String wantedLangEnglishName, final I18nLanguageChangeNeeded listener) {
+    if (!currentLangCode.equals(wantedLang) && isInConstantProperties(wantedLang)) {
+      NotifyUser.askConfirmation(t("Confirm please"),
+          t("Do you want to reload this page to use '[%s]' language?", wantedLangEnglishName),
+          new SimpleResponseCallback() {
+            @Override
+            public void onCancel() {
+              // User no accepted to change the language...
+              listener.onChangeNotNeeded();
+            }
+
+            @Override
+            public void onSuccess() {
+              // User accepted to change the language...
+              listener.onChangeNeeded();
+              setCurrentLanguage(wantedLang);
+              changeLanguageInUrl(wantedLang);
+            }
+          });
+    } else {
+      listener.onChangeNotNeeded();
     }
-    return false;
   }
 
   public String formatDateWithLocale(final Date date) {

Modified: trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java	2011-12-05 20:42:43 UTC (rev 1633)
@@ -66,11 +66,13 @@
   }
 
   private void checkNavigatorCompatibility(final NavigatorSupport navSupport) {
-    if (Navigator.getUserAgent().toLowerCase().contains("msie")
-        || Navigator.getUserAgent().toLowerCase().contains("opera")) {
+    // http://www.useragentstring.com/pages/useragentstring.php
+    final String userAgent = Navigator.getUserAgent().toLowerCase();
+    Log.info("User agent: " + userAgent);
+    if (userAgent.contains("chrome") || userAgent.contains("gecko")) {
+      navSupport.onSupported();
+    } else {
       navSupport.onNotSupported();
-    } else {
-      navSupport.onSupported();
     }
   }
 

Modified: trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java	2011-12-05 20:42:43 UTC (rev 1633)
@@ -145,7 +145,13 @@
     view.getGroupBtn().addClickHandler(new ClickHandler() {
       @Override
       public void onClick(final ClickEvent event) {
-        restoreToken(groupToken);
+        if (groupToken.equals(SiteTokens.GROUP_HOME)) {
+          // as current home is equal to "no content" token, we shall go to
+          // group space def home page
+          stateManager.gotoDefaultHomepage();
+        } else {
+          restoreToken(groupToken);
+        }
         setDown(Space.groupSpace);
       }
     });

Modified: trunk/src/main/java/cc/kune/gspace/client/actions/ParticipateInContentBtn.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/ParticipateInContentBtn.java	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/ParticipateInContentBtn.java	2011-12-05 20:42:43 UTC (rev 1633)
@@ -76,7 +76,7 @@
       final IsCurrentStateEditableCondition isEditable,
       final IsNotParticipantOfCurrentStateCondition isNotParticipant, final CoreResources res) {
     super(action);
-    this.withText(i18n.t("Edit")).withToolTip("Participate in the edition of this page").withIcon(
+    this.withText(i18n.t("Participate")).withToolTip("Participate in the edition of this page").withIcon(
         res.contentEdit()).withStyles("k-def-docbtn, k-fl");
     super.add(isLogged);
     super.add(isEditable);

Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralPresenter.java	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralPresenter.java	2011-12-05 20:42:43 UTC (rev 1633)
@@ -19,9 +19,9 @@
  */
 package cc.kune.gspace.client.options.general;
 
+import cc.kune.core.client.i18n.I18nUITranslationService;
 import cc.kune.core.client.state.Session;
 import cc.kune.core.client.state.StateManager;
-import cc.kune.core.shared.i18n.I18nTranslationService;
 import cc.kune.gspace.client.options.EntityOptions;
 import cc.kune.gspace.client.options.logo.CurrentEntityChangedEvent;
 
@@ -34,13 +34,13 @@
 
   protected final EntityOptions entityOptions;
   private final EventBus eventBus;
-  protected final I18nTranslationService i18n;
+  protected final I18nUITranslationService i18n;
   protected final Session session;
   protected final StateManager stateManager;
   protected EntityOptGeneralView view;
 
   public EntityOptGeneralPresenter(final Session session, final StateManager stateManager,
-      final EventBus eventBus, final I18nTranslationService i18n, final EntityOptions entityOptions) {
+      final EventBus eventBus, final I18nUITranslationService i18n, final EntityOptions entityOptions) {
     this.session = session;
     this.stateManager = stateManager;
     this.eventBus = eventBus;

Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/GroupOptGeneralPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/GroupOptGeneralPresenter.java	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/GroupOptGeneralPresenter.java	2011-12-05 20:42:43 UTC (rev 1633)
@@ -20,6 +20,7 @@
 package cc.kune.gspace.client.options.general;
 
 import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.core.client.i18n.I18nUITranslationService;
 import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
 import cc.kune.core.client.rpcservices.GroupServiceAsync;
 import cc.kune.core.client.state.GroupChangedEvent;
@@ -29,7 +30,6 @@
 import cc.kune.core.shared.domain.utils.StateToken;
 import cc.kune.core.shared.dto.GroupDTO;
 import cc.kune.core.shared.dto.StateAbstractDTO;
-import cc.kune.core.shared.i18n.I18nTranslationService;
 import cc.kune.gspace.client.options.GroupOptions;
 
 import com.google.gwt.event.shared.EventBus;
@@ -43,7 +43,7 @@
 
   @Inject
   public GroupOptGeneralPresenter(final StateManager stateManager, final Session session,
-      final EventBus eventBus, final I18nTranslationService i18n, final GroupOptions entityOptions,
+      final EventBus eventBus, final I18nUITranslationService i18n, final GroupOptions entityOptions,
       final Provider<GroupServiceAsync> groupService, final GroupOptGeneralView view) {
     super(session, stateManager, eventBus, i18n, entityOptions);
     this.groupService = groupService;

Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java	2011-11-30 01:31:04 UTC (rev 1632)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java	2011-12-05 20:42:43 UTC (rev 1633)
@@ -20,6 +20,8 @@
 package cc.kune.gspace.client.options.general;
 
 import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.core.client.i18n.I18nUITranslationService;
+import cc.kune.core.client.i18n.I18nUITranslationService.I18nLanguageChangeNeeded;
 import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
 import cc.kune.core.client.rpcservices.UserServiceAsync;
 import cc.kune.core.client.state.Session;
@@ -30,7 +32,6 @@
 import cc.kune.core.shared.dto.StateAbstractDTO;
 import cc.kune.core.shared.dto.UserDTO;
 import cc.kune.core.shared.dto.UserSimpleDTO;
-import cc.kune.core.shared.i18n.I18nTranslationService;
 import cc.kune.gspace.client.options.UserOptions;
 
 import com.google.gwt.event.shared.EventBus;
@@ -44,7 +45,7 @@
 
   @Inject
   public UserOptGeneralPresenter(final Session session, final StateManager stateManager,
-      final EventBus eventBus, final I18nTranslationService i18n, final UserOptions entityOptions,
+      final EventBus eventBus, final I18nUITranslationService i18n, final UserOptions entityOptions,
       final Provider<UserServiceAsync> userService, final UserOptGeneralView view) {
     super(session, stateManager, eventBus, i18n, entityOptions);
     this.userService = userService;
@@ -84,13 +85,25 @@
       user.setId(currentUser.getId());
       final String longName = userView.getLongName();
       user.setName(longName);
+      final I18nLanguageSimpleDTO lang = userView.getLanguage();
       userService.get().updateUser(session.getUserHash(), user, userView.getLanguage(),
           new AsyncCallbackSimple<StateAbstractDTO>() {
             @Override
             public void onSuccess(final StateAbstractDTO result) {
               NotifyUser.hideProgress();
-              stateManager.setRetrievedStateAndGo(result);
-              sendChangeEntityEvent();
+              // Change language to new one if needed
+              i18n.changeToLanguageIfNecessary(lang.getCode(), lang.getEnglishName(),
+                  new I18nLanguageChangeNeeded() {
+                    @Override
+                    public void onChangeNeeded() {
+                    }
+
+                    @Override
+                    public void onChangeNotNeeded() {
+                      stateManager.setRetrievedStateAndGo(result);
+                      sendChangeEntityEvent();
+                    }
+                  });
             };
           }
 




More information about the kune-commits mailing list