Add key commands to mark patch as reviewed

Add a key command to toggle the reviewed flag for a patch.

In addition add another key command to mark the patch as reviewed and
navigate to the next unreviewed patch. This is the same streamlined
workflow as implemented by 1481c2ed1a.

Bug: issue 1510
Change-Id: I322814cde19921ea424990f701d52b6fb040168b
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2012-08-07 15:53:12 +02:00
parent adbb4d2af5
commit 501a5e90ab
3 changed files with 65 additions and 22 deletions

View File

@@ -48,6 +48,9 @@ public interface PatchConstants extends Constants {
String fileList();
String expandComment();
String toggleReviewed();
String markAsReviewedAndGoToNext();
String commentEditorSet();
String commentInsert();
String commentSaveDraft();

View File

@@ -30,6 +30,9 @@ commentNext = Next comment
fileList = Browse files in patch set
expandComment = Expand or collapse comment
toggleReviewed = Toggle the reviewed flag
markAsReviewedAndGoToNext = Mark patch as reviewed and go to next unreviewed patch
commentEditorSet = Comment Editing
commentInsert = Create a new inline comment
commentSaveDraft = Save draft comment

View File

@@ -25,8 +25,8 @@ import com.google.gerrit.client.changes.Util;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.InlineHyperlink;
import com.google.gerrit.client.ui.ListenableAccountDiffPreference;
import com.google.gerrit.client.ui.PatchLink;
import com.google.gerrit.client.ui.Screen;
import com.google.gerrit.common.data.PatchScript;
import com.google.gerrit.common.data.PatchSetDetail;
@@ -112,6 +112,7 @@ public abstract class PatchScreen extends Screen implements
private CheckBox reviewedCheckBox;
private FlowPanel reviewedPanel;
private InlineHyperlink reviewedLink;
private HistoryTable historyTable;
private FlowPanel topPanel;
private FlowPanel contentPanel;
@@ -131,7 +132,9 @@ public abstract class PatchScreen extends Screen implements
/** Keys that cause an action on this screen */
private KeyCommandSet keysNavigation;
private KeyCommandSet keysAction;
private HandlerRegistration regNavigation;
private HandlerRegistration regAction;
private boolean intralineFailure;
/**
@@ -193,13 +196,6 @@ public abstract class PatchScreen extends Screen implements
Anchor reviewedAnchor = new Anchor("");
SafeHtml.set(reviewedAnchor, text);
reviewedAnchor.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
setReviewedByCurrentUser(true);
}
});
final PatchValidator unreviewedValidator = new PatchValidator() {
public boolean isValid(Patch patch) {
return !patch.isReviewedByCurrentUser();
@@ -212,25 +208,20 @@ public abstract class PatchScreen extends Screen implements
if (nextUnreviewedPatchIndex > -1) {
// Create invisible patch link to change page
final PatchLink reviewedLink =
reviewedLink =
fileList.createLink(nextUnreviewedPatchIndex, getPatchScreenType(),
null, null);
reviewedLink.setText("");
reviewedAnchor.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
reviewedLink.go();
}
});
} else {
final ChangeLink upLink = new ChangeLink("", patchKey.getParentKey());
reviewedAnchor.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
upLink.go();
}
});
reviewedLink = new ChangeLink("", patchKey.getParentKey());
}
reviewedAnchor.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
setReviewedByCurrentUser(true);
reviewedLink.go();
}
});
return reviewedAnchor;
}
@@ -310,6 +301,14 @@ public abstract class PatchScreen extends Screen implements
keysNavigation.add(new UpToChangeCommand(patchKey.getParentKey(), 0, 'u'));
keysNavigation.add(new FileListCmd(0, 'f', PatchUtil.C.fileList()));
if (Gerrit.isSignedIn()) {
keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
keysAction
.add(new ToggleReviewedCmd(0, 'm', PatchUtil.C.toggleReviewed()));
keysAction.add(new MarkAsReviewedAndGoToNextCmd(0, 'M', PatchUtil.C
.markAsReviewedAndGoToNext()));
}
historyTable = new HistoryTable(this);
commitMessageBlock = new CommitMessageBlock();
@@ -393,6 +392,10 @@ public abstract class PatchScreen extends Screen implements
regNavigation.removeHandler();
regNavigation = null;
}
if (regAction != null) {
regAction.removeHandler();
regAction = null;
}
super.onUnload();
}
@@ -405,6 +408,13 @@ public abstract class PatchScreen extends Screen implements
regNavigation = null;
}
regNavigation = GlobalKey.add(this, keysNavigation);
if (regAction != null) {
regAction.removeHandler();
regAction = null;
}
if (keysAction != null) {
regAction = GlobalKey.add(this, keysAction);
}
}
protected abstract AbstractPatchContentTable createContentTable();
@@ -603,4 +613,31 @@ public abstract class PatchScreen extends Screen implements
p.open();
}
}
public class ToggleReviewedCmd extends KeyCommand {
public ToggleReviewedCmd(int mask, int key, String help) {
super(mask, key, help);
}
@Override
public void onKeyPress(final KeyPressEvent event) {
final boolean isReviewed = !reviewedCheckBox.getValue();
reviewedCheckBox.setValue(isReviewed);
setReviewedByCurrentUser(isReviewed);
}
}
public class MarkAsReviewedAndGoToNextCmd extends KeyCommand {
public MarkAsReviewedAndGoToNextCmd(int mask, int key, String help) {
super(mask, key, help);
}
@Override
public void onKeyPress(final KeyPressEvent event) {
if (reviewedLink != null) {
setReviewedByCurrentUser(true);
reviewedLink.go();
}
}
}
}