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

Commit

Permalink
rhbz982916 - force comment on reject
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Jul 22, 2013
1 parent 8158398 commit f13f2b5
Show file tree
Hide file tree
Showing 16 changed files with 535 additions and 49 deletions.
@@ -0,0 +1,51 @@
/*
* 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.events;

import com.google.gwt.event.shared.GwtEvent;

public class CommentBeforeSaveEvent extends GwtEvent<CommentBeforeSaveEventHandler>
{
public static Type<CommentBeforeSaveEventHandler> TYPE = new Type<CommentBeforeSaveEventHandler>();

private final TransUnitSaveEvent saveEvent;

public CommentBeforeSaveEvent(TransUnitSaveEvent saveEvent)
{
this.saveEvent = saveEvent;
}

public TransUnitSaveEvent getSaveEvent()
{
return saveEvent;
}

public Type<CommentBeforeSaveEventHandler> getAssociatedType()
{
return TYPE;
}

protected void dispatch(CommentBeforeSaveEventHandler handler)
{
handler.onCommentBeforeSave(this);
}
}
@@ -0,0 +1,29 @@
/*
* 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.events;

import com.google.gwt.event.shared.EventHandler;

public interface CommentBeforeSaveEventHandler extends EventHandler
{
void onCommentBeforeSave(CommentBeforeSaveEvent event);
}
Expand Up @@ -45,6 +45,7 @@
import org.zanata.webtrans.client.presenter.DocumentListOptionsPresenter;
import org.zanata.webtrans.client.presenter.DocumentListPresenter;
import org.zanata.webtrans.client.presenter.EditorOptionsPresenter;
import org.zanata.webtrans.client.presenter.ForceReviewCommentPresenter;
import org.zanata.webtrans.client.presenter.GlossaryDetailsPresenter;
import org.zanata.webtrans.client.presenter.GlossaryPresenter;
import org.zanata.webtrans.client.presenter.KeyShortcutPresenter;
Expand Down Expand Up @@ -164,6 +165,7 @@ protected void configure()
bindPresenter(NotificationPresenter.class, NotificationDisplay.class, NotificationView.class);
bindPresenter(TransUnitsTablePresenter.class, TransUnitsTableDisplay.class, TransUnitsTableView.class);
bindPresenter(SideMenuPresenter.class, SideMenuDisplay.class, SideMenuView.class);
bind(ForceReviewCommentPresenter.class).asEagerSingleton();

bind(SourceContentsPresenter.class).in(Singleton.class);
bind(TargetContentsDisplay.class).to(TargetContentsView.class);
Expand Down
@@ -0,0 +1,102 @@
/*
* 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.CommentBeforeSaveEvent;
import org.zanata.webtrans.client.events.CommentBeforeSaveEventHandler;
import org.zanata.webtrans.client.events.NavTransUnitEvent;
import org.zanata.webtrans.client.events.TransUnitSaveEvent;
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.view.ForceReviewCommentDisplay;
import org.zanata.webtrans.shared.rpc.AddReviewCommentAction;
import org.zanata.webtrans.shared.rpc.AddReviewCommentResult;
import com.google.inject.Inject;

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

/**
* @author Patrick Huang <a href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
public class ForceReviewCommentPresenter extends WidgetPresenter<ForceReviewCommentDisplay>
implements ForceReviewCommentDisplay.Listener, CommentBeforeSaveEventHandler
{

private final CachingDispatchAsync dispatcher;
private final GetTransUnitActionContextHolder contextHolder;

private TransUnitSaveEvent saveEvent;

@Inject
public ForceReviewCommentPresenter(ForceReviewCommentDisplay display, EventBus eventBus, CachingDispatchAsync dispatcher, GetTransUnitActionContextHolder contextHolder)
{
super(display, eventBus);
this.dispatcher = dispatcher;
this.contextHolder = contextHolder;
display.setListener(this);

eventBus.addHandler(CommentBeforeSaveEvent.TYPE, this);
}

@Override
public void onCommentBeforeSave(CommentBeforeSaveEvent event)
{
saveEvent = event.getSaveEvent();
display.center();
}

@Override
public void addComment(String content)
{
dispatcher.execute(new AddReviewCommentAction(saveEvent.getTransUnitId(), content,
contextHolder.getContext().getDocument().getId()), new AbstractAsyncCallback<AddReviewCommentResult>()
{
@Override
public void onSuccess(AddReviewCommentResult result)
{
display.clearInput();
eventBus.fireEvent(saveEvent);
eventBus.fireEvent(NavTransUnitEvent.NEXT_ENTRY_EVENT);
saveEvent = null;
display.hide();
}
});

}

@Override
protected void onBind()
{
}

@Override
protected void onUnbind()
{
}

@Override
protected void onRevealDisplay()
{
}
}
Expand Up @@ -31,6 +31,7 @@

import org.zanata.common.ContentState;
import org.zanata.webtrans.client.events.CheckStateHasChangedEvent;
import org.zanata.webtrans.client.events.CommentBeforeSaveEvent;
import org.zanata.webtrans.client.events.CopyDataToEditorEvent;
import org.zanata.webtrans.client.events.CopyDataToEditorHandler;
import org.zanata.webtrans.client.events.InsertStringInEditorEvent;
Expand Down Expand Up @@ -689,7 +690,8 @@ public void acceptTranslation(TransUnitId id)
public void rejectTranslation(TransUnitId id)
{
ensureRowSelection(id);
saveCurrent(ContentState.Rejected);
TransUnitSaveEvent event = new TransUnitSaveEvent(getNewTargets(), ContentState.Rejected, display.getId(), display.getVerNum(), display.getCachedTargets());
eventBus.fireEvent(new CommentBeforeSaveEvent(event));
}


Expand Down
Expand Up @@ -59,6 +59,7 @@ public TranslationHistoryPresenter(TranslationHistoryDisplay display, EventBus e
this.contextHolder = contextHolder;

display.setListener(this);
eventBus.addHandler(ReviewCommentEvent.TYPE, this);
}

@Override
Expand Down
Expand Up @@ -553,4 +553,7 @@ public interface WebTransMessages extends Messages

@DefaultMessage("Remove from comparison")
String removeFromComparison();

@DefaultMessage("Enter reject reason or close to cancel")
String rejectCommentTitle();
}
@@ -0,0 +1,75 @@
/*
* 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.ui;

import org.zanata.webtrans.client.view.ForceReviewCommentDisplay;
import com.google.gwt.core.client.GWT;
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.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.TextArea;

public class ReviewCommentInputWidget extends Composite
{
private static ReviewCommentInputWidgetUiBinder ourUiBinder = GWT.create(ReviewCommentInputWidgetUiBinder.class);
@UiField
TextArea commentTextArea;
@UiField
Button addCommentButton;
private ForceReviewCommentDisplay.Listener listener;

public ReviewCommentInputWidget()
{
initWidget(ourUiBinder.createAndBindUi(this));
commentTextArea.getElement().setAttribute("placeholder", "Add a comment...");
}

@UiHandler("addCommentButton")
public void onAddCommentButtonClick(ClickEvent event)
{
listener.addComment(commentTextArea.getText());
}

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

public void setEnabled(boolean enabled)
{
commentTextArea.setEnabled(enabled);
addCommentButton.setEnabled(enabled);
}

public void clearInput()
{
commentTextArea.setValue("");
}

interface ReviewCommentInputWidgetUiBinder extends UiBinder<HTMLPanel, ReviewCommentInputWidget>
{
}
}
@@ -0,0 +1,35 @@
<!--
~ 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.
-->

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<g:HTMLPanel styleName="g">
<div class="g__item w--1-12 txt--align-right">
<i class="i--comment i"/><span class="is-invisible">Comment</span>
</div>
<div class="w--9-12 g__item">
<g:TextArea name="comment" styleName="basic-input" ui:field="commentTextArea" />
</div>
<div class="w--2-12 g__item">
<g:Button addStyleNames="button--full" text="Add Comment" ui:field="addCommentButton" />
</div>
</g:HTMLPanel>
</ui:UiBinder>
Expand Up @@ -2,28 +2,17 @@

import java.util.List;

import org.zanata.webtrans.client.view.ForceReviewCommentDisplay;
import org.zanata.webtrans.shared.model.ComparableByDate;
import org.zanata.webtrans.shared.model.ReviewComment;
import org.zanata.webtrans.shared.model.TransHistoryItem;
import com.google.gwt.user.cellview.client.ColumnSortEvent;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.ProvidesKey;
import com.google.gwt.view.client.SelectionModel;
import com.google.inject.ImplementedBy;

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

@ImplementedBy(TranslationHistoryView.class)
public interface TranslationHistoryDisplay extends WidgetDisplay
{
ProvidesKey<TransHistoryItem> HISTORY_ITEM_PROVIDES_KEY = new ProvidesKey<TransHistoryItem>()
{
@Override
public Object getKey(TransHistoryItem item)
{
return item.getVersionNum();
}
};

void center();

Expand All @@ -45,11 +34,9 @@ public Object getKey(TransHistoryItem item)

void clearInput();

interface Listener
interface Listener extends ForceReviewCommentDisplay.Listener
{

void addComment(String commentContent);

void copyIntoEditor(List<String> contents);

void compareClicked(TransHistoryItem item);
Expand Down

0 comments on commit f13f2b5

Please sign in to comment.