Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fix chat layout in Firefox, implement dummy mode for new action
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed May 9, 2012
1 parent 629935f commit 3052c7c
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 19 deletions.
Expand Up @@ -177,6 +177,7 @@ public void onFailure(Throwable caught)
@Override
public void onSuccess(PublishWorkspaceChatResult result)
{
// display.appendChat("timestamp", "dummy user", "dummy msg");
}
});
}
Expand Down
Expand Up @@ -15,6 +15,7 @@
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.SplitLayoutPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
Expand All @@ -33,7 +34,7 @@ interface WorkspaceUsersViewUiBinder extends UiBinder<SplitLayoutPanel, Workspac
@UiField
VerticalPanel userListPanel;

@UiField
@UiField(provided = true)
SplitLayoutPanel mainPanel;

@UiField
Expand All @@ -45,9 +46,13 @@ interface WorkspaceUsersViewUiBinder extends UiBinder<SplitLayoutPanel, Workspac
@UiField
PushButton sendButton;

@UiField
ScrollPanel chatRoomScrollPanel;

@Inject
public WorkspaceUsersView(final UiMessages uiMessages)
{
mainPanel = new SplitLayoutPanel(3);
initWidget(uiBinder.createAndBindUi(this));
sendButton.setText(uiMessages.sendLabel());
}
Expand Down Expand Up @@ -101,5 +106,7 @@ public void appendChat(String user, String timestamp, String msg)
{
chatRoom.add(new HTML("[" + timestamp + "] " + user + ": " + msg));
}

chatRoomScrollPanel.scrollToBottom();
}
}
Expand Up @@ -23,7 +23,7 @@
padding-left:2px;
}

.userListSection
.userListScrollPanel
{
border-right:2px solid #E0E8EE;
}
Expand Down Expand Up @@ -59,28 +59,45 @@

<g:SplitLayoutPanel ui:field="mainPanel">
<g:west size="150" min-size="20">
<g:ScrollPanel styleName="{style.userListSection}">
<g:ScrollPanel styleName="{style.userListScrollPanel}">
<g:VerticalPanel ui:field='userListPanel' styleName="{style.userListTable}" width="100%" />
</g:ScrollPanel>
</g:west>
<g:center>
<g:VerticalPanel styleName="{style.chatSection}">
<g:cell verticalAlignment="ALIGN_TOP">
<g:ScrollPanel styleName="{style.chatRoomScrollPanel}">
<g:VerticalPanel ui:field="chatRoom" styleName="{style.chatRoom}"/>
</g:ScrollPanel>
</g:cell>
<g:cell verticalAlignment="ALIGN_BOTTOM" height="14px">
<g:HorizontalPanel width="100%" spacing="3">
<g:LayoutPanel height="100%" width="100%">
<g:layer top="0px" bottom="24px">
<g:ScrollPanel styleName="{style.chatRoomScrollPanel}" ui:field="chatRoomScrollPanel">
<g:VerticalPanel ui:field="chatRoom" styleName="{style.chatRoom}"/>
</g:ScrollPanel>
</g:layer>
<g:layer bottom="2px" height="24px">
<g:HorizontalPanel width="100%" spacing="3">
<g:cell>
<g:TextBox styleName="{style.chatInput}" ui:field="chatInput"/>
</g:cell>
<g:cell width="40px">
<g:PushButton addStyleNames="{style.sendButton}" ui:field="sendButton"/>
</g:cell>
</g:HorizontalPanel>
</g:cell>
</g:VerticalPanel>
</g:layer>
</g:LayoutPanel>
<!-- <g:VerticalPanel styleName="{style.chatSection}"> -->
<!-- <g:cell verticalAlignment="ALIGN_TOP"> -->
<!-- <g:ScrollPanel styleName="{style.chatRoomScrollPanel}"> -->
<!-- <g:VerticalPanel ui:field="chatRoom" styleName="{style.chatRoom}"/> -->
<!-- </g:ScrollPanel> -->
<!-- </g:cell> -->
<!-- <g:cell verticalAlignment="ALIGN_BOTTOM" height="14px"> -->
<!-- <g:HorizontalPanel width="100%" spacing="3"> -->
<!-- <g:cell> -->
<!-- <g:TextBox styleName="{style.chatInput}" ui:field="chatInput"/> -->
<!-- </g:cell> -->
<!-- <g:cell width="40px"> -->
<!-- <g:PushButton addStyleNames="{style.sendButton}" ui:field="sendButton"/> -->
<!-- </g:cell> -->
<!-- </g:HorizontalPanel> -->
<!-- </g:cell> -->
<!-- </g:VerticalPanel> -->
</g:center>
</g:SplitLayoutPanel>

