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

Commit

Permalink
Move 'refresh' page option to top right corner
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-sl-eng committed Oct 19, 2012
1 parent 1ba6ffd commit 158390e
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 59 deletions.
Expand Up @@ -98,6 +98,7 @@
import org.zanata.webtrans.client.view.TransUnitNavigationView;
import org.zanata.webtrans.client.view.TransUnitsTableDisplay;
import org.zanata.webtrans.client.view.TransUnitsTableView;
import org.zanata.webtrans.client.view.TranslationEditorDisplay;
import org.zanata.webtrans.client.view.TranslationEditorView;
import org.zanata.webtrans.client.view.TranslationMemoryDisplay;
import org.zanata.webtrans.client.view.TranslationView;
Expand Down Expand Up @@ -151,7 +152,7 @@ protected void configure()
bindPresenter(TransMemoryDetailsPresenter.class, TransMemoryDetailsDisplay.class, TransMemoryDetailsView.class);
bindPresenter(TransUnitNavigationPresenter.class, TransUnitNavigationDisplay.class, TransUnitNavigationView.class);
bindPresenter(EditorOptionsPresenter.class, EditorOptionsDisplay.class, EditorOptionsView.class);
bindPresenter(TranslationEditorPresenter.class, TranslationEditorPresenter.Display.class, TranslationEditorView.class);
bindPresenter(TranslationEditorPresenter.class, TranslationEditorDisplay.class, TranslationEditorView.class);
bindPresenter(ValidationOptionsPresenter.class, ValidationOptionsPresenter.Display.class, ValidationOptionsView.class);
bindPresenter(NotificationPresenter.class, NotificationDisplay.class, NotificationView.class);
bindPresenter(TransUnitsTablePresenter.class, TransUnitsTableDisplay.class, TransUnitsTableView.class);
Expand Down
Expand Up @@ -168,12 +168,6 @@ public void onUseCodeMirrorOptionChanged(Boolean useCodeMirrorChkValue)
}
}

@Override
public void refreshCurrentPage()
{
eventBus.fireEvent(RefreshPageEvent.EVENT);
}

@Override
protected void onUnbind()
{
Expand Down
Expand Up @@ -24,7 +24,10 @@
import org.zanata.webtrans.client.events.PageChangeEventHandler;
import org.zanata.webtrans.client.events.PageCountChangeEvent;
import org.zanata.webtrans.client.events.PageCountChangeEventHandler;
import org.zanata.webtrans.client.events.RefreshPageEvent;
import org.zanata.webtrans.client.ui.HasPager;
import org.zanata.webtrans.client.view.TranslationEditorDisplay;

import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.Widget;
Expand All @@ -34,36 +37,24 @@
import net.customware.gwt.presenter.client.widget.WidgetDisplay;
import net.customware.gwt.presenter.client.widget.WidgetPresenter;

public class TranslationEditorPresenter extends WidgetPresenter<TranslationEditorPresenter.Display> implements PageChangeEventHandler, PageCountChangeEventHandler
public class TranslationEditorPresenter extends WidgetPresenter<TranslationEditorDisplay> implements PageChangeEventHandler, PageCountChangeEventHandler, TranslationEditorDisplay.Listener
{

public interface Display extends WidgetDisplay
{

void setEditorView(Widget widget);

void setTransUnitNavigation(Widget widget);

void setFilterView(Widget filterView);

HasPager getPageNavigation();

boolean isPagerFocused();

}


private final TransUnitNavigationPresenter transUnitNavigationPresenter;
private final TransFilterPresenter transFilterPresenter;
private final TransUnitsTablePresenter transUnitsTablePresenter;


@Inject
public TranslationEditorPresenter(Display display, EventBus eventBus, TransUnitNavigationPresenter transUnitNavigationPresenter, TransFilterPresenter transFilterPresenter, TransUnitsTablePresenter transUnitsTablePresenter)
public TranslationEditorPresenter(TranslationEditorDisplay display, EventBus eventBus, TransUnitNavigationPresenter transUnitNavigationPresenter, TransFilterPresenter transFilterPresenter, TransUnitsTablePresenter transUnitsTablePresenter)
{
super(display, eventBus);
this.transUnitNavigationPresenter = transUnitNavigationPresenter;
this.transFilterPresenter = transFilterPresenter;
this.transUnitsTablePresenter = transUnitsTablePresenter;

display.setListener(this);
}

@Override
Expand Down Expand Up @@ -102,6 +93,12 @@ public void onPageCountChange(PageCountChangeEvent event)
{
display.getPageNavigation().setPageCount(event.getPageCount());
}

@Override
public void refreshCurrentPage()
{
eventBus.fireEvent(RefreshPageEvent.EVENT);
}

@Override
protected void onUnbind()
Expand Down
Expand Up @@ -463,5 +463,8 @@ public interface WebTransMessages extends Messages

@DefaultMessage("By message")
String byMessage();

@DefaultMessage("Refresh current page")
String refreshCurrentPage();

}
Expand Up @@ -33,7 +33,5 @@ interface Listener extends EnumRadioButtonGroup.SelectionChangeListener<NavOptio
void onShowErrorsOptionChanged(Boolean showErrorChkValue);

void onUseCodeMirrorOptionChanged(Boolean useCodeMirrorChkValue);

void refreshCurrentPage();
}
}
Expand Up @@ -79,8 +79,6 @@ public class EditorOptionsView extends Composite implements EditorOptionsDisplay
CheckBox showErrorChk;
@UiField
CheckBox useCodeMirrorChk; // TODO this is disabled and invisible to user. If codemirror works fine then remove this option.
@UiField
Label refreshCurrentPage;

