diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/ReviewCommentDataProvider.java b/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/ReviewCommentDataProvider.java
deleted file mode 100644
index 87cd023aa4..0000000000
--- a/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/ReviewCommentDataProvider.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
- * @author tags. See the copyright.txt file in the distribution for a full
- * listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software 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 Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-
-package org.zanata.webtrans.client.presenter;
-
-import org.zanata.webtrans.client.view.ReviewCommentDisplay;
-import org.zanata.webtrans.shared.model.ReviewComment;
-import com.google.gwt.view.client.ListDataProvider;
-import com.google.inject.Singleton;
-
-/**
- * @author Patrick Huang pahuang@redhat.com
- */
-@Singleton
-public class ReviewCommentDataProvider extends ListDataProvider
-{
- public ReviewCommentDataProvider()
- {
- super(ReviewCommentDisplay.COMMENT_PROVIDES_KEY);
- }
-
- public void setLoading(boolean loading)
- {
- if (loading)
- {
- updateRowCount(0, false);
- }
- else
- {
- updateRowCount(getList().size(), true);
- }
- }
-}
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/ReviewCommentPresenter.java b/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/ReviewCommentPresenter.java
deleted file mode 100644
index 251342c8e5..0000000000
--- a/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/ReviewCommentPresenter.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
- * @author tags. See the copyright.txt file in the distribution for a full
- * listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software 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 Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-
-package org.zanata.webtrans.client.presenter;
-
-import org.zanata.webtrans.client.events.ReviewCommentEvent;
-import org.zanata.webtrans.client.events.ReviewCommentEventHandler;
-import org.zanata.webtrans.client.rpc.AbstractAsyncCallback;
-import org.zanata.webtrans.client.rpc.CachingDispatchAsync;
-import org.zanata.webtrans.client.service.GetTransUnitActionContextHolder;
-import org.zanata.webtrans.client.service.NavigationService;
-import org.zanata.webtrans.client.view.ReviewCommentDisplay;
-import org.zanata.webtrans.shared.model.TransUnit;
-import org.zanata.webtrans.shared.model.TransUnitId;
-import org.zanata.webtrans.shared.rpc.AddReviewCommentAction;
-import org.zanata.webtrans.shared.rpc.AddReviewCommentResult;
-import org.zanata.webtrans.shared.rpc.GetReviewCommentsAction;
-import org.zanata.webtrans.shared.rpc.GetReviewCommentsResult;
-import com.allen_sauer.gwt.log.client.Log;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-import net.customware.gwt.presenter.client.EventBus;
-import net.customware.gwt.presenter.client.widget.WidgetPresenter;
-
-/**
- * @author Patrick Huang pahuang@redhat.com
- */
-@Singleton
-public class ReviewCommentPresenter extends WidgetPresenter implements ReviewCommentDisplay.Listener, ReviewCommentEventHandler
-{
- private final ReviewCommentDisplay display;
- private final CachingDispatchAsync dispatcher;
- private final ReviewCommentDataProvider dataProvider;
- private final GetTransUnitActionContextHolder contextHolder;
- private final NavigationService navigationService;
- private TransUnitId transUnitId;
-
- @Inject
- public ReviewCommentPresenter(ReviewCommentDisplay display, EventBus eventBus, CachingDispatchAsync dispatcher, ReviewCommentDataProvider dataProvider, GetTransUnitActionContextHolder contextHolder, NavigationService navigationService)
- {
- super(display, eventBus);
- this.display = display;
- this.dispatcher = dispatcher;
- this.dataProvider = dataProvider;
- this.contextHolder = contextHolder;
- this.navigationService = navigationService;
-
- display.setListener(this);
- display.setDataProvider(dataProvider);
- }
-
- @Override
- protected void onBind()
- {
- eventBus.addHandler(ReviewCommentEvent.TYPE, this);
- }
-
- @Override
- public void onShowReviewComment(ReviewCommentEvent event)
- {
- this.transUnitId = event.getTransUnitId();
- Integer currentTargetVersion = navigationService.getByIdOrNull(transUnitId).getVerNum();
- display.setCurrentTargetVersion(currentTargetVersion);
- dataProvider.setLoading(true);
- dispatcher.execute(new GetReviewCommentsAction(transUnitId), new AbstractAsyncCallback()
- {
- @Override
- public void onSuccess(GetReviewCommentsResult result)
- {
- dataProvider.setList(result.getComments());
- dataProvider.setLoading(false);
- }
- });
- display.center();
- }
-
- @Override
- public void addComment(String content)
- {
- dispatcher.execute(new AddReviewCommentAction(transUnitId, content, contextHolder.getContext().getDocument().getId()), new AbstractAsyncCallback()
- {
- @Override
- public void onSuccess(AddReviewCommentResult result)
- {
- dataProvider.getList().add(result.getComment());
- display.clearInput();
- }
- });
- }
-
- @Override
- protected void onUnbind()
- {
- }
-
- @Override
- protected void onRevealDisplay()
- {
- }
-}
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TargetContentsPresenter.java b/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TargetContentsPresenter.java
index 60e04c81d9..c4e1338ab4 100644
--- a/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TargetContentsPresenter.java
+++ b/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TargetContentsPresenter.java
@@ -89,7 +89,6 @@ public class TargetContentsPresenter implements
private final TableEditorMessages messages;
private final SourceContentsPresenter sourceContentsPresenter;
private final TranslationHistoryPresenter historyPresenter;
- private final ReviewCommentPresenter reviewCommentPresenter;
private final Provider displayProvider;
private final EditorTranslators editorTranslators;
private final EditorKeyShortcuts editorKeyShortcuts;
@@ -115,9 +114,8 @@ public TargetContentsPresenter(Provider displayProvider,
UserWorkspaceContext userWorkspaceContext,
EditorKeyShortcuts editorKeyShortcuts,
TranslationHistoryPresenter historyPresenter,
- UserOptionsService userOptionsService,
- SaveAsApprovedConfirmationDisplay saveAsApprovedConfirmation,
- ReviewCommentPresenter reviewCommentPresenter)
+ UserOptionsService userOptionsService,
+ SaveAsApprovedConfirmationDisplay saveAsApprovedConfirmation)
// @formatter:on
{
this.displayProvider = displayProvider;
@@ -128,7 +126,6 @@ public TargetContentsPresenter(Provider displayProvider,
this.sourceContentsPresenter = sourceContentsPresenter;
this.editorKeyShortcuts = editorKeyShortcuts;
this.historyPresenter = historyPresenter;
- this.reviewCommentPresenter = reviewCommentPresenter;
this.historyPresenter.setCurrentValueHolder(this);
this.userOptionsService = userOptionsService;
this.saveAsApprovedConfirmation = saveAsApprovedConfirmation;
@@ -148,7 +145,6 @@ private void bindEventHandlers()
eventBus.addHandler(CopyDataToEditorEvent.getType(), this);
eventBus.addHandler(TransUnitEditEvent.getType(), this);
eventBus.addHandler(WorkspaceContextUpdateEvent.getType(), this);
- reviewCommentPresenter.bind();
}
public void savePendingChangesIfApplicable()
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TranslationHistoryPresenter.java b/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TranslationHistoryPresenter.java
index e6e3288d1b..64aa919760 100644
--- a/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TranslationHistoryPresenter.java
+++ b/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TranslationHistoryPresenter.java
@@ -10,6 +10,8 @@
import org.zanata.common.ContentState;
import org.zanata.webtrans.client.events.CopyDataToEditorEvent;
import org.zanata.webtrans.client.events.NotificationEvent;
+import org.zanata.webtrans.client.events.ReviewCommentEvent;
+import org.zanata.webtrans.client.events.ReviewCommentEventHandler;
import org.zanata.webtrans.client.resources.WebTransMessages;
import org.zanata.webtrans.client.rpc.AbstractAsyncCallback;
import org.zanata.webtrans.client.rpc.CachingDispatchAsync;
@@ -36,7 +38,8 @@
* @author Patrick Huang pahuang@redhat.com
*/
@Singleton
-public class TranslationHistoryPresenter extends WidgetPresenter implements TranslationHistoryDisplay.Listener
+public class TranslationHistoryPresenter extends WidgetPresenter
+ implements TranslationHistoryDisplay.Listener, ReviewCommentEventHandler
{
private final TranslationHistoryDisplay display;
private final EventBus eventBus;
@@ -60,6 +63,12 @@ public TranslationHistoryPresenter(TranslationHistoryDisplay display, EventBus e
display.setListener(this);
}
+ @Override
+ public void onShowReviewComment(ReviewCommentEvent event)
+ {
+ showTranslationHistory(event.getTransUnitId());
+ }
+
public void showTranslationHistory(final TransUnitId transUnitId)
{
this.transUnitId = transUnitId;
@@ -101,7 +110,7 @@ protected void displayEntries(TransHistoryItem latest, List ot
List newTargets = targetContentsPresenter.getNewTargets();
if (!Objects.equal(latest.getContents(), newTargets))
{
- all.add(new TransHistoryItem(messages.unsaved(), newTargets, ContentState.New, "You", new Date()));
+ all.add(new TransHistoryItem(messages.unsaved(), newTargets, ContentState.New, messages.you(), new Date()));
}
}
all.addAll(otherEntries);
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorButtonsWidget.java b/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorButtonsWidget.java
index d11795bbef..bcf719299f 100644
--- a/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorButtonsWidget.java
+++ b/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorButtonsWidget.java
@@ -1,7 +1,5 @@
package org.zanata.webtrans.client.ui;
-import org.zanata.common.ContentState;
-import org.zanata.webtrans.client.events.ReviewCommentEvent;
import org.zanata.webtrans.client.view.TargetContentsDisplay;
import org.zanata.webtrans.shared.model.TransUnitId;
import com.google.gwt.core.client.GWT;
@@ -15,12 +13,9 @@
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.SimplePanel;
-import net.customware.gwt.presenter.client.EventBus;
-
public class EditorButtonsWidget extends Composite
{
private static EditorButtonsWidgetUiBinder ourUiBinder = GWT.create(EditorButtonsWidgetUiBinder.class);
- private final EventBus eventBus;
@UiField
HTMLPanel buttons;
@@ -40,15 +35,12 @@ public class EditorButtonsWidget extends Composite
InlineLabel acceptIcon;
@UiField
InlineLabel rejectIcon;
- @UiField
- InlineLabel commentIcon;
private TargetContentsDisplay.Listener listener;
private TransUnitId id;
- public EditorButtonsWidget(EventBus eventBus)
+ public EditorButtonsWidget()
{
- this.eventBus = eventBus;
initWidget(ourUiBinder.createAndBindUi(this));
setDisplayReviewButtons(listener != null && listener.canReview());
setDisplayModifyTranslationButtons(listener != null && listener.canEditTranslation());
@@ -129,12 +121,6 @@ public void onReject(ClickEvent event)
event.stopPropagation();
}
- @UiHandler("commentIcon")
- public void onCommentClick(ClickEvent event)
- {
- eventBus.fireEvent(new ReviewCommentEvent(id));
- }
-
public void setListener(TargetContentsDisplay.Listener listener)
{
this.listener = listener;
@@ -142,15 +128,9 @@ public void setListener(TargetContentsDisplay.Listener listener)
setDisplayModifyTranslationButtons(listener.canEditTranslation());
}
- public void setIdAndState(TransUnitId id, ContentState state)
+ public void setId(TransUnitId id)
{
this.id = id;
- enableComment(state.isTranslated() || state.isRejectedOrFuzzy());
- }
-
- private void enableComment(boolean enable)
- {
- commentIcon.setVisible(enable);
}
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorButtonsWidget.ui.xml b/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorButtonsWidget.ui.xml
index ea44f13fc0..8ce0c6255f 100644
--- a/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorButtonsWidget.ui.xml
+++ b/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorButtonsWidget.ui.xml
@@ -21,7 +21,6 @@
-
\ No newline at end of file
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/view/ReviewCommentDisplay.java b/zanata-war/src/main/java/org/zanata/webtrans/client/view/ReviewCommentDisplay.java
deleted file mode 100644
index 0c8b33108a..0000000000
--- a/zanata-war/src/main/java/org/zanata/webtrans/client/view/ReviewCommentDisplay.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
- * @author tags. See the copyright.txt file in the distribution for a full
- * listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software 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 Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-
-package org.zanata.webtrans.client.view;
-
-import org.zanata.webtrans.shared.model.ReviewComment;
-import com.google.gwt.view.client.ListDataProvider;
-import com.google.gwt.view.client.ProvidesKey;
-import com.google.inject.ImplementedBy;
-
-import net.customware.gwt.presenter.client.widget.WidgetDisplay;
-
-@ImplementedBy(ReviewCommentView.class)
-public interface ReviewCommentDisplay extends WidgetDisplay
-{
- static final ProvidesKey COMMENT_PROVIDES_KEY = new ProvidesKey()
- {
- @Override
- public Object getKey(ReviewComment item)
- {
- return item.getId();
- }
- };
-
- void setDataProvider(ListDataProvider dataProvider);
-
- void setListener(Listener listener);
-
- void center();
-
- void clearInput();
-
- void setCurrentTargetVersion(Integer targetVersion);
-
- interface Listener
- {
- void addComment(String comment);
- }
-}
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/view/ReviewCommentView.java b/zanata-war/src/main/java/org/zanata/webtrans/client/view/ReviewCommentView.java
deleted file mode 100644
index ea5f04e7db..0000000000
--- a/zanata-war/src/main/java/org/zanata/webtrans/client/view/ReviewCommentView.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
- * @author tags. See the copyright.txt file in the distribution for a full
- * listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software 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 Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-
-package org.zanata.webtrans.client.view;
-
-import org.zanata.webtrans.client.resources.WebTransMessages;
-import org.zanata.webtrans.client.ui.CellTableResources;
-import org.zanata.webtrans.client.ui.DialogBoxCloseButton;
-import org.zanata.webtrans.client.util.DateUtil;
-import org.zanata.webtrans.shared.model.ReviewComment;
-import com.google.common.base.Objects;
-import com.google.gwt.cell.client.Cell;
-import com.google.gwt.cell.client.TextCell;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.Style;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.resources.client.CssResource;
-import com.google.gwt.uibinder.client.UiBinder;
-import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.user.cellview.client.CellTable;
-import com.google.gwt.user.cellview.client.Column;
-import com.google.gwt.user.cellview.client.SimplePager;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.HTMLPanel;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.view.client.ListDataProvider;
-import com.google.inject.Singleton;
-
-/**
- * @author Patrick Huang pahuang@redhat.com
- */
-@Singleton
-public class ReviewCommentView extends DialogBox implements ReviewCommentDisplay
-{
- private static final CellTableResources CELL_TABLE_RESOURCES = GWT.create(CellTableResources.class);
- private static AddReviewCommentViewUiBinder ourUiBinder = GWT.create(AddReviewCommentViewUiBinder.class);
-
- @UiField(provided = true)
- DialogBoxCloseButton closeButton;
- @UiField
- WebTransMessages messages;
- @UiField
- VerticalPanel commentsContainer;
- @UiField
- Styles style;
-
- private final CellTable commentTable;
- private Listener listener;
- private TextBox commentInputBox;
- private Integer currentTargetVersion;
-
- public ReviewCommentView()
- {
- super(true, true);
- closeButton = new DialogBoxCloseButton(this);
- HTMLPanel root = ourUiBinder.createAndBindUi(this);
- setGlassEnabled(true);
-
- commentTable = setUpTable();
-
- SimplePager simplePager = new SimplePager();
- simplePager.setDisplay(commentTable);
-
- commentsContainer.add(commentTable);
- commentsContainer.add(simplePager);
- commentsContainer.add(createCommentInput());
-
- setWidget(root);
- }
-
- private Widget createCommentInput()
- {
- FlowPanel panel = new FlowPanel();
- commentInputBox = new TextBox();
- panel.add(commentInputBox);
- Button addButton = new Button(messages.reviewComment(), new ClickHandler()
- {
- @Override
- public void onClick(ClickEvent event)
- {
- listener.addComment(commentInputBox.getValue());
- }
- });
- panel.add(addButton);
- return panel;
- }
-
- private CellTable setUpTable()
- {
- CellTable table = new CellTable(15, CELL_TABLE_RESOURCES, COMMENT_PROVIDES_KEY);
- table.setEmptyTableWidget(new Label(messages.noContent()));
- table.setLoadingIndicator(new Label(messages.loading()));
-
- Column commentColumn = createCommentColumn();
- Column commenterColumn = createCommenterColumn();
- Column commentedDateColumn = createCommentedDateColumn();
-
- table.addColumn(commenterColumn, messages.modifiedBy());
- table.setColumnWidth(commenterColumn, 10, Style.Unit.PCT);
-
- table.addColumn(commentedDateColumn, messages.modifiedDate());
- table.setColumnWidth(commentedDateColumn, 20, Style.Unit.PCT);
-
- table.addColumn(commentColumn, messages.reviewComment());
- table.setColumnWidth(commentColumn, 70, Style.Unit.PCT);
-
- return table;
- }
-
- private Column createCommentColumn()
- {
- return new Column(new TextCell())
- {
- @Override
- public String getValue(ReviewComment object)
- {
- return object.getComment();
- }
-
- @Override
- public String getCellStyleNames(Cell.Context context, ReviewComment object)
- {
- if (!Objects.equal(object.getTargetVersion(), currentTargetVersion))
- {
- return style.obsoleteComment();
- }
- return super.getCellStyleNames(context, object);
- }
- };
- }
-
- private static Column createCommenterColumn()
- {
- return new Column(new TextCell())
- {
- @Override
- public String getValue(ReviewComment item)
- {
- return item.getCommenterName();
- }
- };
- }
-
- private static Column createCommentedDateColumn()
- {
- return new Column(new TextCell())
- {
- @Override
- public String getValue(ReviewComment item)
- {
- return DateUtil.formatShortDate(item.getCreationDate());
- }
- };
- }
-
- @Override
- public void clearInput()
- {
- commentInputBox.setText("");
- }
-
- @Override
- public void setCurrentTargetVersion(Integer targetVersion)
- {
- this.currentTargetVersion = targetVersion;
- }
-
- @Override
- public void setDataProvider(ListDataProvider dataProvider)
- {
- dataProvider.addDataDisplay(commentTable);
- }
-
- @Override
- public void setListener(Listener listener)
- {
- this.listener = listener;
- }
-
- interface AddReviewCommentViewUiBinder extends UiBinder
- {
- }
-
- interface Styles extends CssResource
- {
-
- String obsoleteComment();
- }
-}
\ No newline at end of file
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/view/ReviewCommentView.ui.xml b/zanata-war/src/main/java/org/zanata/webtrans/client/view/ReviewCommentView.ui.xml
deleted file mode 100644
index 29fb1c892b..0000000000
--- a/zanata-war/src/main/java/org/zanata/webtrans/client/view/ReviewCommentView.ui.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
- .obsoleteComment
- {
- font-style: italic;
- text-decoration: line-through;
- }
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/view/TargetContentsView.java b/zanata-war/src/main/java/org/zanata/webtrans/client/view/TargetContentsView.java
index 4c94c49aee..f3116ef23f 100644
--- a/zanata-war/src/main/java/org/zanata/webtrans/client/view/TargetContentsView.java
+++ b/zanata-war/src/main/java/org/zanata/webtrans/client/view/TargetContentsView.java
@@ -86,7 +86,7 @@ public class TargetContentsView extends Composite implements TargetContentsDispl
public TargetContentsView(Provider validationMessagePanelViewProvider, EventBus eventBus)
{
this.eventBus = eventBus;
- buttons = new EditorButtonsWidget(eventBus);
+ buttons = new EditorButtonsWidget();
validationPanel = validationMessagePanelViewProvider.get();
rootPanel = binder.createAndBindUi(this);
editorGrid.addStyleName("TableEditorCell-Target-Table");
@@ -201,7 +201,7 @@ private void setCachedTU(TransUnit newTransUnit)
{
cachedValue = newTransUnit;
editorGrid.setStyleName(resolveStyleName(cachedValue.getStatus()));
- buttons.setIdAndState(cachedValue.getId(), cachedValue.getStatus());
+ buttons.setId(cachedValue.getId());
}
@Override
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/GetReviewCommentsHandler.java b/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/GetReviewCommentsHandler.java
deleted file mode 100644
index 735979a1e2..0000000000
--- a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/GetReviewCommentsHandler.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
- * @author tags. See the copyright.txt file in the distribution for a full
- * listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software 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 Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-
-package org.zanata.webtrans.server.rpc;
-
-import java.util.List;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.zanata.dao.TextFlowTargetReviewCommentsDAO;
-import org.zanata.model.HTextFlowTargetReviewComment;
-import org.zanata.webtrans.server.ActionHandlerFor;
-import org.zanata.webtrans.shared.model.ReviewComment;
-import org.zanata.webtrans.shared.model.ReviewCommentId;
-import org.zanata.webtrans.shared.rpc.GetReviewCommentsAction;
-import org.zanata.webtrans.shared.rpc.GetReviewCommentsResult;
-import com.google.common.base.Function;
-import com.google.common.collect.Lists;
-
-import net.customware.gwt.dispatch.server.ExecutionContext;
-import net.customware.gwt.dispatch.shared.ActionException;
-
-/**
- * @author Patrick Huang pahuang@redhat.com
- */
-@Name("webtrans.gwt.GetReviewCommentsHandler")
-@Scope(ScopeType.STATELESS)
-@ActionHandlerFor(GetReviewCommentsAction.class)
-public class GetReviewCommentsHandler extends AbstractActionHandler
-{
- @In
- private TextFlowTargetReviewCommentsDAO textFlowTargetReviewCommentsDAO;
-
- @Override
- public GetReviewCommentsResult execute(GetReviewCommentsAction action, ExecutionContext context) throws ActionException
- {
- List hComments = textFlowTargetReviewCommentsDAO.getReviewComments(action.getTransUnitId(), action.getWorkspaceId().getLocaleId());
-
- List comments = Lists.transform(hComments, new Function()
- {
- @Override
- public ReviewComment apply(HTextFlowTargetReviewComment input)
- {
- return new ReviewComment(new ReviewCommentId(input.getId()), input.getComment(), input.getCommenterName(), input.getCreationDate(), input.getTargetVersion());
- }
- });
- // we re-wrap the list because gwt rpc doesn't like other list implementation
- return new GetReviewCommentsResult(Lists.newArrayList(comments));
- }
-
- @Override
- public void rollback(GetReviewCommentsAction action, GetReviewCommentsResult result, ExecutionContext context) throws ActionException
- {
-
- }
-}
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/GetTranslationHistoryHandler.java b/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/GetTranslationHistoryHandler.java
index 7674183abf..2e18f474d1 100644
--- a/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/GetTranslationHistoryHandler.java
+++ b/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/GetTranslationHistoryHandler.java
@@ -101,7 +101,7 @@ private static String nameOrEmptyString(HPerson lastModifiedBy)
return lastModifiedBy != null ? lastModifiedBy.getName() : "";
}
- private List getReviewComments(GetTranslationHistoryAction action)
+ protected List getReviewComments(GetTranslationHistoryAction action)
{
List hComments = textFlowTargetReviewCommentsDAO.getReviewComments(action.getTransUnitId(), action.getWorkspaceId().getLocaleId());
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/GetReviewCommentsAction.java b/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/GetReviewCommentsAction.java
deleted file mode 100644
index d9928b9590..0000000000
--- a/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/GetReviewCommentsAction.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
- * @author tags. See the copyright.txt file in the distribution for a full
- * listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software 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 Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-
-package org.zanata.webtrans.shared.rpc;
-
-import org.zanata.webtrans.shared.model.TransUnitId;
-
-/**
- * @author Patrick Huang pahuang@redhat.com
- */
-public class GetReviewCommentsAction extends AbstractWorkspaceAction
-{
- private static final long serialVersionUID = 1L;
- private TransUnitId transUnitId;
-
- @SuppressWarnings("unused")
- public GetReviewCommentsAction()
- {
- }
-
- public GetReviewCommentsAction(TransUnitId transUnitId)
- {
- this.transUnitId = transUnitId;
- }
-
- public TransUnitId getTransUnitId()
- {
- return transUnitId;
- }
-}
diff --git a/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/GetReviewCommentsResult.java b/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/GetReviewCommentsResult.java
deleted file mode 100644
index 81e565617f..0000000000
--- a/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/GetReviewCommentsResult.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
- * @author tags. See the copyright.txt file in the distribution for a full
- * listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software 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 Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-
-package org.zanata.webtrans.shared.rpc;
-
-import java.util.List;
-
-import org.zanata.webtrans.shared.model.ReviewComment;
-
-/**
- * @author Patrick Huang pahuang@redhat.com
- */
-public class GetReviewCommentsResult implements DispatchResult
-{
- private static final long serialVersionUID = 1L;
- private List comments;
-
- @SuppressWarnings("unused")
- public GetReviewCommentsResult()
- {
- }
-
- public GetReviewCommentsResult(List comments)
- {
- this.comments = comments;
- }
-
- public List getComments()
- {
- return comments;
- }
-}
diff --git a/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/ReviewCommentPresenterTest.java b/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/ReviewCommentPresenterTest.java
deleted file mode 100644
index 08eb42371c..0000000000
--- a/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/ReviewCommentPresenterTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
- * @author tags. See the copyright.txt file in the distribution for a full
- * listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software 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 Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-
-package org.zanata.webtrans.client.presenter;
-
-import java.util.List;
-
-import org.hamcrest.Matchers;
-import org.mockito.Answers;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.zanata.webtrans.client.events.ReviewCommentEvent;
-import org.zanata.webtrans.client.rpc.CachingDispatchAsync;
-import org.zanata.webtrans.client.service.GetTransUnitActionContextHolder;
-import org.zanata.webtrans.client.service.NavigationService;
-import org.zanata.webtrans.client.view.ReviewCommentDisplay;
-import org.zanata.webtrans.shared.model.DocumentId;
-import org.zanata.webtrans.shared.model.ReviewComment;
-import org.zanata.webtrans.shared.model.TransUnitId;
-import org.zanata.webtrans.shared.rpc.AddReviewCommentAction;
-import org.zanata.webtrans.shared.rpc.AddReviewCommentResult;
-import org.zanata.webtrans.shared.rpc.GetReviewCommentsAction;
-import org.zanata.webtrans.shared.rpc.GetReviewCommentsResult;
-import com.google.common.collect.Lists;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-
-import net.customware.gwt.presenter.client.EventBus;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-/**
- * @author Patrick Huang pahuang@redhat.com
- */
-@Test(groups = "unit-tests")
-public class ReviewCommentPresenterTest
-{
- private ReviewCommentPresenter presenter;
- @Mock
- private ReviewCommentDisplay display;
- @Mock
- private EventBus eventBus;
- @Mock
- private CachingDispatchAsync dispather;
- @Mock
- private ReviewCommentDataProvider dataProvider;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private GetTransUnitActionContextHolder contextHolder;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private NavigationService navigationService;
-
-
- @BeforeMethod
- public void beforeMethod()
- {
- MockitoAnnotations.initMocks(this);
-
- presenter = new ReviewCommentPresenter(display, eventBus, dispather, dataProvider, contextHolder, navigationService);
-
- verify(display).setDataProvider(dataProvider);
- verify(display).setListener(presenter);
- }
- @Test
- public void testDisplayCommentView() throws Exception
- {
- // Given: trans unit id 1 and current target version 99
- TransUnitId transUnitId = new TransUnitId(1L);
- when(navigationService.getByIdOrNull(transUnitId).getVerNum()).thenReturn(99);
- ArgumentCaptor actionCaptor = ArgumentCaptor.forClass(GetReviewCommentsAction.class);
- ArgumentCaptor resultCaptor = ArgumentCaptor.forClass(AsyncCallback.class);
-
- // When:
- presenter.onShowReviewComment(new ReviewCommentEvent(transUnitId));
-
- // Then:
- verify(dataProvider).setLoading(true);
- verify(dispather).execute(actionCaptor.capture(), resultCaptor.capture());
- assertThat(actionCaptor.getValue().getTransUnitId(), Matchers.equalTo(transUnitId));
-
- AsyncCallback callback = resultCaptor.getValue();
- GetReviewCommentsResult result = new GetReviewCommentsResult(Lists.newArrayList(new ReviewComment()));
- callback.onSuccess(result);
-
- verify(display).setCurrentTargetVersion(99);
- verify(dataProvider).setLoading(false);
- verify(dataProvider).setList(result.getComments());
- }
-
- @Test
- public void testAddComment() throws Exception
- {
- when(contextHolder.getContext().getDocument().getId()).thenReturn(new DocumentId(1L, "doc"));
- ArgumentCaptor actionCaptor = ArgumentCaptor.forClass(AddReviewCommentAction.class);
- ArgumentCaptor resultCaptor = ArgumentCaptor.forClass(AsyncCallback.class);
- List mockList = mock(List.class);
- when(dataProvider.getList()).thenReturn(mockList);
-
- presenter.addComment("some comment");
-
- verify(dispather).execute(actionCaptor.capture(), resultCaptor.capture());
- assertThat(actionCaptor.getValue().getContent(), Matchers.equalTo("some comment"));
-
- AsyncCallback callback = resultCaptor.getValue();
- AddReviewCommentResult result = new AddReviewCommentResult(new ReviewComment());
- callback.onSuccess(result);
-
- verify(dataProvider).getList();
- verify(mockList).add(result.getComment());
- verify(display).clearInput();
- }
-}
diff --git a/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/TargetContentsPresenterTest.java b/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/TargetContentsPresenterTest.java
index f1e024dbda..a47c66b3cb 100644
--- a/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/TargetContentsPresenterTest.java
+++ b/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/TargetContentsPresenterTest.java
@@ -124,8 +124,6 @@ public class TargetContentsPresenterTest
private UserOptionsService userOptionsService;
@Mock
private SaveAsApprovedConfirmationDisplay saveAsApprovedConfirmation;
- @Mock
- private ReviewCommentPresenter reviewCommentPresenter;
@BeforeMethod
public void beforeMethod()
@@ -136,7 +134,7 @@ public void beforeMethod()
when(userOptionsService.getConfigHolder()).thenReturn(configHolder);
userWorkspaceContext = TestFixture.userWorkspaceContext();
- presenter = new TargetContentsPresenter(displayProvider, editorTranslators, eventBus, tableEditorMessages, sourceContentPresenter, userWorkspaceContext, editorKeyShortcuts, historyPresenter, userOptionsService, saveAsApprovedConfirmation, reviewCommentPresenter);
+ presenter = new TargetContentsPresenter(displayProvider, editorTranslators, eventBus, tableEditorMessages, sourceContentPresenter, userWorkspaceContext, editorKeyShortcuts, historyPresenter, userOptionsService, saveAsApprovedConfirmation);
verify(eventBus).addHandler(UserConfigChangeEvent.TYPE, presenter);
verify(eventBus).addHandler(RequestValidationEvent.getType(), presenter);
diff --git a/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/GetReviewCommentsHandlerTest.java b/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/GetReviewCommentsHandlerTest.java
deleted file mode 100644
index 59f9e7b9f8..0000000000
--- a/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/GetReviewCommentsHandlerTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
- * @author tags. See the copyright.txt file in the distribution for a full
- * listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software 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 Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-
-package org.zanata.webtrans.server.rpc;
-
-import org.hamcrest.Matchers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.zanata.common.ContentState;
-import org.zanata.common.LocaleId;
-import org.zanata.dao.TextFlowTargetReviewCommentsDAO;
-import org.zanata.model.HLocale;
-import org.zanata.model.HPerson;
-import org.zanata.model.HTextFlow;
-import org.zanata.model.HTextFlowTargetReviewComment;
-import org.zanata.model.TestFixture;
-import org.zanata.seam.SeamAutowire;
-import org.zanata.webtrans.shared.model.TransUnitId;
-import org.zanata.webtrans.shared.rpc.GetReviewCommentsAction;
-import org.zanata.webtrans.shared.rpc.GetReviewCommentsResult;
-
-import com.google.common.collect.Lists;
-
-import static org.hamcrest.MatcherAssert.*;
-import static org.mockito.Mockito.when;
-
-/**
- * @author Patrick Huang pahuang@redhat.com
- */
-@Test(groups = "unit-tests")
-public class GetReviewCommentsHandlerTest
-{
- private GetReviewCommentsHandler handler;
- @Mock
- private TextFlowTargetReviewCommentsDAO dao;
-
- @BeforeMethod
- public void setUp() throws Exception
- {
- MockitoAnnotations.initMocks(this);
-
- handler = SeamAutowire.instance().reset().use("textFlowTargetReviewCommentsDAO", dao).autowire(GetReviewCommentsHandler.class);
- }
-
- @Test
- public void testExecute() throws Exception
- {
- GetReviewCommentsAction action = new GetReviewCommentsAction(new TransUnitId(1L));
- action.setWorkspaceId(TestFixture.workspaceId());
- LocaleId localeId = action.getWorkspaceId().getLocaleId();
- when(dao.getReviewComments(action.getTransUnitId(), localeId)).thenReturn(Lists.newArrayList(makeCommentEntity(localeId, "a comment"), makeCommentEntity(localeId, "another comment")));
-
- GetReviewCommentsResult result = handler.execute(action, null);
-
- assertThat(result.getComments(), Matchers.hasSize(2));
- assertThat(result.getComments().get(0).getComment(), Matchers.equalTo("a comment"));
- assertThat(result.getComments().get(1).getComment(), Matchers.equalTo("another comment"));
-
- }
-
- private static HTextFlowTargetReviewComment makeCommentEntity(LocaleId localeId, String comment)
- {
- HLocale hLocale = new HLocale(localeId);
- TestFixture.setId(2L, hLocale);
-
- HTextFlow textFlow = TestFixture.makeHTextFlow(1L, hLocale, ContentState.Rejected);
-
- HPerson commenter = new HPerson();
- TestFixture.setId(3L, commenter);
-
- return new HTextFlowTargetReviewComment(textFlow.getTargets().get(hLocale.getId()), comment, commenter);
- }
-}
diff --git a/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/GetTranslationHistoryHandlerTest.java b/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/GetTranslationHistoryHandlerTest.java
index 47d89596b4..efcb4ba9a4 100644
--- a/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/GetTranslationHistoryHandlerTest.java
+++ b/zanata-war/src/test/java/org/zanata/webtrans/server/rpc/GetTranslationHistoryHandlerTest.java
@@ -2,6 +2,7 @@
import java.util.Date;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.hamcrest.Matchers;
@@ -9,30 +10,36 @@
import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import org.zanata.common.ContentState;
import org.zanata.common.LocaleId;
import org.zanata.common.ProjectType;
import org.zanata.dao.TextFlowDAO;
+import org.zanata.dao.TextFlowTargetReviewCommentsDAO;
import org.zanata.exception.ZanataServiceException;
import org.zanata.model.HLocale;
import org.zanata.model.HPerson;
import org.zanata.model.HTextFlow;
import org.zanata.model.HTextFlowTarget;
import org.zanata.model.HTextFlowTargetHistory;
+import org.zanata.model.HTextFlowTargetReviewComment;
+import org.zanata.model.TestFixture;
import org.zanata.seam.SeamAutowire;
import org.zanata.security.ZanataIdentity;
import org.zanata.service.LocaleService;
import org.zanata.webtrans.shared.model.ProjectIterationId;
+import org.zanata.webtrans.shared.model.ReviewComment;
import org.zanata.webtrans.shared.model.TransHistoryItem;
import org.zanata.webtrans.shared.model.TransUnitId;
import org.zanata.webtrans.shared.model.WorkspaceId;
import org.zanata.webtrans.shared.rpc.GetTranslationHistoryAction;
import org.zanata.webtrans.shared.rpc.GetTranslationHistoryResult;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.customware.gwt.dispatch.server.ExecutionContext;
import net.customware.gwt.dispatch.shared.ActionException;
-import static org.hamcrest.MatcherAssert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -57,6 +64,8 @@ public class GetTranslationHistoryHandlerTest
@Mock
private HLocale hLocale;
private LocaleId localeId = new LocaleId("en-US");
+ @Mock
+ private TextFlowTargetReviewCommentsDAO reviewCommentsDAO;
@BeforeMethod
public void beforeMethod()
@@ -67,6 +76,7 @@ public void beforeMethod()
.use("identity", identity)
.use("localeServiceImpl", localeService)
.use("textFlowDAO", textFlowDAO)
+ .use("textFlowTargetReviewCommentsDAO", reviewCommentsDAO)
.autowire(GetTranslationHistoryHandler.class);
// @formatter:on
action = new GetTranslationHistoryAction(transUnitId);
@@ -183,4 +193,34 @@ private static HTextFlowTargetHistory createHistory(HTextFlowTarget target)
targetHistory.setContents(target.getContents());
return targetHistory;
}
+
+ @Test
+ public void canGetReviewComments()
+ {
+ GetTranslationHistoryAction action = new GetTranslationHistoryAction(new TransUnitId(1L));
+ action.setWorkspaceId(TestFixture.workspaceId());
+ LocaleId localeId = action.getWorkspaceId().getLocaleId();
+ when(reviewCommentsDAO.getReviewComments(action.getTransUnitId(), localeId))
+ .thenReturn(Lists.newArrayList(
+ makeCommentEntity(localeId, "a comment"), makeCommentEntity(localeId, "another comment")));
+
+ List result = handler.getReviewComments(action);
+
+ assertThat(result, Matchers.hasSize(2));
+ assertThat(result.get(0).getComment(), Matchers.equalTo("a comment"));
+ assertThat(result.get(1).getComment(), Matchers.equalTo("another comment"));
+ }
+
+ private static HTextFlowTargetReviewComment makeCommentEntity(LocaleId localeId, String comment)
+ {
+ HLocale hLocale = new HLocale(localeId);
+ TestFixture.setId(2L, hLocale);
+
+ HTextFlow textFlow = TestFixture.makeHTextFlow(1L, hLocale, ContentState.Rejected);
+
+ HPerson commenter = new HPerson();
+ TestFixture.setId(3L, commenter);
+
+ return new HTextFlowTargetReviewComment(textFlow.getTargets().get(hLocale.getId()), comment, commenter);
+ }
}