[kune-commits] r1301 - in trunk: . script src/main/java/cc/kune src/main/java/cc/kune/chat src/main/java/cc/kune/chat/client/actions src/main/java/cc/kune/client src/main/java/cc/kune/common/client/utils src/main/java/cc/kune/common/public src/main/java/cc/kune/common/public/images src/main/java/cc/kune/core/client src/main/java/cc/kune/core/client/auth src/main/java/cc/kune/core/client/errors src/main/java/cc/kune/core/client/groups/newgroup src/main/java/cc/kune/core/client/sitebar src/main/java/cc/kune/core/client/sitebar/logo src/main/java/cc/kune/core/client/sitebar/spaces src/main/java/cc/kune/core/client/state src/main/java/cc/kune/core/public src/main/java/cc/kune/wave/client src/main/java/org/ourproject/kune/workspace/client src/main/java/org/ourproject/kune/workspace/client/sitebar/sitesign src/test/java/cc/kune/core/client/state
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Sat Apr 2 00:07:26 CEST 2011
Author: vjrj_
Date: 2011-04-02 00:07:25 +0200 (Sat, 02 Apr 2011)
New Revision: 1301
Added:
trunk/src/main/java/cc/kune/chat/KuneChat.gwt.xml
trunk/src/main/java/cc/kune/common/client/utils/Pair.java
trunk/src/main/java/cc/kune/common/public/images/
trunk/src/main/java/cc/kune/common/public/images/hborder.png
trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceConfEvent.java
trunk/src/main/java/cc/kune/core/client/state/ReservedWordsRegistry.java
trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java
trunk/src/main/java/cc/kune/core/client/state/TokenMatcher.java
trunk/src/main/java/cc/kune/core/client/state/TokenUtils.java
trunk/src/test/java/cc/kune/core/client/state/TokenMatcherTest.java
Removed:
trunk/src/main/java/cc/kune/chat/Chat.gwt.xml
trunk/src/main/java/cc/kune/common/public/img/
trunk/src/main/java/cc/kune/core/client/state/SiteCommonTokens.java
Modified:
trunk/.classpath
trunk/pom.xml
trunk/script/mvn-eclipse.sh
trunk/src/main/java/cc/kune/Kune.gwt.xml
trunk/src/main/java/cc/kune/chat/client/actions/AddAsBuddieHeaderButton.java
trunk/src/main/java/cc/kune/client/KuneGinjector.java
trunk/src/main/java/cc/kune/common/public/kune-common.css
trunk/src/main/java/cc/kune/core/client/CoreGinModule.java
trunk/src/main/java/cc/kune/core/client/auth/SignInPresenter.java
trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java
trunk/src/main/java/cc/kune/core/client/groups/newgroup/NewGroupPresenter.java
trunk/src/main/java/cc/kune/core/client/sitebar/SitebarNewGroupLink.java
trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java
trunk/src/main/java/cc/kune/core/client/sitebar/logo/SiteLogoPresenter.java
trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java
trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorViewImpl.java
trunk/src/main/java/cc/kune/core/client/state/HistoryWrapper.java
trunk/src/main/java/cc/kune/core/client/state/HistoryWrapperDefault.java
trunk/src/main/java/cc/kune/core/client/state/SiteTokenListeners.java
trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java
trunk/src/main/java/cc/kune/core/public/ws.css
trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java
trunk/src/main/java/cc/kune/wave/client/WebClient.java
trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitesign/SiteSignInLinkPanel.java
trunk/src/test/java/cc/kune/core/client/state/StateManagerTest.java
Log:
NEW - # 35: Spaces selector integration with login/logout and history
http://kune.ourproject.org/issues/ticket/35
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/.classpath 2011-04-01 22:07:25 UTC (rev 1301)
@@ -49,7 +49,7 @@
<classpathentry kind="var" path="M2_REPO/com/google/gwt/gwt-servlet/2.1.1/gwt-servlet-2.1.1.jar" sourcepath="M2_REPO/com/google/gwt/gwt-servlet/2.1.1/gwt-servlet-2.1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/com/google/gwt/gwt-user/2.1.1/gwt-user-2.1.1.jar" sourcepath="M2_REPO/com/google/gwt/gwt-user/2.1.1/gwt-user-2.1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/waveprotocol/gwt-util-src/0.3.0-SNAPSHOT/gwt-util-src-0.3.0-SNAPSHOT.jar"/>
- <classpathentry kind="var" path="M2_REPO/com/allen_sauer/gwt/voices/gwt-voices/gwt-voices/1.6.0/gwt-voices-1.6.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/com/allen_sauer/gwt/voices/gwt-voices/gwt-voices/1.7.0/gwt-voices-1.7.0.jar"/>
<classpathentry kind="var" path="M2_REPO/com/gwtext/gwtext/2.0.5/gwtext-2.0.5.jar"/>
<classpathentry kind="var" path="M2_REPO/com/gwtextux/gwtextux/0.4.0.924/gwtextux-0.4.0.924.jar"/>
<classpathentry kind="var" path="M2_REPO/com/gwtplatform/gwtp-all/0.5/gwtp-all-0.5.jar" sourcepath="M2_REPO/com/gwtplatform/gwtp-all/0.5/gwtp-all-0.5-sources.jar"/>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/pom.xml 2011-04-01 22:07:25 UTC (rev 1301)
@@ -284,7 +284,7 @@
<dependency>
<groupId>com.allen_sauer.gwt.voices.gwt-voices</groupId>
<artifactId>gwt-voices</artifactId>
- <version>1.6.0</version>
+ <version>1.7.0</version>
</dependency>
<!-- utilities -->
<dependency>
@@ -1069,8 +1069,6 @@
</execution>
</executions>
</plugin>
-
-
<!-- <plugin> -->
<!-- <groupId>org.codehaus.mojo</groupId> -->
<!-- <artifactId>selenium-maven-plugin</artifactId> -->
Modified: trunk/script/mvn-eclipse.sh
===================================================================
--- trunk/script/mvn-eclipse.sh 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/script/mvn-eclipse.sh 2011-04-01 22:07:25 UTC (rev 1301)
@@ -1,7 +1,16 @@
mvn eclipse:eclipse -Dgwt.compiler.skip=true
-
+RESULT=$?
perl -p -i -e 's/<\/classpath>//g' .classpath
perl -p -i -e 's/\/home\/vjrj\/nfsdev\///g' .classpath
#echo -en " <classpathentry kind=\"src\" path=\"target/generated-sources/apt\" including=\"**/*.java\"/>" >> .classpath
echo -en " <classpathentry kind=\"con\" path=\"com.google.gwt.eclipse.core.GWT_CONTAINER\"/>\n</classpath>" >> .classpath
-
+which kdialog > /dev/null 2>&1
+if [[ $? == 0 ]]
+then
+ if [[ $RESULT == 0 ]]
+ then
+ kdialog --msgbox "mvn finished successfully" 2>/dev/null &
+ else
+ kdialog --error "mvn finished with errors" 2>/dev/null &
+ fi
+fi
Modified: trunk/src/main/java/cc/kune/Kune.gwt.xml
===================================================================
--- trunk/src/main/java/cc/kune/Kune.gwt.xml 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/Kune.gwt.xml 2011-04-01 22:07:25 UTC (rev 1301)
@@ -5,7 +5,7 @@
<inherits name='com.google.gwt.logging.Logging' />
<inherits name="cc.kune.core.Core" />
<inherits name="cc.kune.wave.KuneWave" />
- <inherits name="cc.kune.chat.Chat" />
+ <inherits name="cc.kune.chat.KuneChat" />
<inherits name="cc.kune.docs.KuneDocs" />
<inherits name="cc.kune.pspace.PSpace" />
<inherits name="com.calclab.suco.Suco" />
Deleted: trunk/src/main/java/cc/kune/chat/Chat.gwt.xml
===================================================================
--- trunk/src/main/java/cc/kune/chat/Chat.gwt.xml 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/chat/Chat.gwt.xml 2011-04-01 22:07:25 UTC (rev 1301)
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.1.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.1.1/distro-source/core/src/gwt-module.dtd">
-<module>
- <inherits name="com.google.gwt.user.User" />
- <inherits name="com.calclab.hablar.Hablar" />
- <inherits name='com.calclab.hablar.console.HablarConsole' />
- <inherits name='com.calclab.hablar.login.HablarLogin' />
- <inherits name='com.calclab.hablar.icons.def.HablarDefaultIcons' />
- <inherits name='com.calclab.hablar.icons.ie6gif.HablarIE6GifIcons' />
- <inherits name='com.calclab.hablar.icons.alt.HablarAltIcons' />
- <source path="client" />
- <set-property name="user.agent" value="safari,gecko1_8" />
- <public path="public" />
-</module>
\ No newline at end of file
Copied: trunk/src/main/java/cc/kune/chat/KuneChat.gwt.xml (from rev 1299, trunk/src/main/java/cc/kune/chat/Chat.gwt.xml)
===================================================================
--- trunk/src/main/java/cc/kune/chat/KuneChat.gwt.xml (rev 0)
+++ trunk/src/main/java/cc/kune/chat/KuneChat.gwt.xml 2011-04-01 22:07:25 UTC (rev 1301)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.1.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.1.1/distro-source/core/src/gwt-module.dtd">
+<module>
+ <inherits name="com.google.gwt.user.User" />
+ <inherits name="com.calclab.hablar.Hablar" />
+ <inherits name='com.calclab.hablar.console.HablarConsole' />
+ <inherits name='com.calclab.hablar.login.HablarLogin' />
+ <inherits name='com.calclab.hablar.icons.def.HablarDefaultIcons' />
+ <inherits name='com.calclab.hablar.icons.ie6gif.HablarIE6GifIcons' />
+ <inherits name='com.calclab.hablar.icons.alt.HablarAltIcons' />
+ <source path="client" />
+ <public path="public" />
+</module>
\ No newline at end of file
Modified: trunk/src/main/java/cc/kune/chat/client/actions/AddAsBuddieHeaderButton.java
===================================================================
--- trunk/src/main/java/cc/kune/chat/client/actions/AddAsBuddieHeaderButton.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/chat/client/actions/AddAsBuddieHeaderButton.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -65,7 +65,10 @@
@Override
public void onGroupChanged(final RosterGroupChangedEvent event) {
- setState(session.getCurrentState());
+ final StateAbstractDTO currentState = session.getCurrentState();
+ if (currentState != null) {
+ setState(currentState);
+ }
}
});
putValue(Action.NAME, i18n.t("Add as a buddie"));
Modified: trunk/src/main/java/cc/kune/client/KuneGinjector.java
===================================================================
--- trunk/src/main/java/cc/kune/client/KuneGinjector.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/client/KuneGinjector.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -44,6 +44,7 @@
import cc.kune.core.client.sn.UserSNPresenter;
import cc.kune.core.client.state.SiteTokenListeners;
import cc.kune.core.client.state.StateManager;
+import cc.kune.core.client.state.TokenMatcher;
import cc.kune.core.client.ws.CorePresenter;
import cc.kune.core.client.ws.entheader.EntityHeaderPresenter;
import cc.kune.core.shared.i18n.I18nTranslationService;
@@ -135,6 +136,8 @@
AsyncProvider<TagsSummaryPresenter> getTagsSummaryPresenter();
+ TokenMatcher getTokenMatcher();
+
AsyncProvider<ToolSelectorPresenter> getToolSelectorPresenter();
AsyncProvider<UserConfirmPresenter> getUserConfirmPresenter();
Added: trunk/src/main/java/cc/kune/common/client/utils/Pair.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/utils/Pair.java (rev 0)
+++ trunk/src/main/java/cc/kune/common/client/utils/Pair.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package cc.kune.common.client.utils;
+
+/**
+ * @param <L>
+ * @param <R>
+ */
+public class Pair<L, R> {
+ public static <L, R> Pair<L, R> create(final L l, final R r) {
+ return new Pair<L, R>(l, r);
+ }
+
+ public final L left;
+ public final R right;
+
+ private Pair(final L left, final R right) {
+ this.left = left;
+ this.right = right;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Pair other = (Pair) obj;
+ if (left == null) {
+ if (other.left != null) {
+ return false;
+ }
+ } else if (!left.equals(other.left)) {
+ return false;
+ }
+ if (right == null) {
+ if (other.right != null) {
+ return false;
+ }
+ } else if (!right.equals(other.right)) {
+ return false;
+ }
+ return true;
+ }
+
+ public L getLeft() {
+ return left;
+ }
+
+ public R getRight() {
+ return right;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((left == null) ? 0 : left.hashCode());
+ result = prime * result + ((right == null) ? 0 : right.hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + left + "," + right + ")";
+ }
+}
Property changes on: trunk/src/main/java/cc/kune/common/client/utils/Pair.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/src/main/java/cc/kune/common/public/images (from rev 1299, trunk/src/main/java/cc/kune/common/public/img)
Added: trunk/src/main/java/cc/kune/common/public/images/hborder.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/cc/kune/common/public/images/hborder.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/java/cc/kune/common/public/kune-common.css
===================================================================
--- trunk/src/main/java/cc/kune/common/public/kune-common.css 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/common/public/kune-common.css 2011-04-01 22:07:25 UTC (rev 1301)
@@ -205,7 +205,7 @@
}
.oc-testico {
- background-image: url(/common/img/ico.png) !important;
+ background-image: url(images/ico.png) !important;
-moz-background-clip: border;
-moz-background-inline-policy: continuous;
-moz-background-origin: padding;
@@ -364,7 +364,7 @@
}
.oc-testico {
- background-image: url(/common/img/ico.png) !important;
+ background-image: url(images/ico.png) !important;
-moz-background-clip: border;
-moz-background-inline-policy: continuous;
-moz-background-origin: padding;
@@ -464,4 +464,9 @@
.gwt-MenuBar-vertical .subMenuIcon-selected {
background: none repeat scroll 0 0 #808080;
+}
+
+.gwt-Button {
+ background: url("images/hborder.png") repeat-x scroll 0 -27px
+ transparent;
}
\ No newline at end of file
Modified: trunk/src/main/java/cc/kune/core/client/CoreGinModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreGinModule.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/CoreGinModule.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -85,11 +85,14 @@
import cc.kune.core.client.state.ContentCacheDefault;
import cc.kune.core.client.state.HistoryWrapper;
import cc.kune.core.client.state.HistoryWrapperDefault;
+import cc.kune.core.client.state.ReservedWordsRegistry;
import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.SessionDefault;
import cc.kune.core.client.state.SiteTokenListeners;
+import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
import cc.kune.core.client.state.StateManagerDefault;
+import cc.kune.core.client.state.TokenMatcher;
import cc.kune.core.client.ws.CorePresenter;
import cc.kune.core.client.ws.CoreViewImpl;
import cc.kune.core.client.ws.entheader.EntityHeader;
@@ -130,7 +133,7 @@
bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class);
bind(RootPresenter.class).asEagerSingleton();
bind(ProxyFailureHandler.class).to(DefaultProxyFailureHandler.class).in(Singleton.class);
- bind(I18nUITranslationService.class).in(Singleton.class);
+ s(I18nUITranslationService.class);
bind(I18nTranslationService.class).to(I18nUITranslationService.class).in(Singleton.class);
bind(GlobalShortcutRegister.class).to(DefaultGlobalShortcutRegister.class).in(Singleton.class);
@@ -175,48 +178,63 @@
bind(NewGroup.class).to(NewGroupPresenter.class).in(Singleton.class);
bind(EntityHeader.class).to(EntityHeaderPresenter.class).in(Singleton.class);
- bind(UserMessagesPresenter.class).in(Singleton.class);
- bind(UserMessagesPanel.class).in(Singleton.class);
+ s(UserMessagesPresenter.class);
+ s(UserMessagesPanel.class);
// bind(MessagePanelView.class).to(MessagePanel.class);
// UI
- bind(WsArmorImpl.class).in(Singleton.class);
+ s(WsArmorImpl.class);
bind(WsArmor.class).to(WsArmorImpl.class).in(Singleton.class);
bind(GuiProvider.class).to(DefaultGuiProvider.class).in(Singleton.class);
- bind(GxtGuiProvider.class).in(Singleton.class);
- bind(GwtGuiProvider.class).in(Singleton.class);
+ s(GxtGuiProvider.class);
+ s(GwtGuiProvider.class);
bind(MaskWidgetView.class).to(MaskWidget.class).in(Singleton.class);
// Core App
bind(Session.class).to(SessionDefault.class).in(Singleton.class);
- bind(ErrorHandler.class).in(Singleton.class);
- bind(StateManagerDefault.class).in(Singleton.class);
+ s(ErrorHandler.class);
+ s(StateManagerDefault.class);
bind(StateManager.class).to(StateManagerDefault.class).in(Singleton.class);
- bind(AccessRightsClientManager.class).in(Singleton.class);
+ s(AccessRightsClientManager.class);
bind(ContentCache.class).to(ContentCacheDefault.class).in(Singleton.class);
bind(HistoryWrapper.class).to(HistoryWrapperDefault.class).in(Singleton.class);
- bind(PrefetchUtilities.class).in(Singleton.class);
+ s(PrefetchUtilities.class);
bind(AppStarter.class).to(AppStarterDefault.class).in(Singleton.class);
bind(CookiesManager.class).to(CookiesManagerImpl.class).in(Singleton.class);
- bind(BeforeSignOut.class).in(Singleton.class);
- bind(SiteTokenListeners.class).asEagerSingleton();
- bind(ActionRegistries.class).in(Singleton.class);
- bind(CoreParts.class).asEagerSingleton();
+ s(BeforeSignOut.class);
+ eagle(SiteTokenListeners.class);
+ s(SiteTokens.class);
+ s(ReservedWordsRegistry.class);
+ eagle(TokenMatcher.class);
+ s(ActionRegistries.class);
+ eagle(CoreParts.class);
// SN
- bind(GroupSNAdminsMenuItemsRegistry.class).in(Singleton.class);
- bind(GroupSNCollabsMenuItemsRegistry.class).in(Singleton.class);
- bind(GroupSNPendingsMenuItemsRegistry.class).in(Singleton.class);
- bind(UserSNMenuItemsRegistry.class).in(Singleton.class);
- bind(GroupSNConfActions.class).in(Singleton.class);
- bind(UserSNConfActions.class).in(Singleton.class);
+ s(GroupSNAdminsMenuItemsRegistry.class);
+ s(GroupSNCollabsMenuItemsRegistry.class);
+ s(GroupSNPendingsMenuItemsRegistry.class);
+ s(UserSNMenuItemsRegistry.class);
+ s(GroupSNConfActions.class);
+ s(UserSNConfActions.class);
- bind(SiteUserOptionsPresenter.class).in(Singleton.class);
- bind(SiteUserOptions.class).to(SiteUserOptionsPresenter.class).in(Singleton.class);
- bind(SitebarNewGroupLink.class).in(Singleton.class);
- bind(SitebarSignInLink.class).in(Singleton.class);
- bind(SitebarSignOutLink.class).in(Singleton.class);
+ s(SiteUserOptionsPresenter.class);
+ s(SiteUserOptions.class, SiteUserOptionsPresenter.class);
+ s(SitebarNewGroupLink.class);
+ s(SitebarSignInLink.class);
+ s(SitebarSignOutLink.class);
}
+
+ private void eagle(final Class<?> type) {
+ bind(type).asEagerSingleton();
+ }
+
+ private void s(final Class<?> type) {
+ bind(type).in(Singleton.class);
+ }
+
+ private <V, W> void s(final Class<V> type, final Class<? extends V> typeImpl) {
+ bind(type).to(typeImpl).in(Singleton.class);
+ }
}
Modified: trunk/src/main/java/cc/kune/core/client/auth/SignInPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/auth/SignInPresenter.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/auth/SignInPresenter.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -32,7 +32,7 @@
import cc.kune.core.client.resources.CoreMessages;
import cc.kune.core.client.rpcservices.UserServiceAsync;
import cc.kune.core.client.state.Session;
-import cc.kune.core.client.state.SiteCommonTokens;
+import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
import cc.kune.core.shared.dto.UserDTO;
import cc.kune.core.shared.dto.UserInfoDTO;
@@ -119,7 +119,7 @@
getView().reset();
getView().hideMessages();
getView().hide();
- stateManager.gotoToken(SiteCommonTokens.REGISTER);
+ stateManager.gotoToken(SiteTokens.REGISTER);
}
@Override
Modified: trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -25,7 +25,7 @@
import cc.kune.core.client.notify.msgs.UserNotifyEvent;
import cc.kune.core.client.notify.spiner.ProgressHideEvent;
import cc.kune.core.client.state.Session;
-import cc.kune.core.client.state.SiteCommonTokens;
+import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
import cc.kune.core.shared.i18n.I18nTranslationService;
@@ -55,7 +55,7 @@
}
private void goHome() {
- stateManager.gotoToken(SiteCommonTokens.GROUP_HOME);
+ stateManager.gotoToken(SiteTokens.GROUP_HOME);
}
private void logException(final Throwable caught) {
Modified: trunk/src/main/java/cc/kune/core/client/groups/newgroup/NewGroupPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/groups/newgroup/NewGroupPresenter.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/groups/newgroup/NewGroupPresenter.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -30,7 +30,7 @@
import cc.kune.core.client.rpcservices.GroupServiceAsync;
import cc.kune.core.client.state.HistoryTokenCallback;
import cc.kune.core.client.state.Session;
-import cc.kune.core.client.state.SiteCommonTokens;
+import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
import cc.kune.core.shared.domain.utils.StateToken;
import cc.kune.core.shared.dto.GroupDTO;
@@ -77,7 +77,7 @@
this.groupService = groupService;
this.signIn = signIn;
- stateManager.addSiteToken(SiteCommonTokens.NEWGROUP, new HistoryTokenCallback() {
+ stateManager.addSiteToken(SiteTokens.NEWGROUP, new HistoryTokenCallback() {
@Override
public void onHistoryToken() {
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/SitebarNewGroupLink.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/SitebarNewGroupLink.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/SitebarNewGroupLink.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -24,7 +24,7 @@
import cc.kune.common.client.actions.ActionEvent;
import cc.kune.common.client.actions.ui.descrip.ButtonDescriptor;
import cc.kune.core.client.state.StateManager;
-import cc.kune.core.client.state.SiteCommonTokens;
+import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.shared.i18n.I18nTranslationService;
import com.google.inject.Inject;
@@ -44,7 +44,7 @@
@Override
public void actionPerformed(final ActionEvent event) {
- stateManager.gotoToken(SiteCommonTokens.NEWGROUP);
+ stateManager.gotoToken(SiteTokens.NEWGROUP);
}
}
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -24,7 +24,7 @@
import cc.kune.common.client.actions.ActionEvent;
import cc.kune.common.client.actions.ui.descrip.ButtonDescriptor;
import cc.kune.core.client.state.Session;
-import cc.kune.core.client.state.SiteCommonTokens;
+import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
import cc.kune.core.client.state.UserSignInEvent;
import cc.kune.core.client.state.UserSignInEvent.UserSignInHandler;
@@ -51,7 +51,7 @@
@Override
public void actionPerformed(final ActionEvent event) {
- stateManager.gotoToken(SiteCommonTokens.SIGNIN);
+ stateManager.gotoToken(SiteTokens.SIGNIN);
}
}
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/logo/SiteLogoPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/logo/SiteLogoPresenter.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/logo/SiteLogoPresenter.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -20,7 +20,7 @@
package cc.kune.core.client.sitebar.logo;
import cc.kune.core.client.init.AppStartEvent;
-import cc.kune.core.client.state.SiteCommonTokens;
+import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
import com.google.gwt.event.shared.EventBus;
@@ -61,7 +61,7 @@
@Override
public void onClick() {
- stateManager.gotoToken(SiteCommonTokens.GROUP_HOME);
+ stateManager.gotoToken(SiteTokens.GROUP_HOME);
}
@Override
Added: trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceConfEvent.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceConfEvent.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceConfEvent.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -0,0 +1,99 @@
+package cc.kune.core.client.sitebar.spaces;
+
+import com.google.gwt.event.shared.EventHandler;
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.HasHandlers;
+
+public class SpaceConfEvent extends GwtEvent<SpaceConfEvent.SpaceConfHandler> {
+
+ public interface HasSpaceConfHandlers extends HasHandlers {
+ HandlerRegistration addSpaceConfHandler(SpaceConfHandler handler);
+ }
+
+ public interface SpaceConfHandler extends EventHandler {
+ public void onSpaceConf(SpaceConfEvent event);
+ }
+
+ private static final Type<SpaceConfHandler> TYPE = new Type<SpaceConfHandler>();
+
+ public static void fire(final HasHandlers source, final cc.kune.core.client.sitebar.spaces.Space space,
+ final String token) {
+ source.fireEvent(new SpaceConfEvent(space, token));
+ }
+
+ public static Type<SpaceConfHandler> getType() {
+ return TYPE;
+ }
+
+ private cc.kune.core.client.sitebar.spaces.Space space;
+ private String token;
+
+ protected SpaceConfEvent() {
+ // Possibly for serialization.
+ }
+
+ public SpaceConfEvent(final cc.kune.core.client.sitebar.spaces.Space space, final String token) {
+ this.space = space;
+ this.token = token;
+ }
+
+ @Override
+ protected void dispatch(final SpaceConfHandler handler) {
+ handler.onSpaceConf(this);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final SpaceConfEvent other = (SpaceConfEvent) obj;
+ if (space == null) {
+ if (other.space != null) {
+ return false;
+ }
+ } else if (!space.equals(other.space)) {
+ return false;
+ }
+ if (token == null) {
+ if (other.token != null) {
+ return false;
+ }
+ } else if (!token.equals(other.token)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public Type<SpaceConfHandler> getAssociatedType() {
+ return TYPE;
+ }
+
+ public cc.kune.core.client.sitebar.spaces.Space getSpace() {
+ return space;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ @Override
+ public int hashCode() {
+ int hashCode = 23;
+ hashCode = (hashCode * 37) + (space == null ? 1 : space.hashCode()) + (token == null ? 1 : token.hashCode());
+ return hashCode;
+ }
+
+ @Override
+ public String toString() {
+ return "SpaceConfEvent[" + space + "/" + token + "]";
+ }
+}
Property changes on: trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceConfEvent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -22,12 +22,19 @@
import cc.kune.common.client.noti.NotifyLevel;
import cc.kune.core.client.auth.SignIn;
import cc.kune.core.client.init.AppStartEvent;
+import cc.kune.core.client.state.HistoryWrapper;
import cc.kune.core.client.state.Session;
+import cc.kune.core.client.state.SiteTokens;
+import cc.kune.core.client.state.TokenUtils;
import cc.kune.core.client.state.UserSignInEvent;
import cc.kune.core.client.state.UserSignOutEvent;
+import cc.kune.core.shared.domain.utils.StateToken;
import cc.kune.core.shared.i18n.I18nTranslationService;
import cc.kune.gspace.client.WsArmor;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.EventBus;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -47,6 +54,14 @@
public interface SpaceSelectorView extends View {
+ HasClickHandlers getGroupBtn();
+
+ HasClickHandlers getHomeBtn();
+
+ HasClickHandlers getPublicBtn();
+
+ HasClickHandlers getUserBtn();
+
void setGroupBtnDown(boolean down);
void setHomeBtnDown(boolean down);
@@ -57,59 +72,65 @@
}
private final WsArmor armor;
+ private Space currentSpace;
+ private String groupToken;
+ private String homeToken;
private final I18nTranslationService i18n;
+ private boolean nextUserSpace;
+ private String publicToken;
private final Session session;
private final Provider<SignIn> signIn;
- private Space currentSpace;
- private boolean nextUserSpace;
+ private String userToken;
@Inject
public SpaceSelectorPresenter(final EventBus eventBus, final SpaceSelectorView view,
final SpaceSelectorProxy proxy, final WsArmor armor, final Session session, final Provider<SignIn> sigIn,
- final I18nTranslationService i18n) {
+ final I18nTranslationService i18n, final HistoryWrapper history) {
super(eventBus, view, proxy);
this.armor = armor;
this.session = session;
this.signIn = sigIn;
this.i18n = i18n;
nextUserSpace = false;
- }
-
- @ProxyEvent
- public void onUserSignIn(UserSignInEvent event) {
- if (nextUserSpace) {
- onUserSpaceSelect();
- nextUserSpace = false;
- }
- }
-
- @ProxyEvent
- public void onUserSignOut(UserSignOutEvent event) {
- if (currentSpace == Space.userSpace)
- nextUserSpace = false;
- onHomeSpaceSelect();
- }
-
- @ProxyEvent
- public void onSpaceSelect(SpaceSelectEvent event) {
- Space space = event.getSpace();
- if (space != currentSpace) {
- switch (space) {
- case homeSpace:
- onHomeSpaceSelect();
- break;
- case userSpace:
- onUserSpaceSelect();
- break;
- case groupSpace:
+ homeToken = SiteTokens.HOME;
+ userToken = SiteTokens.WAVEINBOX;
+ groupToken = SiteTokens.GROUP_HOME;
+ publicToken = TokenUtils.preview(SiteTokens.GROUP_HOME);
+ view.getHomeBtn().addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ gotoTokenIfDifferent(history, homeToken);
+ }
+ });
+ view.getUserBtn().addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ gotoTokenIfDifferent(history, userToken);
+ }
+ });
+ view.getGroupBtn().addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ gotoTokenIfDifferent(history, groupToken);
onGroupSpaceSelect();
- break;
- case publicSpace:
+ }
+ });
+ view.getPublicBtn().addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ gotoTokenIfDifferent(history, publicToken);
onPublicSpaceSelect();
- break;
- default:
- break;
}
+ });
+ }
+
+ private void gotoTokenIfDifferent(final HistoryWrapper history, final String token) {
+ if (!history.getToken().equals(token)) {
+ if ((new StateToken(token)).equals(session.getCurrentStateToken())) {
+ history.newItem(token, false);
+ } else {
+ history.newItem(token);
+ }
}
}
@@ -152,6 +173,65 @@
nextUserSpace = false;
}
+ @ProxyEvent
+ public void onSpaceConf(final SpaceConfEvent event) {
+ final Space space = event.getSpace();
+ final String token = event.getToken();
+ switch (space) {
+ case homeSpace:
+ homeToken = token;
+ break;
+ case userSpace:
+ userToken = token;
+ break;
+ case groupSpace:
+ groupToken = token;
+ break;
+ case publicSpace:
+ publicToken = token;
+ break;
+ }
+ }
+
+ @ProxyEvent
+ public void onSpaceSelect(final SpaceSelectEvent event) {
+ final Space space = event.getSpace();
+ if (space != currentSpace) {
+ switch (space) {
+ case homeSpace:
+ onHomeSpaceSelect();
+ break;
+ case userSpace:
+ onUserSpaceSelect();
+ break;
+ case groupSpace:
+ onGroupSpaceSelect();
+ break;
+ case publicSpace:
+ onPublicSpaceSelect();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ @ProxyEvent
+ public void onUserSignIn(final UserSignInEvent event) {
+ if (nextUserSpace) {
+ onUserSpaceSelect();
+ nextUserSpace = false;
+ }
+ }
+
+ @ProxyEvent
+ public void onUserSignOut(final UserSignOutEvent event) {
+ if (currentSpace == Space.userSpace) {
+ nextUserSpace = false;
+ onHomeSpaceSelect();
+ }
+ }
+
private void onUserSpaceSelect() {
if (session.isLogged()) {
armor.selectUserSpace();
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorViewImpl.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorViewImpl.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorViewImpl.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -20,17 +20,15 @@
package cc.kune.core.client.sitebar.spaces;
import cc.kune.core.client.sitebar.spaces.SpaceSelectorPresenter.SpaceSelectorView;
-import cc.kune.core.client.state.SiteCommonTokens;
import cc.kune.core.client.state.StateManager;
import cc.kune.core.shared.i18n.I18nTranslationService;
import cc.kune.gspace.client.WsArmor;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.ToggleButton;
import com.google.gwt.user.client.ui.Widget;
@@ -41,22 +39,23 @@
interface SpaceSelectorViewImplUiBinder extends UiBinder<Widget, SpaceSelectorViewImpl> {
}
private static SpaceSelectorViewImplUiBinder uiBinder = GWT.create(SpaceSelectorViewImplUiBinder.class);
+ private final EventBus eventBus;
@UiField
ToggleButton groupButton;
@UiField
ToggleButton homeButton;
@UiField
HorizontalPanel panel;
+
@UiField
ToggleButton publicButton;
-
+ private final StateManager stateManager;
@UiField
ToggleButton userButton;
- private final StateManager stateManager;
- private final EventBus eventBus;
@Inject
- public SpaceSelectorViewImpl(final WsArmor armor, final I18nTranslationService i18n, StateManager stateManager, EventBus eventBus) {
+ public SpaceSelectorViewImpl(final WsArmor armor, final I18nTranslationService i18n,
+ final StateManager stateManager, final EventBus eventBus) {
this.stateManager = stateManager;
this.eventBus = eventBus;
armor.getSitebar().insert(uiBinder.createAndBindUi(this), 0);
@@ -71,24 +70,24 @@
return panel;
}
- @UiHandler("groupButton")
- void onGroupSpaceClick(final ClickEvent event) {
- SpaceSelectEvent.fire(eventBus, Space.groupSpace);
- }
+ @Override
+ public HasClickHandlers getGroupBtn() {
+ return groupButton;
+ }
- @UiHandler("homeButton")
- void onHomeSpaceClick(final ClickEvent event) {
- stateManager.gotoToken(SiteCommonTokens.HOME);
+ @Override
+ public HasClickHandlers getHomeBtn() {
+ return homeButton;
}
- @UiHandler("publicButton")
- void onPublicSpaceClick(final ClickEvent event) {
- SpaceSelectEvent.fire(eventBus, Space.publicSpace);
+ @Override
+ public HasClickHandlers getPublicBtn() {
+ return publicButton;
}
- @UiHandler("userButton")
- void onUserSpaceClick(final ClickEvent event) {
- SpaceSelectEvent.fire(eventBus, Space.userSpace);
+ @Override
+ public HasClickHandlers getUserBtn() {
+ return userButton;
}
@Override
Modified: trunk/src/main/java/cc/kune/core/client/state/HistoryWrapper.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/HistoryWrapper.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/state/HistoryWrapper.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -25,4 +25,6 @@
void newItem(final String historyToken);
+ void newItem(String historyToken, boolean issueEvent);
+
}
\ No newline at end of file
Modified: trunk/src/main/java/cc/kune/core/client/state/HistoryWrapperDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/HistoryWrapperDefault.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/state/HistoryWrapperDefault.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -30,8 +30,12 @@
@Override
public void newItem(final String historyToken) {
- // NotifyUser.info("New history token: " + historyToken);
History.newItem(historyToken);
}
+ @Override
+ public void newItem(final String historyToken, final boolean issueEvent) {
+ History.newItem(historyToken, issueEvent);
+ }
+
}
Added: trunk/src/main/java/cc/kune/core/client/state/ReservedWordsRegistry.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/ReservedWordsRegistry.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/state/ReservedWordsRegistry.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -0,0 +1,8 @@
+package cc.kune.core.client.state;
+
+import java.util.ArrayList;
+
+ at SuppressWarnings("serial")
+public class ReservedWordsRegistry extends ArrayList<String> {
+
+}
Property changes on: trunk/src/main/java/cc/kune/core/client/state/ReservedWordsRegistry.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/src/main/java/cc/kune/core/client/state/SiteCommonTokens.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/SiteCommonTokens.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/state/SiteCommonTokens.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -1,37 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package cc.kune.core.client.state;
-
-/**
- * Some common history tokens like {@link #SIGNIN} and {@link #NEWGROUP}
- *
- */
-public final class SiteCommonTokens {
- public static final String ABOUTKUNE = "about";
- public final static String GROUP_HOME = "";
- public final static String NEWGROUP = "newgroup";
- public final static String REGISTER = "register";
- public final static String SIGNIN = "signin";
- public final static String TRANSLATE = "translate";
- public final static String HOME = "home";
-
- private SiteCommonTokens() {
- }
-}
Modified: trunk/src/main/java/cc/kune/core/client/state/SiteTokenListeners.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/SiteTokenListeners.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/state/SiteTokenListeners.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -36,11 +36,11 @@
@Singleton
public class SiteTokenListeners {
private final Provider<AboutKuneDialog> aboutKuneDialog;
+ private final EventBus eventBus;
private final Provider<NewGroup> newGroup;
private final Provider<Register> register;
private final Provider<SignIn> signIn;
private final Provider<StateManager> stateManager;
- private final EventBus eventBus;
@Inject
public SiteTokenListeners(final Session session, final EventBus eventBus,
@@ -63,31 +63,37 @@
}
private void init() {
- stateManager.get().addSiteToken(SiteCommonTokens.HOME, new HistoryTokenCallback() {
+ stateManager.get().addSiteToken(SiteTokens.HOME, new HistoryTokenCallback() {
@Override
public void onHistoryToken() {
SpaceSelectEvent.fire(eventBus, Space.homeSpace);
}
});
- stateManager.get().addSiteToken(SiteCommonTokens.SIGNIN, new HistoryTokenCallback() {
+ stateManager.get().addSiteToken(SiteTokens.WAVEINBOX, new HistoryTokenCallback() {
@Override
public void onHistoryToken() {
+ SpaceSelectEvent.fire(eventBus, Space.userSpace);
+ }
+ });
+ stateManager.get().addSiteToken(SiteTokens.SIGNIN, new HistoryTokenCallback() {
+ @Override
+ public void onHistoryToken() {
signIn.get().showSignInDialog();
}
});
- stateManager.get().addSiteToken(SiteCommonTokens.REGISTER, new HistoryTokenCallback() {
+ stateManager.get().addSiteToken(SiteTokens.REGISTER, new HistoryTokenCallback() {
@Override
public void onHistoryToken() {
register.get().doRegister();
}
});
- stateManager.get().addSiteToken(SiteCommonTokens.NEWGROUP, new HistoryTokenCallback() {
+ stateManager.get().addSiteToken(SiteTokens.NEWGROUP, new HistoryTokenCallback() {
@Override
public void onHistoryToken() {
newGroup.get().doNewGroup();
}
});
- stateManager.get().addSiteToken(SiteCommonTokens.ABOUTKUNE, new HistoryTokenCallback() {
+ stateManager.get().addSiteToken(SiteTokens.ABOUTKUNE, new HistoryTokenCallback() {
@Override
public void onHistoryToken() {
// FIXME, something to come back
Copied: trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java (from rev 1299, trunk/src/main/java/cc/kune/core/client/state/SiteCommonTokens.java)
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -0,0 +1,51 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.core.client.state;
+
+import com.google.inject.Inject;
+
+/**
+ * Some common history tokens like {@link #SIGNIN} and {@link #NEWGROUP}
+ *
+ */
+public final class SiteTokens {
+ public static final String ABOUTKUNE = "about";
+ public final static String GROUP_HOME = "";
+ public final static String HOME = "home";
+ public final static String NEWGROUP = "newgroup";
+ public static final String PREVIEW = "preview";
+ public final static String REGISTER = "register";
+ public final static String SIGNIN = "signin";
+ public final static String TRANSLATE = "translate";
+ public final static String WAVEINBOX = "inbox";
+
+ @Inject
+ public SiteTokens(final ReservedWordsRegistry reserverdWords) {
+ reserverdWords.add(ABOUTKUNE);
+ reserverdWords.add(GROUP_HOME);
+ reserverdWords.add(HOME);
+ reserverdWords.add(NEWGROUP);
+ reserverdWords.add(PREVIEW);
+ reserverdWords.add(REGISTER);
+ reserverdWords.add(SIGNIN);
+ reserverdWords.add(TRANSLATE);
+ reserverdWords.add(WAVEINBOX);
+ }
+}
Property changes on: trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -22,15 +22,17 @@
import java.util.HashMap;
-import org.waveprotocol.box.webclient.client.HistorySupport;
+import org.waveprotocol.wave.util.escapers.GwtWaverefEncoder;
import cc.kune.common.client.actions.BeforeActionCollection;
import cc.kune.common.client.actions.BeforeActionListener;
import cc.kune.common.client.errors.NotImplementedException;
import cc.kune.common.client.log.Log;
+import cc.kune.common.client.utils.Pair;
import cc.kune.core.client.notify.spiner.ProgressHideEvent;
import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
import cc.kune.core.client.sitebar.spaces.Space;
+import cc.kune.core.client.sitebar.spaces.SpaceConfEvent;
import cc.kune.core.client.sitebar.spaces.SpaceSelectEvent;
import cc.kune.core.client.state.GroupChangedEvent.GroupChangedHandler;
import cc.kune.core.client.state.SocialNetworkChangedEvent.SocialNetworkChangedHandler;
@@ -60,16 +62,19 @@
private StateToken resumedToken;
private final Session session;
private final HashMap<String, HistoryTokenCallback> siteTokens;
+ private final TokenMatcher tokenMatcher;
@Inject
public StateManagerDefault(final ContentCache contentProvider, final Session session, final HistoryWrapper history,
- final EventBus eventBus) {
+ final TokenMatcher tokenMatcher, final EventBus eventBus) {
+ this.tokenMatcher = tokenMatcher;
this.eventBus = eventBus;
this.contentProvider = contentProvider;
this.session = session;
this.history = history;
this.previousToken = null;
this.resumedToken = null;
+ tokenMatcher.init(GwtWaverefEncoder.INSTANCE);
siteTokens = new HashMap<String, HistoryTokenCallback>();
beforeStateChangeCollection = new BeforeActionCollection();
session.onUserSignIn(true, new UserSignInEvent.UserSignInHandler() {
@@ -165,26 +170,49 @@
});
}
- void onHistoryChanged(final String historyToken) {
+ void onHistoryChanged(final String newHistoryToken) {
// http://code.google.com/p/google-web-toolkit-doc-1-5/wiki/DevGuideHistory
if (beforeStateChangeCollection.checkBeforeAction()) {
- final HistoryTokenCallback tokenListener = siteTokens.get(historyToken != null ? historyToken.toLowerCase()
- : historyToken);
- Log.debug("StateManager: on history changed (" + historyToken + ")");
+ HistoryTokenCallback tokenListener = null;
+ if (newHistoryToken != null) {
+ final String nToken = newHistoryToken.toLowerCase();
+ tokenListener = siteTokens.get(nToken);
+ }
+ Log.debug("StateManager: on history changed (" + newHistoryToken + ")");
if (tokenListener == null) {
- // Ok, normal token change
- // Is a Wave token?
- if (historyToken == null || HistorySupport.waveRefFromHistoryToken(historyToken) == null) {
- // Non wave token
+ // token is not one of #newgroup #signin #translate ...
+ final String nToken = newHistoryToken.toLowerCase();
+ if (tokenMatcher.hasRedirect(nToken)) {
+ final Pair<String, String> redirect = tokenMatcher.getRedirect(nToken);
+ final String firstToken = redirect.getLeft();
+ final String sndToken = redirect.getRight();
+ if (firstToken.equals(SiteTokens.PREVIEW)) {
+ SpaceSelectEvent.fire(eventBus, Space.publicSpace);
+ SpaceConfEvent.fire(eventBus, Space.groupSpace, sndToken);
+ SpaceConfEvent.fire(eventBus, Space.publicSpace, TokenUtils.preview(sndToken));
+ onHistoryChanged(new StateToken(sndToken));
+ }
+ } else if (tokenMatcher.isWaveToken(newHistoryToken)) {
+ if (session.isLogged()) {
+ SpaceSelectEvent.fire(eventBus, Space.userSpace);
+ } else {
+ history.newItem(TokenUtils.addRedirect(SiteTokens.SIGNIN, newHistoryToken));
+ }
+ if (previousToken == null) {
+ // Starting application (with Wave url)
+ onHistoryChanged(new StateToken(SiteTokens.GROUP_HOME));
+ }
+ } else if (tokenMatcher.isGroupToken(newHistoryToken)) {
+ SpaceConfEvent.fire(eventBus, Space.groupSpace, newHistoryToken);
+ SpaceConfEvent.fire(eventBus, Space.publicSpace, TokenUtils.preview(newHistoryToken));
SpaceSelectEvent.fire(eventBus, Space.groupSpace);
- onHistoryChanged(new StateToken(historyToken));
+ onHistoryChanged(new StateToken(newHistoryToken));
} else {
- SpaceSelectEvent.fire(eventBus, Space.userSpace);
- // Wave token
- // spaceSelector.onUserSpaceSelect();
- if (session.isNotLogged()) {
- // use r=? argument?
- }
+ // While we don't redefine token "" as home:
+ SpaceSelectEvent.fire(eventBus, Space.groupSpace);
+ SpaceConfEvent.fire(eventBus, Space.groupSpace, SiteTokens.GROUP_HOME);
+ SpaceConfEvent.fire(eventBus, Space.publicSpace, TokenUtils.preview(SiteTokens.GROUP_HOME));
+ onHistoryChanged(new StateToken(SiteTokens.GROUP_HOME));
}
} else {
// token is one of #newgroup #signin #translate ...
@@ -197,7 +225,7 @@
tokenListener.onHistoryToken();
}
} else {
- resumedToken = new StateToken(historyToken);
+ resumedToken = new StateToken(newHistoryToken);
}
}
Added: trunk/src/main/java/cc/kune/core/client/state/TokenMatcher.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/TokenMatcher.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/state/TokenMatcher.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -0,0 +1,68 @@
+package cc.kune.core.client.state;
+
+import org.waveprotocol.wave.model.waveref.InvalidWaveRefException;
+import org.waveprotocol.wave.model.waveref.WaverefEncoder;
+
+import cc.kune.common.client.utils.Pair;
+import cc.kune.core.shared.domain.utils.StateToken;
+
+import com.google.inject.Inject;
+
+public class TokenMatcher {
+
+ private WaverefEncoder encoder;
+ private final ReservedWordsRegistry reservedWordsRegistry;
+
+ @Inject
+ public TokenMatcher(final ReservedWordsRegistry reservedWordsRegistry) {
+ this.reservedWordsRegistry = reservedWordsRegistry;
+ }
+
+ public Pair<String, String> getRedirect(final String token) {
+ final String[] splited = splitRedirect(token);
+ if (hasRedirect(token, splited)) {
+ return Pair.create(splited[0], splited[1].replaceAll("\\)$", ""));
+ }
+ return null;
+ }
+
+ public boolean hasRedirect(final String token) {
+ final String[] splited = splitRedirect(token);
+ if (hasRedirect(token, splited)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean hasRedirect(final String token, final String[] splited) {
+ return token.endsWith(")") && splited.length == 2;
+ }
+
+ public void init(final WaverefEncoder encoder) {
+ assert encoder != null;
+ this.encoder = encoder;
+ }
+
+ public boolean isGroupToken(final String token) {
+ return token != null && !isWaveToken(token) && !hasRedirect(token) && !reservedWordsRegistry.contains(token)
+ && !new StateToken(token).hasNothing();
+ }
+
+ public boolean isHomeToken(final String currentToken) {
+ return SiteTokens.HOME.equals(currentToken);
+ }
+
+ public boolean isWaveToken(final String token) {
+ assert encoder != null;
+ try {
+ return token == null ? false : encoder.decodeWaveRefFromPath(token) != null;
+ } catch (final InvalidWaveRefException e) {
+ return false;
+ }
+ }
+
+ private String[] splitRedirect(final String token) {
+ return token.split("\\(");
+ }
+
+}
Property changes on: trunk/src/main/java/cc/kune/core/client/state/TokenMatcher.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/src/main/java/cc/kune/core/client/state/TokenUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/TokenUtils.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/state/TokenUtils.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -0,0 +1,12 @@
+package cc.kune.core.client.state;
+
+public class TokenUtils {
+
+ public static String addRedirect(final String token, final String redirect) {
+ return new StringBuffer().append(token).append("(").append(redirect).append(")").toString();
+ }
+
+ public static String preview(final String token) {
+ return addRedirect(SiteTokens.PREVIEW, token);
+ }
+}
Property changes on: trunk/src/main/java/cc/kune/core/client/state/TokenUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/src/main/java/cc/kune/core/public/ws.css
===================================================================
--- trunk/src/main/java/cc/kune/core/public/ws.css 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/core/public/ws.css 2011-04-01 22:07:25 UTC (rev 1301)
@@ -1091,7 +1091,3 @@
background-color: inherits;
}
-.gwt-Button {
- background: url("gwt/chrome/images/hborder.png") repeat-x scroll 0 -27px
- transparent;
-}
\ No newline at end of file
Modified: trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -13,6 +13,7 @@
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsonUtils;
+import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.InsertPanel.ForIsWidget;
import com.google.inject.Inject;
@@ -20,7 +21,7 @@
private WebClient webClient;
@Inject
- public WaveClientManager(final Session session, final StateManager stateManager,
+ public WaveClientManager(final Session session, final StateManager stateManager, final EventBus eventBus,
final UserServiceAsync userService, final WsArmor wsArmor) {
session.onUserSignIn(true, new UserSignInHandler() {
@Override
@@ -39,7 +40,7 @@
if (userSpace.getWidgetCount() > 0) {
userSpace.remove(0);
}
- webClient = new WebClient();
+ webClient = new WebClient(eventBus);
userSpace.add(webClient);
}
}
Modified: trunk/src/main/java/cc/kune/wave/client/WebClient.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WebClient.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/cc/kune/wave/client/WebClient.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -22,10 +22,10 @@
-import org.waveprotocol.box.webclient.client.HistorySupport;
import org.waveprotocol.box.webclient.client.ClientEvents;
import org.waveprotocol.box.webclient.client.ClientIdGenerator;
import org.waveprotocol.box.webclient.client.DebugMessagePanel;
+import org.waveprotocol.box.webclient.client.HistorySupport;
import org.waveprotocol.box.webclient.client.RemoteViewServiceMultiplexer;
import org.waveprotocol.box.webclient.client.Session;
import org.waveprotocol.box.webclient.client.SimpleWaveStore;
@@ -60,11 +60,15 @@
import org.waveprotocol.wave.model.waveref.WaveRef;
import cc.kune.common.client.noti.NotifyUser;
+import cc.kune.core.client.sitebar.spaces.Space;
+import cc.kune.core.client.sitebar.spaces.SpaceConfEvent;
+import cc.kune.core.client.state.SiteTokens;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.GWT.UncaughtExceptionHandler;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
+import com.google.gwt.event.shared.EventBus;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
@@ -75,6 +79,7 @@
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.SplitLayoutPanel;
import com.google.gwt.user.client.ui.UIObject;
+import com.google.inject.Inject;
/**
* Entry point classes define <code>onModuleLoad()</code>.
@@ -127,11 +132,15 @@
private RemoteViewServiceMultiplexer channel;
+private final EventBus eventBus;
+
/**
* This is the entry point method.
*/
- public WebClient() {
+ @Inject
+ public WebClient(EventBus eventBus) {
+ this.eventBus = eventBus;
ErrorHandler.install();
ClientEvents.get().addWaveCreationEventHandler(
@@ -284,22 +293,24 @@
}
});
String encodedToken = History.getToken();
- NotifyUser.info("Open Wave: " + encodedToken + " waveRef: " + waveRef.getWaveId(), true);
- if (encodedToken != null && !encodedToken.isEmpty()) {
+ // NotifyUser.info("Open Wave: " + encodedToken + " waveRef: " + waveRef.getWaveId(), true);
+ // Kune patch
+ if (encodedToken != null && !encodedToken.isEmpty() && !encodedToken.equals(SiteTokens.WAVEINBOX)) {
WaveRef fromWaveRef = HistorySupport.waveRefFromHistoryToken(encodedToken);
if (waveRef == null) {
LOG.info("History token contains invalid path: " + encodedToken);
return;
}
- // Kune patch
- // if (fromWaveRef.getWaveId().equals(waveRef.getWaveId())) {
- if (fromWaveRef == null || fromWaveRef.getWaveId().equals(waveRef.getWaveId())) {
+ if (fromWaveRef.getWaveId().equals(waveRef.getWaveId())) {
// History change was caused by clicking on a link, it's already
// updated by browser.
+ SpaceConfEvent.fire(eventBus, Space.userSpace, encodedToken);
return;
}
}
- History.newItem(HistorySupport.historyTokenFromWaveref(waveRef), false);
+ String tokenFromWaveref = HistorySupport.historyTokenFromWaveref(waveRef);
+ SpaceConfEvent.fire(eventBus, Space.userSpace, tokenFromWaveref);
+ History.newItem(tokenFromWaveref, false);
}
/**
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -203,7 +203,7 @@
import cc.kune.core.client.services.MediaUtils;
import cc.kune.core.client.state.HistoryTokenCallback;
import cc.kune.core.client.state.Session;
-import cc.kune.core.client.state.SiteCommonTokens;
+import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
import cc.kune.core.shared.domain.utils.StateToken;
import cc.kune.core.shared.dto.StateTokenUtils;
@@ -948,7 +948,7 @@
});
// Register of tokens like "signin", "newgroup", "translate" etcetera
- i(StateManager.class).addSiteToken(SiteCommonTokens.SIGNIN, new HistoryTokenCallback() {
+ i(StateManager.class).addSiteToken(SiteTokens.SIGNIN, new HistoryTokenCallback() {
@Override
public void onHistoryToken() {
@@ -956,7 +956,7 @@
}
});
- i(StateManager.class).addSiteToken(SiteCommonTokens.REGISTER, new HistoryTokenCallback() {
+ i(StateManager.class).addSiteToken(SiteTokens.REGISTER, new HistoryTokenCallback() {
@Override
public void onHistoryToken() {
@@ -964,7 +964,7 @@
}
});
- i(StateManager.class).addSiteToken(SiteCommonTokens.NEWGROUP, new HistoryTokenCallback() {
+ i(StateManager.class).addSiteToken(SiteTokens.NEWGROUP, new HistoryTokenCallback() {
@Override
public void onHistoryToken() {
@@ -972,7 +972,7 @@
}
});
- i(StateManager.class).addSiteToken(SiteCommonTokens.TRANSLATE, new HistoryTokenCallback() {
+ i(StateManager.class).addSiteToken(SiteTokens.TRANSLATE, new HistoryTokenCallback() {
@Override
public void onHistoryToken() {
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitesign/SiteSignInLinkPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitesign/SiteSignInLinkPanel.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitesign/SiteSignInLinkPanel.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -22,7 +22,7 @@
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
import cc.kune.core.client.i18n.I18nUITranslationService;
-import cc.kune.core.client.state.SiteCommonTokens;
+import cc.kune.core.client.state.SiteTokens;
import com.google.gwt.user.client.ui.Hyperlink;
@@ -37,7 +37,7 @@
signInHyperlink = new Hyperlink();
signInHyperlink.ensureDebugId(SITE_SIGN_IN);
signInHyperlink.setText(i18n.t("Sign in to collaborate"));
- signInHyperlink.setTargetHistoryToken(SiteCommonTokens.SIGNIN);
+ signInHyperlink.setTargetHistoryToken(SiteTokens.SIGNIN);
ws.getSiteBar().add(signInHyperlink);
ws.getSiteBar().addSpacer();
}
Modified: trunk/src/test/java/cc/kune/core/client/state/StateManagerTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/client/state/StateManagerTest.java 2011-03-30 14:56:20 UTC (rev 1300)
+++ trunk/src/test/java/cc/kune/core/client/state/StateManagerTest.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -47,6 +47,7 @@
private StateAbstractDTO state;
private StateChangedHandler stateChangeHandler;
private StateManagerDefault stateManager;
+ private TokenMatcher tokenMatcher;
private ToolChangedHandler toolChangeHandler;
@Before
@@ -54,9 +55,10 @@
contentProvider = Mockito.mock(ContentCache.class);
session = Mockito.mock(Session.class);
history = Mockito.mock(HistoryWrapper.class);
+ tokenMatcher = Mockito.mock(TokenMatcher.class);
spaceSelector = Mockito.mock(SpaceSelectorPresenter.class);
eventBus = new EventBusTester();
- stateManager = new StateManagerDefault(contentProvider, session, history, eventBus);
+ stateManager = new StateManagerDefault(contentProvider, session, history, tokenMatcher, eventBus);
Mockito.when(session.getUserHash()).thenReturn(HASH);
state = Mockito.mock(StateAbstractDTO.class);
stateChangeHandler = Mockito.mock(StateChangedHandler.class);
@@ -231,7 +233,7 @@
@Test
public void siteTokenFirstLoadDefContentAndFireListener() {
final HistoryTokenCallback listener = Mockito.mock(HistoryTokenCallback.class);
- final String token = SiteCommonTokens.SIGNIN;
+ final String token = SiteTokens.SIGNIN;
stateManager.addSiteToken(token, listener);
stateManager.onHistoryChanged(token);
Mockito.verify(listener, Mockito.times(1)).onHistoryToken();
Added: trunk/src/test/java/cc/kune/core/client/state/TokenMatcherTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/client/state/TokenMatcherTest.java (rev 0)
+++ trunk/src/test/java/cc/kune/core/client/state/TokenMatcherTest.java 2011-04-01 22:07:25 UTC (rev 1301)
@@ -0,0 +1,118 @@
+package cc.kune.core.client.state;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.waveprotocol.wave.util.escapers.jvm.JavaWaverefEncoder;
+
+public class TokenMatcherTest {
+
+ private static final String DEF_SITE_TOKEN = "";
+ private static final String GROUP_TOKEN = "site.docs.1";
+ private static final String GROUP_TOKEN_ONLY_PROJECT = "site";
+ private static final String GROUP_TOKEN_ONLY_PROJECT_AND_TOOL = "site.docs";
+ private static final String REDIRECT_LINK = "example.com/w+jsdKixyHhZA";
+ private static final String SIGNIN_TOKEN = "signin";
+ private static final String SIGNIN_TOKEN_WITH_REDIRECT = SIGNIN_TOKEN + "(" + REDIRECT_LINK + ")";
+ private static final String WAVE_TOKEN_SAMPLE1 = "example.com/w+abcd";
+ private static final String WAVE_TOKEN_SAMPLE2 = "example.com/w+abcd/~/conv+root";
+ private static final String WAVE_TOKEN_SAMPLE3 = "example.com/w+abcd/~/conv+root/b+45kg";
+ private TokenMatcher tokenMatcher;
+
+ @Before
+ public void before() {
+ final ReservedWordsRegistry reservedWords = new ReservedWordsRegistry();
+ reservedWords.add(SIGNIN_TOKEN);
+ tokenMatcher = new TokenMatcher(reservedWords);
+ tokenMatcher.init(JavaWaverefEncoder.INSTANCE);
+ }
+
+ private void dontMatchGroupToken(final String token) {
+ assertFalse("Expected '" + token + "' dont match isGroup", tokenMatcher.isGroupToken(token));
+ }
+
+ @Test
+ public void dontMatchRedirect() {
+ dontMatchWaveToken(SIGNIN_TOKEN_WITH_REDIRECT);
+ dontMatchGroupToken(SIGNIN_TOKEN_WITH_REDIRECT);
+ assertFalse(tokenMatcher.hasRedirect(SIGNIN_TOKEN));
+ }
+
+ private void dontMatchWaveToken(final String token) {
+ assertFalse("Expected '" + token + "' dont match isWaveToken", tokenMatcher.isWaveToken(token));
+ }
+
+ private void matchGroupToken(final String token) {
+ assertTrue("Expected '" + token + "' match isGroup", tokenMatcher.isGroupToken(token));
+ }
+
+ private void matchWaveToken(final String token) {
+ assertTrue("Expected '" + token + "' match isWaveToken", tokenMatcher.isWaveToken(token));
+ }
+
+ @Test
+ public void matchWaveToken2() {
+ matchWaveToken(WAVE_TOKEN_SAMPLE2);
+ dontMatchGroupToken(WAVE_TOKEN_SAMPLE2);
+ }
+
+ @Test
+ public void matchWaveToken3() {
+ matchWaveToken(WAVE_TOKEN_SAMPLE3);
+ dontMatchGroupToken(WAVE_TOKEN_SAMPLE3);
+ }
+
+ @Test
+ public void shouldDontMatchNull() {
+ dontMatchWaveToken(null);
+ dontMatchWaveToken("");
+ dontMatchGroupToken(null);
+ dontMatchGroupToken("");
+ }
+
+ @Test
+ public void shouldExtractRedirect() {
+ assertTrue(tokenMatcher.hasRedirect(SIGNIN_TOKEN_WITH_REDIRECT));
+ assertEquals(SIGNIN_TOKEN, tokenMatcher.getRedirect(SIGNIN_TOKEN_WITH_REDIRECT).getLeft());
+ assertEquals(REDIRECT_LINK, tokenMatcher.getRedirect(SIGNIN_TOKEN_WITH_REDIRECT).getRight());
+ }
+
+ @Test
+ public void shoulMatchCompleteToken() {
+ matchGroupToken(GROUP_TOKEN);
+ dontMatchWaveToken(GROUP_TOKEN);
+ }
+
+ @Test
+ public void shoulMatchGroupToken() {
+ matchGroupToken(GROUP_TOKEN_ONLY_PROJECT);
+ dontMatchWaveToken(GROUP_TOKEN_ONLY_PROJECT);
+ }
+
+ @Test
+ public void shoulMatchGroupToolToken() {
+ matchGroupToken(GROUP_TOKEN_ONLY_PROJECT_AND_TOOL);
+ dontMatchWaveToken(GROUP_TOKEN_ONLY_PROJECT_AND_TOOL);
+ }
+
+ @Test
+ public void testDefSiteTokenDontMatch() {
+ dontMatchWaveToken(DEF_SITE_TOKEN);
+ dontMatchGroupToken(DEF_SITE_TOKEN);
+ }
+
+ @Test
+ public void testMatchWaveToken1() {
+ matchWaveToken(WAVE_TOKEN_SAMPLE1);
+ dontMatchGroupToken(WAVE_TOKEN_SAMPLE1);
+ }
+
+ @Test
+ public void testOtherSiteTokensDontMatch() {
+ dontMatchWaveToken(SIGNIN_TOKEN);
+ dontMatchGroupToken(SIGNIN_TOKEN);
+ }
+}
Property changes on: trunk/src/test/java/cc/kune/core/client/state/TokenMatcherTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the kune-commits
mailing list