r1530 - in trunk/src/main/java/cc/kune: core/server core/server/auth wave/client
Author: vjrj_ Date: 2011-09-23 23:10:32 +0200 (Fri, 23 Sep 2011) New Revision: 1530 Removed: trunk/src/main/java/cc/kune/core/server/auth/SessionService.java trunk/src/main/java/cc/kune/core/server/auth/SessionServiceDefault.java Modified: trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java trunk/src/main/java/cc/kune/core/server/auth/AuthenticatedMethodInterceptor.java trunk/src/main/java/cc/kune/core/server/auth/SuperAdminMethodInterceptor.java trunk/src/main/java/cc/kune/wave/client/KuneConversation.css trunk/src/main/java/cc/kune/wave/client/KuneFullDomRenderer.java trunk/src/main/java/cc/kune/wave/client/KuneFullDomWaveRendererImpl.java trunk/src/main/java/cc/kune/wave/client/KuneStagesProvider.java trunk/src/main/java/cc/kune/wave/client/KuneWaveProfileManager.java trunk/src/main/java/cc/kune/wave/client/WebClient.java Log: CLOSED - # 105: Persist user sessions between restarts http://kune.ourproject.org/issues/ticket/105 Wave code updated Some other fixes / improvements Modified: trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java 2011-09-23 17:07:21 UTC (rev 1529) +++ trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java 2011-09-23 21:10:32 UTC (rev 1530) @@ -39,8 +39,6 @@ import cc.kune.core.server.auth.AuthenticatedMethodInterceptor; import cc.kune.core.server.auth.Authorizated; import cc.kune.core.server.auth.AuthorizatedMethodInterceptor; -import cc.kune.core.server.auth.SessionService; -import cc.kune.core.server.auth.SessionServiceDefault; import cc.kune.core.server.auth.SuperAdmin; import cc.kune.core.server.auth.SuperAdminMethodInterceptor; import cc.kune.core.server.content.ContainerManager; @@ -159,7 +157,6 @@ bind(FinderService.class).to(FinderServiceDefault.class); bind(StateService.class).to(StateServiceDefault.class); bind(I18nTranslationService.class).to(I18nTranslationServiceDefault.class); - bind(SessionService.class).to(SessionServiceDefault.class); bind(KuneWaveService.class).to(KuneWaveServiceDefault.class); bind(XMLActionReader.class); } Modified: trunk/src/main/java/cc/kune/core/server/auth/AuthenticatedMethodInterceptor.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/auth/AuthenticatedMethodInterceptor.java 2011-09-23 17:07:21 UTC (rev 1529) +++ trunk/src/main/java/cc/kune/core/server/auth/AuthenticatedMethodInterceptor.java 2011-09-23 21:10:32 UTC (rev 1530) @@ -41,19 +41,10 @@ Provider<HttpServletRequest> requestProvider; @Inject - Provider<SessionService> sessionServiceProvider; - - // https://code.google.com/p/google-guice/wiki/Transactions - // @Inject - // private UnitOfWork unitOfWork; - @Inject UserSessionManager userSessionManager; @Override public Object invoke(final MethodInvocation invocation) throws Throwable { - // https://code.google.com/p/google-guice/wiki/Transactions - // unitOfWork.end(); - // unitOfWork.begin(); try { final Object[] arguments = invocation.getArguments(); // Some browsers getCookie returns "null" as String instead of null @@ -68,22 +59,18 @@ final boolean mandatory = authAnnotation.mandatory(); if (userHash == null && mandatory) { - // sessionService.getNewSession(); throw new UserMustBeLoggedException(); } else if (userSessionManager.isUserNotLoggedIn() && mandatory) { - // sessionService.getNewSession(); LOG.info("Session expired (not logged in server and mandatory)"); throw new SessionExpiredException(); } else if (userSessionManager.isUserNotLoggedIn() && userHash == null) { // Ok, do nothing } else if (userSessionManager.isUserNotLoggedIn() && userHash != null) { - // sessionService.getNewSession(); LOG.info("Session expired (not logged in server)"); throw new SessionExpiredException(); } else if (!userSessionManager.getHash().equals(userHash)) { final String serverHash = userSessionManager.getHash(); userSessionManager.logout(); - // sessionService.getNewSession(); LOG.info("Session expired (userHash: " + userHash + " different from server hash: " + serverHash + ")"); throw new SessionExpiredException(); @@ -91,7 +78,6 @@ final Object result = invocation.proceed(); return result; } finally { - // unitOfWork.end(); } } Deleted: trunk/src/main/java/cc/kune/core/server/auth/SessionService.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/auth/SessionService.java 2011-09-23 17:07:21 UTC (rev 1529) +++ trunk/src/main/java/cc/kune/core/server/auth/SessionService.java 2011-09-23 21:10:32 UTC (rev 1530) @@ -1,28 +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.server.auth; - -public interface SessionService { - - void setSessionExpiration(); - - void getNewSession(); - -} Deleted: trunk/src/main/java/cc/kune/core/server/auth/SessionServiceDefault.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/auth/SessionServiceDefault.java 2011-09-23 17:07:21 UTC (rev 1529) +++ trunk/src/main/java/cc/kune/core/server/auth/SessionServiceDefault.java 2011-09-23 21:10:32 UTC (rev 1530) @@ -1,69 +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.server.auth; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; - -import com.google.inject.Inject; -import com.google.inject.Provider; -import com.google.inject.Singleton; - -@Singleton -@Deprecated -public class SessionServiceDefault implements SessionService { - - private final Provider<HttpServletRequest> requestProvider; - - @Inject - public SessionServiceDefault(final Provider<HttpServletRequest> requestProvider) { - this.requestProvider = requestProvider; - } - - @Override - @Deprecated - public void getNewSession() { - // HttpSession session = getSession(); - // if (session != null) { - // // During tests session == null - // session.invalidate(); - // } - // getSession(true); - setSessionExpiration(); - } - - private HttpSession getSession() { - return requestProvider.get().getSession(); - } - - private HttpSession getSession(final boolean create) { - return requestProvider.get().getSession(create); - } - - @Override - @Deprecated - public void setSessionExpiration() { - // HttpSession session = getSession(); - // if (session != null) { - // session.setMaxInactiveInterval(Session.SESSION_DURATION / 1000); - // } - } - -} Modified: trunk/src/main/java/cc/kune/core/server/auth/SuperAdminMethodInterceptor.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/auth/SuperAdminMethodInterceptor.java 2011-09-23 17:07:21 UTC (rev 1529) +++ trunk/src/main/java/cc/kune/core/server/auth/SuperAdminMethodInterceptor.java 2011-09-23 21:10:32 UTC (rev 1530) @@ -50,8 +50,6 @@ Provider<KuneProperties> kuneProperties; @Inject Provider<HttpServletRequest> requestProvider; - @Inject - Provider<SessionService> sessionServiceProvider; private Group siteGroup; @Inject UserSessionManager userSessionManager; Modified: trunk/src/main/java/cc/kune/wave/client/KuneConversation.css =================================================================== --- trunk/src/main/java/cc/kune/wave/client/KuneConversation.css 2011-09-23 17:07:21 UTC (rev 1529) +++ trunk/src/main/java/cc/kune/wave/client/KuneConversation.css 2011-09-23 21:10:32 UTC (rev 1530) @@ -12,11 +12,8 @@ z-index: 0; } -@sprite .toolbar { - gwt-image: 'emptyToolbar'; -} - -.fixedThread { /* +.fixedThread { + /* * Allow scrolling. Also, keep the scrollbar there permanently, so that content does not get * horizontally resized by the addition and removal of a scrollbar. */ @@ -27,4 +24,8 @@ /* left: 0; */ /* right: 0; */ /* bottom: 0; */ /* Layout under siblings (participant panel etc). */ z-index: -1; -} \ No newline at end of file +} + +@sprite .toolbar { + gwt-image: 'emptyToolbar'; +} Modified: trunk/src/main/java/cc/kune/wave/client/KuneFullDomRenderer.java =================================================================== --- trunk/src/main/java/cc/kune/wave/client/KuneFullDomRenderer.java 2011-09-23 17:07:21 UTC (rev 1529) +++ trunk/src/main/java/cc/kune/wave/client/KuneFullDomRenderer.java 2011-09-23 21:10:32 UTC (rev 1530) @@ -1,4 +1,5 @@ // @formatter:off +// @formatter:off /** * Copyright 2010 Google Inc. * @@ -60,40 +61,40 @@ public final class KuneFullDomRenderer implements RenderingRules<UiBuilder> { public interface DocRefRenderer { + UiBuilder render(ConversationBlip blip, + IdentityMap<ConversationThread, UiBuilder> replies); + DocRefRenderer EMPTY = new DocRefRenderer() { @Override - public UiBuilder render(final ConversationBlip blip, - final IdentityMap<ConversationThread, UiBuilder> replies) { + public UiBuilder render(ConversationBlip blip, + IdentityMap<ConversationThread, UiBuilder> replies) { return UiBuilder.Constant.of(EscapeUtils.fromSafeConstant("<div></div>")); } }; - - UiBuilder render(ConversationBlip blip, - IdentityMap<ConversationThread, UiBuilder> replies); } public interface ParticipantsRenderer { + UiBuilder render(Conversation c); + ParticipantsRenderer EMPTY = new ParticipantsRenderer() { @Override - public UiBuilder render(final Conversation c) { + public UiBuilder render(Conversation c) { return UiBuilder.Constant.of(EscapeUtils.fromSafeConstant("<div></div>")); } }; - - UiBuilder render(Conversation c); } private final ShallowBlipRenderer blipPopulator; private final DocRefRenderer docRenderer; + private final ViewIdMapper viewIdMapper; + private final ViewFactory viewFactory; private final ProfileManager profileManager; private final ThreadReadStateMonitor readMonitor; - private final ViewFactory viewFactory; - private final ViewIdMapper viewIdMapper; private final boolean showParticipantsPanel; - public KuneFullDomRenderer(final ShallowBlipRenderer blipPopulator, final DocRefRenderer docRenderer, - final ProfileManager profileManager, final ViewIdMapper viewIdMapper, final ViewFactory viewFactory, - final ThreadReadStateMonitor readMonitor, boolean showParticipantsPanel) { + public KuneFullDomRenderer(ShallowBlipRenderer blipPopulator, DocRefRenderer docRenderer, + ProfileManager profileManager, ViewIdMapper viewIdMapper, ViewFactory viewFactory, + ThreadReadStateMonitor readMonitor, boolean showParticipantsPanel) { this.blipPopulator = blipPopulator; this.docRenderer = docRenderer; this.profileManager = profileManager; @@ -103,10 +104,18 @@ this.showParticipantsPanel = showParticipantsPanel; } - public UiBuilder getFirstConversation(final IdentityMap<Conversation, UiBuilder> conversations) { + @Override + public UiBuilder render(ConversationView wave, + IdentityMap<Conversation, UiBuilder> conversations) { + // return the first conversation in the view. + // TODO(hearnden): select the 'best' conversation. + return conversations.isEmpty() ? null : getFirstConversation(conversations); + } + + public UiBuilder getFirstConversation(IdentityMap<Conversation, UiBuilder> conversations) { return conversations.reduce(null, new Reduce<Conversation, UiBuilder, UiBuilder>() { @Override - public UiBuilder apply(final UiBuilder soFar, final Conversation key, final UiBuilder item) { + public UiBuilder apply(UiBuilder soFar, Conversation key, UiBuilder item) { // Pick the first rendering (any will do). return soFar == null ? item : soFar; } @@ -114,25 +123,20 @@ } @Override - public UiBuilder render(final Conversation conversation, final ParticipantId participant) { - final Profile profile = profileManager.getProfile(participant); - final String id = viewIdMapper.participantOf(conversation, participant); - // Use ParticipantAvatarViewBuilder for avatars. - // Kune patch - // final ParticipantNameViewBuilder participantUi = ParticipantNameViewBuilder.create(id); - final ParticipantAvatarViewBuilder participantUi = ParticipantAvatarViewBuilder.create(id); - participantUi.setAvatar(profile.getImageUrl()); - participantUi.setName(profile.getFullName()); - return participantUi; + public UiBuilder render(Conversation conversation, UiBuilder participantsUi, UiBuilder threadUi) { + String id = viewIdMapper.conversationOf(conversation); + boolean isTop = !conversation.hasAnchor(); + return isTop ? viewFactory.createTopConversationView(id, threadUi, participantsUi) + : viewFactory.createInlineConversationView(id, threadUi, participantsUi); } @Override - public UiBuilder render(final Conversation conversation, final StringMap<UiBuilder> participantUis) { - final HtmlClosureCollection participantsUi = new HtmlClosureCollection(); - for (final ParticipantId participant : conversation.getParticipantIds()) { + public UiBuilder render(Conversation conversation, StringMap<UiBuilder> participantUis) { + HtmlClosureCollection participantsUi = new HtmlClosureCollection(); + for (ParticipantId participant : conversation.getParticipantIds()) { participantsUi.add(participantUis.get(participant.getAddress())); } - final String id = viewIdMapper.participantsOf(conversation); + String id = viewIdMapper.participantsOf(conversation); // Kune patch (but not used) return showParticipantsPanel? ParticipantsViewBuilder.create(id, participantsUi): new UiBuilder() { @Override @@ -142,112 +146,109 @@ } @Override - public UiBuilder render(final Conversation conversation, final UiBuilder participantsUi, final UiBuilder threadUi) { - final String id = viewIdMapper.conversationOf(conversation); - final boolean isTop = !conversation.hasAnchor(); - return isTop ? viewFactory.createTopConversationView(id, threadUi, participantsUi) - : viewFactory.createInlineConversationView(id, threadUi, participantsUi); + public UiBuilder render(Conversation conversation, ParticipantId participant) { + Profile profile = profileManager.getProfile(participant); + String id = viewIdMapper.participantOf(conversation, participant); + // Use ParticipantAvatarViewBuilder for avatars. + // Kune patch + // final ParticipantNameViewBuilder participantUi = ParticipantNameViewBuilder.create(id); + ParticipantAvatarViewBuilder participantUi = ParticipantAvatarViewBuilder.create(id); + participantUi.setAvatar(profile.getImageUrl()); + participantUi.setName(profile.getFullName()); + return participantUi; } - /** - */ @Override - public UiBuilder render( - final ConversationBlip blip, final IdentityMap<ConversationThread, UiBuilder> replies) { - return docRenderer.render(blip, replies); + public UiBuilder render(final ConversationThread thread, + final IdentityMap<ConversationBlip, UiBuilder> blipUis) { + HtmlClosure blipsUi = new HtmlClosure() { + @Override + public void outputHtml(SafeHtmlBuilder out) { + for (ConversationBlip blip : thread.getBlips()) { + UiBuilder blipUi = blipUis.get(blip); + // Not all blips are rendered. + if (blipUi != null) { + blipUi.outputHtml(out); + } + } + } + }; + String threadId = viewIdMapper.threadOf(thread); + String replyIndicatorId = viewIdMapper.replyIndicatorOf(thread); + UiBuilder builder = null; + if (thread.getConversation().getRootThread() == thread) { + ReplyBoxViewBuilder replyBoxBuilder = + ReplyBoxViewBuilder.create(replyIndicatorId); + builder = RootThreadViewBuilder.create(threadId, blipsUi, replyBoxBuilder); + } else { + ContinuationIndicatorViewBuilder indicatorBuilder = ContinuationIndicatorViewBuilder.create( + replyIndicatorId); + InlineThreadViewBuilder inlineBuilder = + InlineThreadViewBuilder.create(threadId, blipsUi, indicatorBuilder); + int read = readMonitor.getReadCount(thread); + int unread = readMonitor.getUnreadCount(thread); + inlineBuilder.setTotalBlipCount(read + unread); + inlineBuilder.setUnreadBlipCount(unread); + builder = inlineBuilder; + } + return builder; } @Override - public UiBuilder render(final ConversationBlip blip, final UiBuilder document, + public UiBuilder render(final ConversationBlip blip, UiBuilder document, final IdentityMap<ConversationThread, UiBuilder> anchorUis, final IdentityMap<Conversation, UiBuilder> nestedConversations) { - final UiBuilder threadsUi = new UiBuilder() { + UiBuilder threadsUi = new UiBuilder() { @Override - public void outputHtml(final SafeHtmlBuilder out) { - for (final ConversationThread thread : blip.getReplyThreads()) { + public void outputHtml(SafeHtmlBuilder out) { + for (ConversationThread thread : blip.getReplyThreads()) { anchorUis.get(thread).outputHtml(out); } } }; - final UiBuilder convsUi = new UiBuilder() { + UiBuilder convsUi = new UiBuilder() { @Override - public void outputHtml(final SafeHtmlBuilder out) { + public void outputHtml(SafeHtmlBuilder out) { // Order by conversation id. Ideally, the sort key would be creation // time, but that is not exposed in the conversation API. final List<Conversation> ordered = CollectionUtils.newArrayList(); nestedConversations.each(new ProcV<Conversation, UiBuilder>() { @Override - public void apply(final Conversation conv, final UiBuilder ui) { + public void apply(Conversation conv, UiBuilder ui) { ordered.add(conv); } }); Collections.sort(ordered, new Comparator<Conversation>() { @Override - public int compare(final Conversation o1, final Conversation o2) { + public int compare(Conversation o1, Conversation o2) { return o1.getId().compareTo(o2.getId()); } }); - final List<UiBuilder> orderedUis = CollectionUtils.newArrayList(); - for (final Conversation conv : ordered) { + List<UiBuilder> orderedUis = CollectionUtils.newArrayList(); + for (Conversation conv : ordered) { nestedConversations.get(conv).outputHtml(out); } } }; - final BlipMetaViewBuilder metaUi = BlipMetaViewBuilder.create(viewIdMapper.metaOf(blip), document); + BlipMetaViewBuilder metaUi = BlipMetaViewBuilder.create(viewIdMapper.metaOf(blip), document); blipPopulator.render(blip, metaUi); return BlipViewBuilder.create(viewIdMapper.blipOf(blip), metaUi, threadsUi, convsUi); } + /** + */ @Override - public UiBuilder render(final ConversationThread thread, - final IdentityMap<ConversationBlip, UiBuilder> blipUis) { - final HtmlClosure blipsUi = new HtmlClosure() { - @Override - public void outputHtml(final SafeHtmlBuilder out) { - for (final ConversationBlip blip : thread.getBlips()) { - final UiBuilder blipUi = blipUis.get(blip); - // Not all blips are rendered. - if (blipUi != null) { - blipUi.outputHtml(out); - } - } - } - }; - final String threadId = viewIdMapper.threadOf(thread); - final String replyIndicatorId = viewIdMapper.replyIndicatorOf(thread); - UiBuilder builder = null; - if (thread.getConversation().getRootThread() == thread) { - final ReplyBoxViewBuilder replyBoxBuilder = - ReplyBoxViewBuilder.create(replyIndicatorId); - builder = RootThreadViewBuilder.create(threadId, blipsUi, replyBoxBuilder); - } else { - final ContinuationIndicatorViewBuilder indicatorBuilder = ContinuationIndicatorViewBuilder.create( - replyIndicatorId); - final InlineThreadViewBuilder inlineBuilder = - InlineThreadViewBuilder.create(threadId, blipsUi, indicatorBuilder); - final int read = readMonitor.getReadCount(thread); - final int unread = readMonitor.getUnreadCount(thread); - inlineBuilder.setTotalBlipCount(read + unread); - inlineBuilder.setUnreadBlipCount(unread); - builder = inlineBuilder; - } - return builder; + public UiBuilder render( + ConversationBlip blip, IdentityMap<ConversationThread, UiBuilder> replies) { + return docRenderer.render(blip, replies); } @Override - public UiBuilder render(final ConversationThread thread, final UiBuilder threadR) { - final String id = EscapeUtils.htmlEscape(viewIdMapper.defaultAnchorOf(thread)); + public UiBuilder render(ConversationThread thread, UiBuilder threadR) { + String id = EscapeUtils.htmlEscape(viewIdMapper.defaultAnchorOf(thread)); return AnchorViewBuilder.create(id, threadR); } - - @Override - public UiBuilder render(final ConversationView wave, - final IdentityMap<Conversation, UiBuilder> conversations) { - // return the first conversation in the view. - // TODO(hearnden): select the 'best' conversation. - return conversations.isEmpty() ? null : getFirstConversation(conversations); - } } Modified: trunk/src/main/java/cc/kune/wave/client/KuneFullDomWaveRendererImpl.java =================================================================== --- trunk/src/main/java/cc/kune/wave/client/KuneFullDomWaveRendererImpl.java 2011-09-23 17:07:21 UTC (rev 1529) +++ trunk/src/main/java/cc/kune/wave/client/KuneFullDomWaveRendererImpl.java 2011-09-23 21:10:32 UTC (rev 1530) @@ -39,7 +39,7 @@ /** * Renders waves into HTML DOM, given a renderer that renders waves as HTML - * closures. + * closures. (this is in StatesTwo.java) * */ public final class KuneFullDomWaveRendererImpl implements DomRenderer { Modified: trunk/src/main/java/cc/kune/wave/client/KuneStagesProvider.java =================================================================== --- trunk/src/main/java/cc/kune/wave/client/KuneStagesProvider.java 2011-09-23 17:07:21 UTC (rev 1529) +++ trunk/src/main/java/cc/kune/wave/client/KuneStagesProvider.java 2011-09-23 21:10:32 UTC (rev 1530) @@ -54,27 +54,27 @@ private final static AsyncHolder<Object> HALT = new AsyncHolder<Object>() { @Override - public void call(final Accessor<Object> accessor) { + public void call(Accessor<Object> accessor) { // Never ready, so never notify the accessor. } }; + private final Element wavePanelElement; + private final LogicalPanel rootPanel; + private final WaveRef waveRef; private final RemoteViewServiceMultiplexer channel; - private boolean closed; private final IdGenerator idGenerator; + private final ProfileManager profiles; + private final WaveStore waveStore; private final boolean isNewWave; private final String localDomain; - private StageOne one; - private final ProfileManager profiles; - private final LogicalPanel rootPanel; - private final boolean showParticipantsPanel; - private StageThree three; + private boolean closed; + private StageOne one; private StageTwo two; + private StageThree three; private WaveContext wave; - private final Element wavePanelElement; - private final WaveRef waveRef; - private final WaveStore waveStore; + private boolean showParticipantsPanel; /** * @param wavePanelElement The dom element to become the wave panel @@ -86,9 +86,9 @@ * @param isNewWave true if the wave is a new client-created wave * @param idGenerator */ - public KuneStagesProvider(final Element wavePanelElement, final LogicalPanel rootPanel, final WaveRef waveRef, - final RemoteViewServiceMultiplexer channel, final IdGenerator idGenerator, final ProfileManager profiles, - final WaveStore store, final boolean isNewWave, final String localDomain, final boolean showParticipantsPanel) { + public KuneStagesProvider(Element wavePanelElement, LogicalPanel rootPanel, WaveRef waveRef, + RemoteViewServiceMultiplexer channel, IdGenerator idGenerator, ProfileManager profiles, + WaveStore store, boolean isNewWave, String localDomain, boolean showParticipantsPanel) { this.wavePanelElement = wavePanelElement; this.rootPanel = rootPanel; this.waveRef = waveRef; @@ -102,46 +102,29 @@ } @Override - protected AsyncHolder<StageOne> createStageOneLoader(final StageZero zero) { + protected AsyncHolder<StageZero> createStageZeroLoader() { + return haltIfClosed(super.createStageZeroLoader()); + } + + @Override + protected AsyncHolder<StageOne> createStageOneLoader(StageZero zero) { return haltIfClosed(new StageOne.DefaultProvider(zero) { @Override - protected LogicalPanel createWaveContainer() { - return rootPanel; - } - - @Override protected Element createWaveHolder() { return wavePanelElement; } - }); - } - - @Override - protected AsyncHolder<StageThree> createStageThreeLoader(final StageTwo two) { - return haltIfClosed(new StageThree.DefaultProvider(this.two = two) { @Override - protected void create(final Accessor<StageThree> whenReady) { - // Prepend an init wave flow onto the stage continuation. - super.create(new Accessor<StageThree>() { - @Override - public void use(final StageThree x) { - onStageThreeLoaded(x, whenReady); - } - }); + protected LogicalPanel createWaveContainer() { + return rootPanel; } - - @Override - protected String getLocalDomain() { - return localDomain; - } }); } @Override - // Kune patch - protected AsyncHolder<StageTwo> createStageTwoLoader(final StageOne one) { + protected AsyncHolder<StageTwo> createStageTwoLoader(StageOne one) { return haltIfClosed(new StageTwoProvider( this.one = one, waveRef.getWaveId(), channel, isNewWave, idGenerator, profiles) { + // Kune patch @Override protected DomRenderer createRenderer() { return KuneFullDomWaveRendererImpl.create(getConversations(), getProfileManager(), @@ -159,51 +142,67 @@ } @Override - protected AsyncHolder<StageZero> createStageZeroLoader() { - return haltIfClosed(super.createStageZeroLoader()); + protected AsyncHolder<StageThree> createStageThreeLoader(final StageTwo two) { + return haltIfClosed(new StageThree.DefaultProvider(this.two = two) { + @Override + protected void create(final Accessor<StageThree> whenReady) { + // Prepend an init wave flow onto the stage continuation. + super.create(new Accessor<StageThree>() { + @Override + public void use(StageThree x) { + onStageThreeLoaded(x, whenReady); + } + }); + } + + @Override + protected String getLocalDomain() { + return localDomain; + } + }); } - public void destroy() { - if (wave != null) { - waveStore.remove(wave); - wave = null; + private void onStageThreeLoaded(StageThree x, Accessor<StageThree> whenReady) { + if (closed) { + // Stop the loading process. + return; } - if (three != null) { - three.getEditActions().stopEditing(); - three = null; + three = x; + if (isNewWave) { + initNewWave(x); + } else { + handleExistingWave(x); } - if (two != null) { - two.getConnector().close(); - two = null; - } - if (one != null) { - one.getWavePanel().destroy(); - one = null; - } - closed = true; + wave = new WaveContext( + two.getWave(), two.getConversations(), two.getSupplement(), two.getReadMonitor()); + waveStore.add(wave); + whenReady.use(x); } - /** - * @return a halting provider if this stage is closed. Otherwise, returns the - * given provider. - */ - @SuppressWarnings("unchecked") // HALT is safe as a holder for any type - private <T> AsyncHolder<T> haltIfClosed(final AsyncHolder<T> provider) { - return closed ? (AsyncHolder<T>) HALT : provider; + private void initNewWave(StageThree three) { + // Do the new-wave flow. + ModelAsViewProvider views = two.getModelAsViewProvider(); + BlipQueueRenderer blipQueue = two.getBlipQueue(); + ConversationView wave = two.getConversations(); + + // Force rendering to finish. + blipQueue.flush(); + BlipView blipUi = views.getBlipView(wave.getRoot().getRootThread().getFirstBlip()); + three.getEditActions().startEditing(blipUi); } - private void handleExistingWave(final StageThree three) { + private void handleExistingWave(StageThree three) { // If there's blip reference then focus on that blip. - final String documentId = waveRef.getDocumentId(); + String documentId = waveRef.getDocumentId(); if (documentId != null) { - final ModelAsViewProvider views = two.getModelAsViewProvider(); - final BlipQueueRenderer blipQueue = two.getBlipQueue(); - final ConversationView wave = two.getConversations(); + ModelAsViewProvider views = two.getModelAsViewProvider(); + BlipQueueRenderer blipQueue = two.getBlipQueue(); + ConversationView wave = two.getConversations(); blipQueue.flush(); // Find conversation Conversation conversation; if (waveRef.hasWaveletId()) { - final String id = ModernIdSerialiser.INSTANCE.serialiseWaveletId(waveRef.getWaveletId()); + String id = ModernIdSerialiser.INSTANCE.serialiseWaveletId(waveRef.getWaveletId()); conversation = wave.getConversation(id); } else { // Unspecified wavelet means root. @@ -211,9 +210,9 @@ } if (conversation != null) { // Find selected blip. - final ConversationBlip blip = wave.getRoot().getBlip(documentId); + ConversationBlip blip = wave.getRoot().getBlip(documentId); if (blip != null) { - final BlipView blipUi = views.getBlipView(blip); + BlipView blipUi = views.getBlipView(blip); if (blipUi != null) { two.getStageOne().getFocusFrame().focus(blipUi); } @@ -222,32 +221,32 @@ } } - private void initNewWave(final StageThree three) { - // Do the new-wave flow. - final ModelAsViewProvider views = two.getModelAsViewProvider(); - final BlipQueueRenderer blipQueue = two.getBlipQueue(); - final ConversationView wave = two.getConversations(); - - // Force rendering to finish. - blipQueue.flush(); - final BlipView blipUi = views.getBlipView(wave.getRoot().getRootThread().getFirstBlip()); - three.getEditActions().startEditing(blipUi); - } - - private void onStageThreeLoaded(final StageThree x, final Accessor<StageThree> whenReady) { - if (closed) { - // Stop the loading process. - return; + public void destroy() { + if (wave != null) { + waveStore.remove(wave); + wave = null; } - three = x; - if (isNewWave) { - initNewWave(x); - } else { - handleExistingWave(x); + if (three != null) { + three.getEditActions().stopEditing(); + three = null; } - wave = new WaveContext( - two.getWave(), two.getConversations(), two.getSupplement(), two.getReadMonitor()); - waveStore.add(wave); - whenReady.use(x); + if (two != null) { + two.getConnector().close(); + two = null; + } + if (one != null) { + one.getWavePanel().destroy(); + one = null; + } + closed = true; } + + /** + * @return a halting provider if this stage is closed. Otherwise, returns the + * given provider. + */ + @SuppressWarnings("unchecked") // HALT is safe as a holder for any type + private <T> AsyncHolder<T> haltIfClosed(AsyncHolder<T> provider) { + return closed ? (AsyncHolder<T>) HALT : provider; + } } Modified: trunk/src/main/java/cc/kune/wave/client/KuneWaveProfileManager.java =================================================================== --- trunk/src/main/java/cc/kune/wave/client/KuneWaveProfileManager.java 2011-09-23 17:07:21 UTC (rev 1529) +++ trunk/src/main/java/cc/kune/wave/client/KuneWaveProfileManager.java 2011-09-23 21:10:32 UTC (rev 1530) @@ -31,7 +31,7 @@ /** * The Class KuneWaveProfileManager is a workaround to show avatars in kune - * while the Wave part is more mature + * while the Wave part is more mature (see in the future RemoteProfileManagerImpl) * */ public class KuneWaveProfileManager extends AbstractProfileManager<ProfileImpl> implements @@ -58,7 +58,7 @@ } @Override - public ProfileImpl getProfile(final ParticipantId participantId) { + public ProfileImpl getProfile(ParticipantId participantId) { ProfileImpl profile = profiles.get(participantId.getAddress()); if (profile == null) { @@ -73,4 +73,4 @@ profile.update(profile.getFirstName(), profile.getFullName(), avatar); } -} \ No newline at end of file +} Modified: trunk/src/main/java/cc/kune/wave/client/WebClient.java =================================================================== --- trunk/src/main/java/cc/kune/wave/client/WebClient.java 2011-09-23 17:07:21 UTC (rev 1529) +++ trunk/src/main/java/cc/kune/wave/client/WebClient.java 2011-09-23 21:10:32 UTC (rev 1530) @@ -282,7 +282,7 @@ } }); - setupConnectionIndicator(); + //setupConnectionIndicator(); // Done in StateManager // HistorySupport.init();
participants (1)
-
Vicente J. Ruiz Jurado