Expand Down
Expand Up @@ -54,6 +54,7 @@ public class TranslationPresenterTest
{

private static final String TEST_USERS_ONLINE_MESSAGE = "some users online";
private static final String TEST_HAS_JONINED_WORKSPACE_MESSAGE = "has joined workspace";
private static final String TEST_SHOW_OPTIONS_TOOLTIP = "tooltip to show options";
private static final String TEST_HIDE_OPTIONS_TOOLTIP = "tooltip to hide options";

Expand Down Expand Up @@ -349,18 +350,23 @@ public void updateParticipantsOnEnterWorkspace()


expect(mockMessages.nUsersOnline(participants.size())).andReturn(TEST_USERS_ONLINE_MESSAGE).anyTimes();
expect(mockMessages.hasJoinedWorkspace()).andReturn(TEST_HAS_JONINED_WORKSPACE_MESSAGE).once();
mockDisplay.setParticipantsTitle(TEST_USERS_ONLINE_MESSAGE);
expectLastCall().once(); // once for now

expect(mockWorkspaceUsersPresenter.getTranslatorsSize()).andReturn(2);

mockWorkspaceUsersPresenter.dispatchChatAction("bob", TEST_HAS_JONINED_WORKSPACE_MESSAGE);
expectLastCall();

mockWorkspaceUsersPresenter.addTranslator(new SessionId("sessionId1"), new Person(new PersonId("bob"), "Bob Smith", "http://www.gravatar.com/avatar/bob@zanata.org?d=mm&s=16"), null);
expectLastCall();

// simulate enter workspace event
EnterWorkspaceEvent event = createMock(EnterWorkspaceEvent.class);

expect(event.getSessionId()).andReturn(new SessionId("sessionId1"));
expect(event.getPerson()).andReturn(new Person(new PersonId("bob"), "Bob Smith", "http://www.gravatar.com/avatar/bob@zanata.org?d=mm&s=16"));
expect(mockWorkspaceUsersPresenter.getTranslatorsSize()).andReturn(2);
expect(event.getPerson()).andReturn(new Person(new PersonId("bob"), "Bob Smith", "http://www.gravatar.com/avatar/bob@zanata.org?d=mm&s=16")).times(2);

replay(mockDispatcher, mockDisplay, mockMessages, mockWorkspaceUsersPresenter, event);

Expand Down
@@ -1,5 +1,6 @@
package org.zanata.webtrans.client.presenter;

import static org.easymock.EasyMock.capture;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
Expand All @@ -13,8 +14,11 @@

import net.customware.gwt.presenter.client.EventBus;

import org.easymock.Capture;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.zanata.webtrans.client.events.PublishWorkspaceChatEvent;
import org.zanata.webtrans.client.events.PublishWorkspaceChatEventHandler;
import org.zanata.webtrans.client.events.TranslatorStatusUpdateEvent;
import org.zanata.webtrans.client.events.TranslatorStatusUpdateEventHandler;
import org.zanata.webtrans.client.presenter.WorkspaceUsersPresenter.Display;
Expand All @@ -27,6 +31,8 @@
import org.zanata.webtrans.shared.model.PersonId;
import org.zanata.webtrans.shared.model.PersonSessionDetails;

import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.HandlerRegistration;


Expand All @@ -42,19 +48,25 @@ public class WorkspaceUsersPresenterTest

Identity mockIdentity = createMock(Identity.class);
CachingDispatchAsync mockDispatcher = createMock(CachingDispatchAsync.class);

HasClickHandlers mockSendButton = createMock(HasClickHandlers.class);
WebTransMessages mockMessages = createMock(WebTransMessages.class);

Capture<ClickHandler> capturedSendButtonClickHandler = new Capture<ClickHandler>();

@BeforeMethod
public void resetMocks()
{
reset(mockDisplay, mockEventBus);
reset(mockDisplay, mockEventBus, mockSendButton);
workspaceUsersPresenter = new WorkspaceUsersPresenter(mockDisplay, mockEventBus, mockIdentity, mockDispatcher, mockMessages);
}

public void setEmptyUserList()
{
expect(mockDisplay.getSendButton()).andReturn(mockSendButton);
expect(mockSendButton.addClickHandler(capture(capturedSendButtonClickHandler))).andReturn(createMock(HandlerRegistration.class));

expect(mockEventBus.addHandler(eq(TranslatorStatusUpdateEvent.getType()), isA(TranslatorStatusUpdateEventHandler.class)) ).andReturn(createMock(HandlerRegistration.class));
expect(mockEventBus.addHandler(eq(PublishWorkspaceChatEvent.getType()), isA(PublishWorkspaceChatEventHandler.class))).andReturn(createMock(HandlerRegistration.class));
replay(mockDisplay, mockEventBus);

workspaceUsersPresenter.bind();
Expand All @@ -67,12 +79,16 @@ public void setNonEmptyUserList()
{
HasManageUserSession mockHasManageUserSession = createMock(HasManageUserSession.class);

expect(mockDisplay.getSendButton()).andReturn(mockSendButton);
expect(mockSendButton.addClickHandler(capture(capturedSendButtonClickHandler))).andReturn(createMock(HandlerRegistration.class));

expect(mockDisplay.addUser(new Person(new PersonId("person1"), "John Smith", "http://www.gravatar.com/avatar/john@zanata.org?d=mm&s=16"))).andReturn(mockHasManageUserSession);
expect(mockDisplay.addUser(new Person(new PersonId("person2"), "Smith John", "http://www.gravatar.com/avatar/smith@zanata.org?d=mm&s=16"))).andReturn(mockHasManageUserSession);
expect(mockDisplay.addUser(new Person(new PersonId("person3"), "Smohn Jith", "http://www.gravatar.com/avatar/smohn@zanata.org?d=mm&s=16"))).andReturn(mockHasManageUserSession);

expect(mockEventBus.addHandler(eq(TranslatorStatusUpdateEvent.getType()), isA(TranslatorStatusUpdateEventHandler.class)) ).andReturn(createMock(HandlerRegistration.class));
replay(mockDisplay, mockEventBus);
expect(mockEventBus.addHandler(eq(PublishWorkspaceChatEvent.getType()), isA(PublishWorkspaceChatEventHandler.class))).andReturn(createMock(HandlerRegistration.class));
replay(mockDisplay, mockEventBus, mockSendButton);

workspaceUsersPresenter.bind();

Expand All @@ -82,6 +98,6 @@ public void setNonEmptyUserList()
people.put(new SessionId("sessionId3"), new PersonSessionDetails(new Person(new PersonId("person3"), "Smohn Jith", "http://www.gravatar.com/avatar/smohn@zanata.org?d=mm&s=16"), null));
workspaceUsersPresenter.initUserList(people);

verify(mockDisplay, mockEventBus);
verify(mockDisplay, mockEventBus, mockSendButton);
}
}
Expand Up @@ -24,6 +24,8 @@
import org.zanata.webtrans.shared.rpc.GetTranslationMemoryResult;
import org.zanata.webtrans.shared.rpc.GetTranslatorList;
import org.zanata.webtrans.shared.rpc.GetTranslatorListResult;
import org.zanata.webtrans.shared.rpc.PublishWorkspaceChatAction;
import org.zanata.webtrans.shared.rpc.PublishWorkspaceChatResult;
import org.zanata.webtrans.shared.rpc.TransMemoryDetailsList;
import org.zanata.webtrans.shared.rpc.UpdateTransUnit;
import org.zanata.webtrans.shared.rpc.UpdateTransUnitResult;
Expand Down Expand Up @@ -122,6 +124,13 @@ else if (action instanceof GetGlossaryDetailsAction)
AsyncCallback<GetGlossaryDetailsResult> _callback = (AsyncCallback<GetGlossaryDetailsResult>) callback;
Scheduler.get().scheduleDeferred(new DummyGetGlossaryDetailsCommand(_action, _callback));
}

