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

Commit

Permalink
Implemented layout selection option
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed May 29, 2012
1 parent 1e7e977 commit dc15823
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 15 deletions.
Expand Up @@ -87,6 +87,8 @@ public interface Display extends net.customware.gwt.presenter.client.widget.Widg
HasClickHandlers getErrorNotificationBtn();

void setErrorNotificationText(int count);

void setLayoutMenuVisible(boolean visible);
}

private final KeyShortcutPresenter keyShortcutPresenter;
Expand Down Expand Up @@ -412,13 +414,15 @@ private void showView(MainView viewToShow)
}
currentDisplayStats = selectedDocumentStats;
searchResultsPresenter.concealDisplay();
display.setLayoutMenuVisible(true);
break;
case Search:
// these two lines temporarily here until PresenterRevealedHandler is
// fully functional
display.setDocumentLabel("", messages.projectWideSearchAndReplace());
currentDisplayStats = projectStats;
searchResultsPresenter.revealDisplay();
display.setLayoutMenuVisible(false);
break;
case Documents:
default:
Expand All @@ -427,6 +431,7 @@ private void showView(MainView viewToShow)
display.setDocumentLabel("", messages.noDocumentSelected());
currentDisplayStats = projectStats;
searchResultsPresenter.concealDisplay();
display.setLayoutMenuVisible(false);
break;
}
display.showInMainView(viewToShow);
Expand Down
Expand Up @@ -107,4 +107,10 @@ public interface Resources extends ClientBundle

@Source("images/crystal_project/_16x16/actions/view_choose.png")
ImageResource viewChoose();

@Source("images/crystal_project/_16x16/actions/help.png")
ImageResource help();

@Source("images/crystal_project/_16x16/actions/logout.png")
ImageResource logout();
}
Expand Up @@ -51,6 +51,7 @@
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.MenuItemSeparator;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
Expand Down Expand Up @@ -109,15 +110,15 @@ interface Styles extends CssResource
@UiField
Anchor searchAndReplace;

MenuBar menuBar;

MenuItem helpMenuItem;

MenuItem leaveWorkspaceMenuItem;

MenuItem signOutMenuItem;

MenuItem layoutMenuItem;

MenuItemSeparator layoutMenuSeperator;

// TODO may be able to make these provided=true widgets
private Widget documentListView;
Expand Down Expand Up @@ -223,20 +224,27 @@ public HasClickHandlers getDocumentsLink()
@Override
public void initMenuList(String userLabel, Command helpMenuCommand, Command leaveWorkspaceMenuCommand, Command signOutMenuCommand, Command layoutMenuCommand)
{
menuBar = new MenuBar(true);
helpMenuItem = new MenuItem(messages.help(), helpMenuCommand);
leaveWorkspaceMenuItem = new MenuItem(messages.leaveWorkspace(), leaveWorkspaceMenuCommand);
signOutMenuItem = new MenuItem(messages.signOut(), signOutMenuCommand);
MenuBar menuBar = new MenuBar(true);

menuBar.addItem(helpMenuItem);
menuBar.addSeparator();
ImageLabel helpImageLabel = new ImageLabel(resources.help(), messages.help());
helpImageLabel.setImageStyle(style.image());

ImageLabel layoutImageLabel = new ImageLabel(resources.viewChoose(), messages.viewSelection());
layoutMenuItem = menuBar.addItem(layoutImageLabel.getElement().getInnerHTML(), true, layoutMenuCommand);
layoutImageLabel.setImageStyle(style.image());

ImageLabel signOutImageLabel = new ImageLabel(resources.logout(), messages.signOut());
signOutImageLabel.setImageStyle(style.image());

helpMenuItem = menuBar.addItem(helpImageLabel.getElement().getString(), true, helpMenuCommand);
menuBar.addSeparator();

layoutMenuItem = menuBar.addItem(layoutImageLabel.getElement().getString(), true, layoutMenuCommand);
layoutMenuSeperator = menuBar.addSeparator();

leaveWorkspaceMenuItem = new MenuItem(messages.leaveWorkspace(), leaveWorkspaceMenuCommand);
menuBar.addItem(leaveWorkspaceMenuItem);
menuBar.addItem(signOutMenuItem);

signOutMenuItem = menuBar.addItem(signOutImageLabel.getElement().getString(), true, signOutMenuCommand);

ImageLabel userMenu = new ImageLabel(userAvatarUrl, userLabel + " " + messages.downArrow());
userMenu.setLabelStyle(style.userName());
Expand Down Expand Up @@ -308,6 +316,13 @@ public HasClickHandlers getErrorNotificationBtn()
return errorNotificationBtn;
}

@Override
public void setLayoutMenuVisible(boolean visible)
{
layoutMenuItem.setVisible(visible);
layoutMenuSeperator.setVisible(visible);
}

