[kune-commits] r1518 - in trunk/src/main/java: cc/kune/core/client/errors cc/kune/gspace/client/viewers cc/kune/wave/client org/ourproject/kune/chat
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Wed Sep 14 13:56:30 CEST 2011
Author: vjrj_
Date: 2011-09-14 13:56:30 +0200 (Wed, 14 Sep 2011)
New Revision: 1518
Added:
trunk/src/main/java/cc/kune/wave/client/WaveClientProvider.java
trunk/src/main/java/cc/kune/wave/client/WaveClientView.java
trunk/src/main/java/cc/kune/wave/client/WebClientMock.java
Removed:
trunk/src/main/java/org/ourproject/kune/chat/client/
Modified:
trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java
trunk/src/main/java/cc/kune/gspace/client/viewers/ContentViewerPanel.java
trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java
trunk/src/main/java/cc/kune/wave/client/WaveGinModule.java
trunk/src/main/java/cc/kune/wave/client/WebClient.java
Log:
NEW - # 125: Make a mock of the WaveClient to make the development not so heavy
http://kune.ourproject.org/issues/ticket/125
Modified: trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java 2011-09-11 19:59:15 UTC (rev 1517)
+++ trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java 2011-09-14 11:56:30 UTC (rev 1518)
@@ -32,11 +32,12 @@
import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
import cc.kune.core.shared.i18n.I18nTranslationService;
-import cc.kune.wave.client.WebClient;
+import cc.kune.wave.client.WaveClientView;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException;
import com.google.inject.Inject;
+import com.google.inject.Provider;
public class ErrorHandler {
@@ -44,14 +45,16 @@
private final I18nTranslationService i18n;
private final Session session;
private final StateManager stateManager;
+ private final Provider<WaveClientView> waveClient;
@Inject
public ErrorHandler(final Session session, final I18nTranslationService i18n,
- final StateManager stateManager, final EventBus eventBus) {
+ final StateManager stateManager, final EventBus eventBus, final Provider<WaveClientView> waveClient) {
this.session = session;
this.i18n = i18n;
this.stateManager = stateManager;
this.eventBus = eventBus;
+ this.waveClient = waveClient;
}
public void doSessionExpired() {
@@ -145,7 +148,7 @@
i18n.t("Oops! Something has gone wrong with our servers. Retry later, please.")));
final String error = "Other kind of exception in StateManagerDefault/processErrorException";
Log.error(error, caught);
- WebClient.ErrorHandler.getStackTraceAsync(caught, new Accessor<SafeHtml>() {
+ waveClient.get().getStackTraceAsync(caught, new Accessor<SafeHtml>() {
@Override
public void use(final SafeHtml stack) {
NotifyUser.logError(stack.asString().replace("<br>", "\n"));
Modified: trunk/src/main/java/cc/kune/gspace/client/viewers/ContentViewerPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/viewers/ContentViewerPanel.java 2011-09-11 19:59:15 UTC (rev 1517)
+++ trunk/src/main/java/cc/kune/gspace/client/viewers/ContentViewerPanel.java 2011-09-14 11:56:30 UTC (rev 1518)
@@ -41,8 +41,9 @@
import cc.kune.gspace.client.viewers.ContentViewerPresenter.ContentViewerView;
import cc.kune.wave.client.KuneStagesProvider;
import cc.kune.wave.client.WaveClientClearEvent;
-import cc.kune.wave.client.WaveClientManager;
-import cc.kune.wave.client.WebClient;
+import cc.kune.wave.client.WaveClientProvider;
+import cc.kune.wave.client.WaveClientView;
+import cc.kune.wave.client.WebClientMock;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
@@ -81,7 +82,8 @@
private ProfileManager profiles;
/** The wave panel, if a wave is open. */
private KuneStagesProvider wave;
- private final WaveClientManager waveClient;
+ private final WaveClientProvider waveClientProv;
+
private ImplPanel waveHolder;
@UiField
@@ -89,16 +91,14 @@
private final WaveStore waveStore = new SimpleWaveStore();
- private WebClient webClient;
-
private final Widget widget;
@Inject
- public ContentViewerPanel(final GSpaceArmor wsArmor, final WaveClientManager waveClient,
+ public ContentViewerPanel(final GSpaceArmor wsArmor, final WaveClientProvider waveClient,
final ContentCapabilitiesRegistry capabilitiesRegistry, final I18nTranslationService i18n,
final EventBus eventBus) {
this.gsArmor = wsArmor;
- this.waveClient = waveClient;
+ this.waveClientProv = waveClient;
this.capabilitiesRegistry = capabilitiesRegistry;
widget = uiBinder.createAndBindUi(this);
contentTitle = new ContentTitleWidget(i18n, gsArmor, capabilitiesRegistry.getIconsRegistry());
@@ -156,7 +156,7 @@
private void initWaveClientIfNeeded() {
if (channel == null) {
- webClient = waveClient.getWebClient();
+ final WaveClientView webClient = waveClientProv.get();
loading = webClient.getLoading();
waveHolder = webClient.getWaveHolder();
channel = webClient.getChannel();
@@ -197,26 +197,30 @@
final WaveRef waveRef = getWaveRef(waveRefS);
initWaveClientIfNeeded();
-
- webClient.clear();
+ waveClientProv.get().clear();
waveClear();
waveHolderParent.add(waveHolder);
- // Release the display:none.
- // UIObject.setVisible(waveFrame.getElement(), true);
- waveHolder.getElement().appendChild(loading);
- final Element holder = waveHolder.getElement().appendChild(Document.get().createDivElement());
- final KuneStagesProvider wave = new KuneStagesProvider(holder, waveHolder, waveRef, channel,
- idGenerator, profiles, waveStore, isNewWave,
- org.waveprotocol.box.webclient.client.Session.get().getDomain(), true);
- this.wave = wave;
- wave.load(new Command() {
- @Override
- public void execute() {
- loading.removeFromParent();
- }
- });
+ if (waveClientProv.get() instanceof WebClientMock) {
+ // do nothing;
+ } else {
+ // real wave client
+ // Release the display:none.
+ // UIObject.setVisible(waveFrame.getElement(), true);
+ waveHolder.getElement().appendChild(loading);
+ final Element holder = waveHolder.getElement().appendChild(Document.get().createDivElement());
+ final KuneStagesProvider wave = new KuneStagesProvider(holder, waveHolder, waveRef, channel,
+ idGenerator, profiles, waveStore, isNewWave,
+ org.waveprotocol.box.webclient.client.Session.get().getDomain(), true);
+ this.wave = wave;
+ wave.load(new Command() {
+ @Override
+ public void execute() {
+ loading.removeFromParent();
+ }
+ });
+ }
}
private void setTitle(final StateContentDTO state, final boolean editable) {
Modified: trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java 2011-09-11 19:59:15 UTC (rev 1517)
+++ trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java 2011-09-14 11:56:30 UTC (rev 1518)
@@ -39,13 +39,13 @@
import com.google.inject.Inject;
public class WaveClientManager {
- private WebClient webClient;
+ private WaveClientView webClient;
@Inject
public WaveClientManager(final Session session, final StateManager stateManager,
final EventBus eventBus, final UserServiceAsync userService, final GSpaceArmor wsArmor,
final KuneWaveProfileManager profiles, final InboxCountPresenter inboxCount,
- final TokenMatcher tokenMatcher) {
+ final TokenMatcher tokenMatcher, final WaveClientProvider webclientView) {
session.onUserSignIn(true, new UserSignInHandler() {
@Override
public void onUserSignIn(final UserSignInEvent event) {
@@ -53,21 +53,20 @@
new AsyncCallbackSimple<WaveClientParams>() {
@Override
public void onSuccess(final WaveClientParams result) {
- // NotifyUser.info(result.getSessionJSON(), true);
setUseSocketIO(result.useSocketIO());
setSessionJSON(JsonUtils.safeEval(result.getSessionJSON()));
setClientFlags(JsonUtils.safeEval(result.getClientFlags()));
- // Only for testing:
final ForIsWidget userSpace = wsArmor.getUserSpace();
if (webClient == null) {
if (userSpace.getWidgetCount() > 0) {
userSpace.remove(0);
}
- webClient = new WebClient(eventBus, profiles, inboxCount, tokenMatcher);
+ webClient = webclientView.get();
userSpace.add(webClient);
} else {
+ // this is done with the first webclient creation above
webClient.login();
- webClient.setVisible(true);
+ webClient.asWidget().setVisible(true);
}
}
});
@@ -77,7 +76,7 @@
@Override
public void onUserSignOut(final UserSignOutEvent event) {
if (webClient != null) {
- webClient.setVisible(false);
+ webClient.asWidget().setVisible(false);
webClient.logout();
}
setUseSocketIO(false);
@@ -87,7 +86,7 @@
});
}
- public WebClient getWebClient() {
+ public WaveClientView getWebClient() {
return webClient;
}
Added: trunk/src/main/java/cc/kune/wave/client/WaveClientProvider.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WaveClientProvider.java (rev 0)
+++ trunk/src/main/java/cc/kune/wave/client/WaveClientProvider.java 2011-09-14 11:56:30 UTC (rev 1518)
@@ -0,0 +1,23 @@
+package cc.kune.wave.client;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+public class WaveClientProvider implements Provider<WaveClientView> {
+
+ private final Provider<? extends WaveClientView> webClientProv;
+
+ @Inject
+ public WaveClientProvider(final Provider<WebClient> webClient,
+ final Provider<WebClientMock> webClientMock) {
+ webClientProv = webClient;
+ // If you want not to load the Webclient Mock
+ // webClientProv = webClientMock;
+ }
+
+ @Override
+ public WaveClientView get() {
+ return webClientProv.get();
+ }
+
+}
Added: trunk/src/main/java/cc/kune/wave/client/WaveClientView.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WaveClientView.java (rev 0)
+++ trunk/src/main/java/cc/kune/wave/client/WaveClientView.java 2011-09-14 11:56:30 UTC (rev 1518)
@@ -0,0 +1,33 @@
+package cc.kune.wave.client;
+
+import org.waveprotocol.box.webclient.client.RemoteViewServiceMultiplexer;
+import org.waveprotocol.box.webclient.client.WaveWebSocketClient;
+import org.waveprotocol.wave.client.account.ProfileManager;
+import org.waveprotocol.wave.client.common.safehtml.SafeHtml;
+import org.waveprotocol.wave.client.common.util.AsyncHolder.Accessor;
+import org.waveprotocol.wave.client.widget.common.ImplPanel;
+
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.ui.IsWidget;
+
+public interface WaveClientView extends IsWidget {
+
+ void clear();
+
+ RemoteViewServiceMultiplexer getChannel();
+
+ Element getLoading();
+
+ ProfileManager getProfiles();
+
+ void getStackTraceAsync(Throwable caught, Accessor<SafeHtml> accessor);
+
+ ImplPanel getWaveHolder();
+
+ WaveWebSocketClient getWebSocket();
+
+ void login();
+
+ void logout();
+
+}
Modified: trunk/src/main/java/cc/kune/wave/client/WaveGinModule.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WaveGinModule.java 2011-09-11 19:59:15 UTC (rev 1517)
+++ trunk/src/main/java/cc/kune/wave/client/WaveGinModule.java 2011-09-14 11:56:30 UTC (rev 1518)
@@ -38,5 +38,8 @@
s(KuneWaveProfileManager.class);
s(InboxCountView.class, InboxCountPanel.class);
s(InboxCountPresenter.class);
+ s(WaveClientProvider.class);
+ s(WebClientMock.class);
+ s(WebClient.class);
}
}
Modified: trunk/src/main/java/cc/kune/wave/client/WebClient.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WebClient.java 2011-09-11 19:59:15 UTC (rev 1517)
+++ trunk/src/main/java/cc/kune/wave/client/WebClient.java 2011-09-14 11:56:30 UTC (rev 1518)
@@ -90,7 +90,7 @@
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
-public class WebClient extends Composite {
+public class WebClient extends Composite implements WaveClientView {
interface Binder extends UiBinder<DockLayoutPanel, WebClient> {
}
@@ -287,10 +287,12 @@
websocket.connect();
}
+ @Override
public void login() {
loginImpl();
}
+ @Override
public void logout() {
loggedInUser = null;
channel = null;
@@ -308,21 +310,26 @@
}
}
+ @Override
public RemoteViewServiceMultiplexer getChannel() {
return channel;
}
+ @Override
public Element getLoading() {
return loading;
}
+ @Override
public ProfileManager getProfiles() {
return profiles;
}
+ @Override
public ImplPanel getWaveHolder() {
return waveHolder;
}
+ at Override
public WaveWebSocketClient getWebSocket() {
return websocket;
}
@@ -487,4 +494,9 @@
}
});
}
+
+ @Override
+ public void getStackTraceAsync(Throwable caught, Accessor<SafeHtml> accessor) {
+ ErrorHandler.getStackTraceAsync(caught, accessor);
+ }
}
Added: trunk/src/main/java/cc/kune/wave/client/WebClientMock.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WebClientMock.java (rev 0)
+++ trunk/src/main/java/cc/kune/wave/client/WebClientMock.java 2011-09-14 11:56:30 UTC (rev 1518)
@@ -0,0 +1,67 @@
+package cc.kune.wave.client;
+
+import org.waveprotocol.box.webclient.client.RemoteViewServiceMultiplexer;
+import org.waveprotocol.box.webclient.client.WaveWebSocketClient;
+import org.waveprotocol.wave.client.account.ProfileManager;
+import org.waveprotocol.wave.client.common.safehtml.SafeHtml;
+import org.waveprotocol.wave.client.common.util.AsyncHolder.Accessor;
+import org.waveprotocol.wave.client.widget.common.ImplPanel;
+
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Label;
+
+public class WebClientMock extends Composite implements WaveClientView {
+
+ private static final String MOCK_MSG = "This is only a mock of the wave client, only to make development testing not so heavy";
+ private ImplPanel implPanel;
+
+ public WebClientMock() {
+ initWidget(new Label(MOCK_MSG));
+ }
+
+ @Override
+ public void clear() {
+ }
+
+ @Override
+ public RemoteViewServiceMultiplexer getChannel() {
+ return null;
+ }
+
+ @Override
+ public Element getLoading() {
+ return null;
+ }
+
+ @Override
+ public ProfileManager getProfiles() {
+ return null;
+ }
+
+ @Override
+ public void getStackTraceAsync(final Throwable caught, final Accessor<SafeHtml> accessor) {
+ }
+
+ @Override
+ public ImplPanel getWaveHolder() {
+ if (implPanel == null) {
+ implPanel = new ImplPanel("<span style='padding:20px;'>" + MOCK_MSG + "</span>");
+ }
+ return implPanel;
+ }
+
+ @Override
+ public WaveWebSocketClient getWebSocket() {
+ return null;
+ }
+
+ @Override
+ public void login() {
+ }
+
+ @Override
+ public void logout() {
+ }
+
+}
More information about the kune-commits
mailing list