else if (action instanceof PublishWorkspaceChatAction)
{
final PublishWorkspaceChatAction _action = (PublishWorkspaceChatAction) action;
AsyncCallback<PublishWorkspaceChatResult> _callback = (AsyncCallback<PublishWorkspaceChatResult>) callback;
Scheduler.get().scheduleDeferred(new DummyPublishWorkspaceChatCommand(_action, _callback));
}
else
{
Log.warn("DummyDispatchAsync: ignoring action of " + action.getClass());
Expand Down
@@ -0,0 +1,31 @@
package org.zanata.webtrans.client.rpc;

import org.zanata.webtrans.shared.rpc.PublishWorkspaceChatAction;
import org.zanata.webtrans.shared.rpc.PublishWorkspaceChatResult;

import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class DummyPublishWorkspaceChatCommand implements Command
{

private final AsyncCallback<PublishWorkspaceChatResult> callback;
private final PublishWorkspaceChatAction action;

DummyPublishWorkspaceChatCommand(PublishWorkspaceChatAction action, AsyncCallback<PublishWorkspaceChatResult> callback)
{
this.callback = callback;
this.action = action;
}

@Override
public void execute()
{
Log.info("ENTER DummyPublishWorkspaceChatCommand.execute()");

callback.onSuccess(new PublishWorkspaceChatResult());
Log.info("EXIT PublishWorkspaceChatResult.execute()");

}
}

0 comments on commit 3052c7c

Please sign in to comment.