@Override
public void setErrorNotificationText(int count)
{
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -244,7 +244,8 @@ public void testUpdateProjectStatsFromEditorView()

expectLoadDocAndViewEditor();
expectViewTransitionFromEditorToDoclist(newProjectStats);

mockDisplay.setLayoutMenuVisible(true);
expectLastCall().once();
replayAllMocks();

appPresenter.bind();
Expand All @@ -263,6 +264,7 @@ public void testHistoryTriggersDocumentSelectionEvent()
expectLastCall().anyTimes();
mockDisplay.setStats(notNull(TranslationStats.class));
expectLastCall().anyTimes();

expect(mockDocumentListPresenter.getDocumentId(TEST_DOCUMENT_PATH + TEST_DOCUMENT_NAME)).andReturn(testDocId).anyTimes();

replayAllMocks();
Expand Down Expand Up @@ -292,7 +294,8 @@ public void testHistoryTriggersViewChange()
expectLastCall().anyTimes();
mockDisplay.setStats(notNull(TranslationStats.class));
expectLastCall().anyTimes();

mockDisplay.setLayoutMenuVisible(true);
expectLastCall().once();
replayAllMocks();

appPresenter.bind();
Expand All @@ -308,6 +311,7 @@ public void testNoEditorWithoutValidDocument()
{
// return invalid document
expect(mockDocumentListPresenter.getDocumentId(notNull(String.class))).andReturn(null).anyTimes();

// not expecting show view editor
replayAllMocks();

Expand All @@ -330,6 +334,9 @@ public void testHistoryTriggersDocumentNameStatsUpdate()
expectLastCall().once();
mockDisplay.setStats(eq(testDocStats));
expectLastCall().once();
mockDisplay.setLayoutMenuVisible(true);
expectLastCall().once();

replayAllMocks();

appPresenter.bind();
Expand All @@ -350,7 +357,8 @@ public void testStatsAndNameChangeWithView()
expectLoadDocAndViewEditor();
expectViewTransitionFromEditorToDoclist(emptyProjectStats);
expectReturnToEditorView(testDocStats);

mockDisplay.setLayoutMenuVisible(true);
expectLastCall().anyTimes();
replayAllMocks();
appPresenter.bind();
HistoryToken token = simulateLoadDocAndViewEditor();
Expand All @@ -366,6 +374,9 @@ public void testStatsAndNameChangeForSearchPageView()
expectViewTransitionFromEditor(MainView.Search, emptyProjectStats, SEARCH_PAGE_LABEL);
expectReturnToEditorView(testDocStats);

mockDisplay.setLayoutMenuVisible(true);
expectLastCall().anyTimes();

replayAllMocks();
appPresenter.bind();
HistoryToken token = simulateLoadDocAndViewEditor();
Expand All @@ -380,6 +391,10 @@ public void testShowsUpdatedDocumentStats()
expectLoadDocAndViewEditor();
mockDisplay.setStats(eq(updatedStats));
expectLastCall().once();

mockDisplay.setLayoutMenuVisible(true);
expectLastCall().once();

replayAllMocks();

appPresenter.bind();
Expand All @@ -395,6 +410,9 @@ public void testDoesNotShowWrongDocumentStats()
TranslationStats updatedStats = new TranslationStats(new TransUnitCount(9, 9, 9), new TransUnitWords(9, 9, 9));
DocumentId notSelectedDocId = new DocumentId(7777L);

mockDisplay.setLayoutMenuVisible(true);
expectLastCall().once();

expectLoadDocAndViewEditor();
replayAllMocks();

Expand All @@ -412,6 +430,8 @@ public void testUpdateDocumentStatsFromDoclistView()
expectLoadDocAndViewEditor();
expectViewTransitionFromEditorToDoclist(emptyProjectStats);
expectReturnToEditorView(updatedStats);
mockDisplay.setLayoutMenuVisible(true);
expectLastCall().anyTimes();
replayAllMocks();

appPresenter.bind();
Expand All @@ -431,7 +451,6 @@ public void testDismiss()
mockDismissVisibility.setVisible(true); // visible upon message
mockDisplay.setNotificationMessage("", Severity.Info);
mockDismissVisibility.setVisible(false); // invisible upon clear

replayAllMocks();
appPresenter.bind();
NotificationEvent notification = new NotificationEvent(Severity.Warning, testMessage);
Expand Down Expand Up @@ -490,8 +509,9 @@ public void testDocumentsLinkGeneratesHistoryToken()
// NOTE not expecting return to editor view as this test does not simulate
// the event for the new history item

replayAllMocks();
mockDisplay.setLayoutMenuVisible(true);

replayAllMocks();

appPresenter.bind();
//discard captured tokens from bind to allow easy check for new token
Expand Down Expand Up @@ -532,6 +552,7 @@ public void testSearchLinkGeneratesHistoryToken()
{
ClickEvent searchLinkClickEvent = createMock(ClickEvent.class);
expect(mockHistory.getToken()).andReturn("").once();

replayAllMocks();
appPresenter.bind();
//simulate click
Expand Down Expand Up @@ -729,6 +750,9 @@ private void setupDefaultMockExpectations()
expectLastCall().anyTimes();
mockEventBus.fireEvent(and(capture(capturedDocumentSelectionEvent), isA(DocumentSelectionEvent.class)));
expectLastCall().anyTimes();

mockDisplay.setLayoutMenuVisible(false);
expectLastCall().anyTimes();
}

/**
Expand Down

0 comments on commit dc15823

Please sign in to comment.