This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rhbz982916 - force comment on reject
- Loading branch information
Patrick Huang
committed
Jul 22, 2013
1 parent
8158398
commit f13f2b5
Showing
16 changed files
with
535 additions
and
49 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
zanata-war/src/main/java/org/zanata/webtrans/client/events/CommentBeforeSaveEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ta-war/src/main/java/org/zanata/webtrans/client/events/CommentBeforeSaveEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...a-war/src/main/java/org/zanata/webtrans/client/presenter/ForceReviewCommentPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
zanata-war/src/main/java/org/zanata/webtrans/client/ui/ReviewCommentInputWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
{ | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
zanata-war/src/main/java/org/zanata/webtrans/client/ui/ReviewCommentInputWidget.ui.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.