private Listener listener;

Expand Down Expand Up @@ -209,12 +207,6 @@ public void onCodeMirrorOptionChanged(ValueChangeEvent<Boolean> event)
listener.onUseCodeMirrorOptionChanged(useCodeMirrorChk.getValue());
}

@UiHandler("refreshCurrentPage")
public void onRedrawCurrentPageClicked(ClickEvent event)
{
listener.refreshCurrentPage();
}

@Override
public void setListener(Listener listener)
{
Expand Down
Expand Up @@ -50,15 +50,6 @@
margin-right: 3px;
}

.clickable {
cursor: pointer;
padding: 3px;
}

.clickable:hover {
color: #add8e6;
}

</ui:style>

<g:LayoutPanel>
Expand Down Expand Up @@ -101,7 +92,6 @@
<g:Label ui:field="otherConfigHeader" styleName="sideMenuHeader"/>
<g:CheckBox ui:field="showErrorChk"><ui:msg>Show System Errors</ui:msg></g:CheckBox>
<g:CheckBox ui:field="useCodeMirrorChk" visible="false" enabled="false"><ui:msg>Use CodeMirror Editor</ui:msg></g:CheckBox>
<g:Label ui:field="refreshCurrentPage" styleName="{style.clickable} icon-arrows-cw"><ui:msg >Refresh current page</ui:msg></g:Label>
</g:VerticalPanel>
</g:layer>
</g:LayoutPanel>
Expand Down
@@ -0,0 +1,32 @@
package org.zanata.webtrans.client.view;

import net.customware.gwt.presenter.client.widget.WidgetDisplay;

import org.zanata.webtrans.client.ui.HasPager;

import com.google.gwt.user.client.ui.Widget;


/**
* @author aeng
*
*/
public interface TranslationEditorDisplay extends WidgetDisplay
{
void setEditorView(Widget widget);

void setTransUnitNavigation(Widget widget);

void setFilterView(Widget filterView);

HasPager getPageNavigation();

boolean isPagerFocused();

void setListener(Listener listener);

interface Listener
{
void refreshCurrentPage();
}
}
Expand Up @@ -20,23 +20,25 @@
*/
package org.zanata.webtrans.client.view;

import org.zanata.webtrans.client.presenter.TranslationEditorPresenter;
import org.zanata.webtrans.client.resources.Resources;
import org.zanata.webtrans.client.resources.WebTransMessages;
import org.zanata.webtrans.client.ui.HasPager;
import org.zanata.webtrans.client.ui.Pager;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;

public class TranslationEditorView extends Composite implements TranslationEditorPresenter.Display
public class TranslationEditorView extends Composite implements TranslationEditorDisplay
{

private static TranslationEditorViewUiBinder uiBinder = GWT.create(TranslationEditorViewUiBinder.class);
Expand All @@ -59,8 +61,11 @@ interface TranslationEditorViewUiBinder extends UiBinder<Widget, TranslationEdit

@UiField
LayoutPanel filterPanelContainer;

@UiField
InlineLabel refreshCurrentPage;

// private Widget filterView;
private Listener listener;

@Inject
public TranslationEditorView(final WebTransMessages messages, final Resources resources)
Expand All @@ -69,6 +74,8 @@ public TranslationEditorView(final WebTransMessages messages, final Resources re
this.pager = new Pager(messages, resources);

initWidget(uiBinder.createAndBindUi(this));

refreshCurrentPage.setTitle(messages.refreshCurrentPage());
}

@Override
Expand Down Expand Up @@ -119,4 +126,16 @@ public boolean isPagerFocused()
{
return pager.isFocused();
}

@UiHandler("refreshCurrentPage")
public void onRedrawCurrentPageClicked(ClickEvent event)
{
listener.refreshCurrentPage();
}

public void setListener(Listener listener)
{
this.listener = listener;
}

}
Expand Up @@ -31,6 +31,17 @@
border-bottom:1px solid lightGrey;
background:#F3F2F2;
}

