[kune-commits] r1505 - in trunk/src/main/java/cc/kune: core/client/sitebar/spaces core/client/state wave/client wave/client/inboxcount
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Fri Sep 2 02:51:35 CEST 2011
Author: vjrj_
Date: 2011-09-02 02:51:34 +0200 (Fri, 02 Sep 2011)
New Revision: 1505
Modified:
trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectEvent.java
trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java
trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java
trunk/src/main/java/cc/kune/wave/client/WebClient.java
trunk/src/main/java/cc/kune/wave/client/inboxcount/InboxCountPanel.java
trunk/src/main/java/cc/kune/wave/client/inboxcount/InboxCountPresenter.java
Log:
CLOSED - # 112: Notify in user space icons new waves, or unread waves
http://kune.ourproject.org/issues/ticket/112
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectEvent.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectEvent.java 2011-09-01 20:02:37 UTC (rev 1504)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectEvent.java 2011-09-02 00:51:34 UTC (rev 1505)
@@ -26,74 +26,99 @@
public class SpaceSelectEvent extends GwtEvent<SpaceSelectEvent.SpaceSelectHandler> {
- public interface HasSpaceSelectHandlers extends HasHandlers {
- HandlerRegistration addSpaceSelectHandler(SpaceSelectHandler handler);
- }
+ public interface HasSpaceSelectHandlers extends HasHandlers {
+ HandlerRegistration addSpaceSelectHandler(SpaceSelectHandler handler);
+ }
- public interface SpaceSelectHandler extends EventHandler {
- public void onSpaceSelect(SpaceSelectEvent event);
- }
+ public interface SpaceSelectHandler extends EventHandler {
+ public void onSpaceSelect(SpaceSelectEvent event);
+ }
- private static final Type<SpaceSelectHandler> TYPE = new Type<SpaceSelectHandler>();
+ private static final Type<SpaceSelectHandler> TYPE = new Type<SpaceSelectHandler>();
- public static void fire(HasHandlers source, cc.kune.core.client.sitebar.spaces.Space space) {
- source.fireEvent(new SpaceSelectEvent(space));
- }
+ public static void fire(final HasHandlers source, final cc.kune.core.client.sitebar.spaces.Space space) {
+ source.fireEvent(new SpaceSelectEvent(space));
+ }
- public static Type<SpaceSelectHandler> getType() {
- return TYPE;
- }
+ public static void fire(final HasHandlers source,
+ final cc.kune.core.client.sitebar.spaces.Space space, final boolean restoreToken) {
+ source.fireEvent(new SpaceSelectEvent(space, restoreToken));
+ }
- private cc.kune.core.client.sitebar.spaces.Space space;
+ public static Type<SpaceSelectHandler> getType() {
+ return TYPE;
+ }
+ private boolean restoreToken;
- public SpaceSelectEvent(cc.kune.core.client.sitebar.spaces.Space space) {
- this.space = space;
- }
+ private cc.kune.core.client.sitebar.spaces.Space space;
- protected SpaceSelectEvent() {
- // Possibly for serialization.
- }
+ protected SpaceSelectEvent() {
+ // Possibly for serialization.
+ }
- @Override
- public Type<SpaceSelectHandler> getAssociatedType() {
- return TYPE;
- }
+ public SpaceSelectEvent(final cc.kune.core.client.sitebar.spaces.Space space) {
+ this(space, false);
+ }
- public cc.kune.core.client.sitebar.spaces.Space getSpace() {
- return space;
- }
+ public SpaceSelectEvent(final cc.kune.core.client.sitebar.spaces.Space space,
+ final boolean restoreToken) {
+ this.space = space;
+ this.setRestoreToken(restoreToken);
+ }
- @Override
- protected void dispatch(SpaceSelectHandler handler) {
- handler.onSpaceSelect(this);
- }
+ @Override
+ protected void dispatch(final SpaceSelectHandler handler) {
+ handler.onSpaceSelect(this);
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- SpaceSelectEvent other = (SpaceSelectEvent) obj;
- if (space == null) {
- if (other.space != null)
- return false;
- } else if (!space.equals(other.space))
- return false;
- return true;
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
}
-
- @Override
- public int hashCode() {
- int hashCode = 23;
- hashCode = (hashCode * 37) + (space == null ? 1 : space.hashCode());
- return hashCode;
+ if (obj == null) {
+ return false;
}
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final SpaceSelectEvent other = (SpaceSelectEvent) obj;
+ if (space == null) {
+ if (other.space != null) {
+ return false;
+ }
+ } else if (!space.equals(other.space)) {
+ return false;
+ }
+ return true;
+ }
- @Override
- public String toString() {
- return "SpaceSelectEvent[" + space + "]";
- }
+ @Override
+ public Type<SpaceSelectHandler> getAssociatedType() {
+ return TYPE;
+ }
+
+ public cc.kune.core.client.sitebar.spaces.Space getSpace() {
+ return space;
+ }
+
+ @Override
+ public int hashCode() {
+ int hashCode = 23;
+ hashCode = (hashCode * 37) + (space == null ? 1 : space.hashCode());
+ return hashCode;
+ }
+
+ public void setRestoreToken(final boolean restoreToken) {
+ this.restoreToken = restoreToken;
+ }
+
+ public boolean shouldRestoreToken() {
+ return restoreToken;
+ }
+
+ @Override
+ public String toString() {
+ return "SpaceSelectEvent[" + space + "]";
+ }
}
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-09-01 20:02:37 UTC (rev 1504)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java 2011-09-02 00:51:34 UTC (rev 1505)
@@ -113,30 +113,31 @@
view.getHomeBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
- stateManager.gotoHistoryToken(homeToken);
+ restoreToken(homeToken);
setDown(Space.homeSpace);
}
});
view.getUserBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
- stateManager.gotoHistoryToken(userToken);
+ restoreToken(userToken);
setDown(Space.userSpace);
}
});
view.getGroupBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
- stateManager.gotoHistoryToken(groupToken);
+ restoreToken(groupToken);
setDown(Space.groupSpace);
}
});
view.getPublicBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
- stateManager.gotoHistoryToken(publicToken);
+ restoreToken(publicToken);
setDown(Space.publicSpace);
}
+
});
eventBus.addHandler(WindowFocusEvent.getType(), new WindowFocusEvent.WindowFocusHandler() {
@Override
@@ -153,21 +154,24 @@
// showTooltipWithDelay();
}
- private void onGroupSpaceSelect() {
+ private void onGroupSpaceSelect(final boolean shouldRestoreToken) {
+ restoreToken(shouldRestoreToken, groupToken);
armor.selectGroupSpace();
backManager.restoreBackImage();
setDown(Space.groupSpace);
currentSpace = Space.groupSpace;
}
- private void onHomeSpaceSelect() {
+ private void onHomeSpaceSelect(final boolean shouldRestoreToken) {
+ restoreToken(shouldRestoreToken, homeToken);
armor.selectHomeSpace();
backManager.clearBackImage();
setDown(Space.homeSpace);
currentSpace = Space.homeSpace;
}
- private void onPublicSpaceSelect() {
+ private void onPublicSpaceSelect(final boolean shouldRestoreToken) {
+ restoreToken(shouldRestoreToken, userToken);
armor.selectPublicSpace();
backManager.restoreBackImage();
setDown(Space.publicSpace);
@@ -198,18 +202,19 @@
public void onSpaceSelect(final SpaceSelectEvent event) {
final Space space = event.getSpace();
if (space != currentSpace) {
+ final boolean restoreToken = event.shouldRestoreToken();
switch (space) {
case homeSpace:
- onHomeSpaceSelect();
+ onHomeSpaceSelect(restoreToken);
break;
case userSpace:
- onUserSpaceSelect();
+ onUserSpaceSelect(restoreToken);
break;
case groupSpace:
- onGroupSpaceSelect();
+ onGroupSpaceSelect(restoreToken);
break;
case publicSpace:
- onPublicSpaceSelect();
+ onPublicSpaceSelect(restoreToken);
break;
default:
break;
@@ -220,13 +225,14 @@
@ProxyEvent
public void onUserSignOut(final UserSignOutEvent event) {
if (currentSpace == Space.userSpace) {
- stateManager.gotoHistoryToken(homeToken);
+ restoreToken(homeToken);
}
userToken = SiteTokens.WAVEINBOX;
}
- private void onUserSpaceSelect() {
+ private void onUserSpaceSelect(final boolean shouldRestoreToken) {
if (session.isLogged()) {
+ restoreToken(shouldRestoreToken, userToken);
armor.selectUserSpace();
backManager.clearBackImage();
setDown(Space.userSpace);
@@ -239,6 +245,16 @@
}
}
+ private void restoreToken(final boolean shouldRestoreToken, final String token) {
+ if (shouldRestoreToken) {
+ restoreToken(token);
+ }
+ }
+
+ private void restoreToken(final String token) {
+ stateManager.gotoHistoryToken(token);
+ }
+
@Override
protected void revealInParent() {
RevealRootContentEvent.fire(this, this);
Modified: trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java 2011-09-01 20:02:37 UTC (rev 1504)
+++ trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java 2011-09-02 00:51:34 UTC (rev 1505)
@@ -20,6 +20,9 @@
*/
package cc.kune.core.client.state;
+import org.waveprotocol.box.webclient.client.ClientEvents;
+import org.waveprotocol.box.webclient.client.HistorySupport;
+import org.waveprotocol.box.webclient.client.events.WaveSelectionEvent;
import org.waveprotocol.wave.util.escapers.GwtWaverefEncoder;
import cc.kune.common.client.actions.BeforeActionCollection;
@@ -44,6 +47,8 @@
import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener2;
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.EventBus;
@@ -277,11 +282,19 @@
}
} else if (tokenMatcher.isWaveToken(newHistoryToken)) {
if (session.isLogged()) {
+ SpaceConfEvent.fire(eventBus, Space.userSpace, newHistoryToken);
SpaceSelectEvent.fire(eventBus, Space.userSpace);
+ Scheduler.get().scheduleDeferred(new ScheduledCommand() {
+ @Override
+ public void execute() {
+ ClientEvents.get().fireEvent(
+ new WaveSelectionEvent(HistorySupport.waveRefFromHistoryToken(newHistoryToken)));
+ }
+ });
} else {
history.newItem(TokenUtils.addRedirect(SiteTokens.SIGNIN, newHistoryToken));
if (startingUp()) {
- // Starting application (with Wave url)
+ // Starting application (with Wave url???)
onHistoryChanged(new StateToken(SiteTokens.GROUP_HOME));
}
}
Modified: trunk/src/main/java/cc/kune/wave/client/WebClient.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WebClient.java 2011-09-01 20:02:37 UTC (rev 1504)
+++ trunk/src/main/java/cc/kune/wave/client/WebClient.java 2011-09-02 00:51:34 UTC (rev 1505)
@@ -267,7 +267,8 @@
setupConnectionIndicator();
- HistorySupport.init();
+ // Done in StateManager
+ // HistorySupport.init();
//createWebSocket();
Modified: trunk/src/main/java/cc/kune/wave/client/inboxcount/InboxCountPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/inboxcount/InboxCountPanel.java 2011-09-01 20:02:37 UTC (rev 1504)
+++ trunk/src/main/java/cc/kune/wave/client/inboxcount/InboxCountPanel.java 2011-09-02 00:51:34 UTC (rev 1505)
@@ -32,9 +32,10 @@
addDomHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
- SpaceSelectEvent.fire(eventBus, Space.userSpace);
+ SpaceSelectEvent.fire(eventBus, Space.userSpace, true);
}
}, ClickEvent.getType());
+
}
@Override
Modified: trunk/src/main/java/cc/kune/wave/client/inboxcount/InboxCountPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/inboxcount/InboxCountPresenter.java 2011-09-01 20:02:37 UTC (rev 1504)
+++ trunk/src/main/java/cc/kune/wave/client/inboxcount/InboxCountPresenter.java 2011-09-02 00:51:34 UTC (rev 1505)
@@ -7,10 +7,13 @@
import org.waveprotocol.box.webclient.search.Search;
import org.waveprotocol.box.webclient.search.Search.Listener;
+import cc.kune.chat.client.snd.SndClickEvent;
+import cc.kune.core.client.events.NewUserRegisteredEvent;
import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.UserSignInOrSignOutEvent;
import cc.kune.core.client.state.UserSignInOrSignOutEvent.UserSignInOrSignOutHandler;
+import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.Timer;
import com.google.inject.Inject;
@@ -28,6 +31,7 @@
private int currentTotal;
private final Map<Integer, Integer> diggests;
+ private final EventBus eventBus;
// protected SimpleSearch search;
private final Listener searchListener;
private final Session session;
@@ -36,9 +40,10 @@
private final InboxCountView view;
@Inject
- public InboxCountPresenter(final InboxCountView view, final Session session) {
+ public InboxCountPresenter(final InboxCountView view, final Session session, final EventBus eventBus) {
this.view = view;
this.session = session;
+ this.eventBus = eventBus;
// this.session = session;
diggests = new HashMap<Integer, Integer>();
currentTotal = Search.UNKNOWN_SIZE;
@@ -103,18 +108,32 @@
view.showCount(event.isLogged());
}
});
+
+ eventBus.addHandler(NewUserRegisteredEvent.getType(),
+ new NewUserRegisteredEvent.NewUserRegisteredHandler() {
+ @Override
+ public void onNewUserRegistered(final NewUserRegisteredEvent event) {
+ sendNoticeToUser();
+ }
+ });
+
}
public Listener getSearchListener() {
return searchListener;
}
+ private void sendNoticeToUser() {
+ view.blink();
+ SndClickEvent.fire(eventBus);
+ }
+
private void setTotal(final int total) {
view.setTotal(total);
final boolean show = session.isLogged() && total != Search.UNKNOWN_SIZE && total > 0;
view.showCount(show);
if (show && total > currentTotal) {
- view.blink();
+ sendNoticeToUser();
}
currentTotal = total;
}
More information about the kune-commits
mailing list