.refresh
{
font-size:20px;
cursor:pointer;
}

.refresh:hover
{
color:#0085CC;
}

</ui:style>

Expand All @@ -43,6 +54,9 @@
<g:layer width="45%" right="40px" top="9px" height="20px">
<g:HTMLPanel ui:field="transUnitNavigationContainer" styleName="{style.centerText}"/>
</g:layer>
<g:layer width="20px" right="8px" top="9px" height="20px">
<g:InlineLabel ui:field="refreshCurrentPage" styleName="icon-arrows-cw {style.refresh}"/>
</g:layer>
</g:LayoutPanel>
</g:layer>

Expand Down
Expand Up @@ -20,7 +20,6 @@
*/
package org.zanata.webtrans.client.view;

import org.zanata.webtrans.client.presenter.TranslationEditorPresenter;
import org.zanata.webtrans.client.presenter.TranslationPresenter;
import org.zanata.webtrans.client.resources.Resources;
import org.zanata.webtrans.client.resources.WebTransMessages;
Expand Down Expand Up @@ -65,7 +64,7 @@ interface TranslationViewUiBinder extends UiBinder<LayoutPanel, TranslationView>
private final static int ANIMATE_DURATION = 200;

@Inject
public TranslationView(Resources resources, WebTransMessages messages, TranslationEditorPresenter.Display translationEditorView, TranslationMemoryDisplay transMemoryView, GlossaryDisplay glossaryView)
public TranslationView(Resources resources, WebTransMessages messages, TranslationEditorDisplay translationEditorView, TranslationMemoryDisplay transMemoryView, GlossaryDisplay glossaryView)
{

StyleInjector.inject(resources.style().getText(), true);
Expand Down
Expand Up @@ -216,12 +216,4 @@ public void onShowErrorOptionChange()
assertThat(configHolder.isShowError(), Matchers.equalTo(true));
verifyZeroInteractions(eventBus);
}

@Test
public void onRefreshCurrentPage()
{
presenter.refreshCurrentPage();

verify(eventBus).fireEvent(RefreshPageEvent.EVENT);
}
}
Expand Up @@ -8,10 +8,12 @@
import org.testng.annotations.Test;
import org.zanata.webtrans.client.events.PageChangeEvent;
import org.zanata.webtrans.client.events.PageCountChangeEvent;
import org.zanata.webtrans.client.events.RefreshPageEvent;
import org.zanata.webtrans.client.ui.HasPager;
import org.zanata.webtrans.client.view.TransFilterDisplay;
import org.zanata.webtrans.client.view.TransUnitNavigationDisplay;
import org.zanata.webtrans.client.view.TransUnitsTableDisplay;
import org.zanata.webtrans.client.view.TranslationEditorDisplay;

import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
Expand All @@ -28,7 +30,7 @@ public class TranslationEditorPresenterTest
{
private TranslationEditorPresenter presenter;
@Mock
private TranslationEditorPresenter.Display display;
private TranslationEditorDisplay display;
@Mock
private EventBus eventBus;
@Mock
Expand Down Expand Up @@ -130,4 +132,12 @@ public void onUnbind()
verify(transUnitsTablePresenter).unbind();
verify(transUnitNavigationPresenter).unbind();
}

@Test
public void onRefreshCurrentPage()
{
presenter.refreshCurrentPage();

verify(eventBus).fireEvent(RefreshPageEvent.EVENT);
}
}
Expand Up @@ -17,6 +17,7 @@
import org.zanata.webtrans.client.keys.ShortcutContext;
import org.zanata.webtrans.client.resources.WebTransMessages;
import org.zanata.webtrans.client.service.NavigationService;
import org.zanata.webtrans.client.view.TranslationEditorDisplay;
import org.zanata.webtrans.shared.model.TransUnit;
import org.zanata.webtrans.shared.model.UserWorkspaceContext;
import com.google.gwt.event.dom.client.KeyCodes;
Expand Down Expand Up @@ -62,7 +63,7 @@ public class TranslationPresenterTest
@Captor
private ArgumentCaptor<KeyShortcut> keyShortcutCaptor;
@Mock
private TranslationEditorPresenter.Display translationEditorDisplay;
private TranslationEditorDisplay translationEditorDisplay;

@BeforeMethod
public void beforeMethod()
Expand Down

0 comments on commit 158390e

Please sign in to comment.