From 471e496fcca9bb36ba8d3b749543910024550442 Mon Sep 17 00:00:00 2001 From: Ismo Haataja Date: Tue, 7 Oct 2014 16:25:14 +0300 Subject: Top/bottom keyboard navigation keys added for diff review pages 'K' is used to move to top of diff review page (changes) 'J' is used to move to bottom of diff review page (changes) Task-number: QTQAINFRA-902 Change-Id: I5a39a80b3595a8a1f652efb8c22ff3795ae55c9f Reviewed-by: Oswald Buddenhagen Reviewed-by: Ismo Haataja --- .../client/patches/AbstractPatchContentTable.java | 28 ++++++++++++++++++ .../gerrit/client/patches/AllInOnePatchScreen.java | 34 ++++++++++++++++++++++ .../gerrit/client/patches/PatchConstants.java | 2 ++ .../client/patches/PatchConstants.properties | 2 ++ .../client/ui/ContentTableKeyNavigation.java | 28 ++++++++++++++++++ 5 files changed, 94 insertions(+) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java index 004905f134..1a3dbe1e2c 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java @@ -141,6 +141,16 @@ public abstract class AbstractPatchContentTable extends NavigationTable moveToPrevComment(getCurrentRow()); } + @Override + protected void onTop() { + moveToTop(); + } + + @Override + protected void onBottom() { + moveToBottom(); + } + @Override protected void onInsertComment() { ensurePointerVisible(); @@ -548,6 +558,24 @@ public abstract class AbstractPatchContentTable extends NavigationTable } } + public void moveToTop() { + for (int row = 0; row < table.getRowCount(); row++) { + if (getRowItem(row) != null) { + movePointerTo(row); + break; + } + } + } + + public void moveToBottom() { + for (int row = table.getRowCount() - 1; row >= 0; row--) { + if (getRowItem(row) != null) { + movePointerTo(row); + break; + } + } + } + private boolean isComment(int row) { return getRowItem(row) instanceof CommentList; } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AllInOnePatchScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AllInOnePatchScreen.java index 27c6c9f077..d15af28ab4 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AllInOnePatchScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AllInOnePatchScreen.java @@ -169,6 +169,40 @@ public class AllInOnePatchScreen extends AbstractPatchScreen implements } } + @Override + protected void onTop() { + if (!diffs.isEmpty()) { + contentTable.hideCursor(); + for (int index = 0; index < diffs.size(); index++) { + Diff diff = diffs.get(index); + if (diff.isVisible()) { + this.diff = diff; + contentTable = diff.getContentTable(); + contentTable.moveToTop(); + break; + } + } + contentTable.showCursor(); + } + } + + @Override + protected void onBottom() { + if (!diffs.isEmpty()) { + contentTable.hideCursor(); + for (int index = diffs.size()-1; index >= 0; index--) { + Diff diff = diffs.get(index); + if (diff.isVisible()) { + this.diff = diff; + contentTable = diff.getContentTable(); + contentTable.moveToBottom(); + break; + } + } + contentTable.showCursor(); + } + } + protected void onFileNext() { contentTable.hideCursor(); diff = getNextDiff(); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchConstants.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchConstants.java index 8c9c56b09a..467fc4209b 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchConstants.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchConstants.java @@ -46,6 +46,8 @@ public interface PatchConstants extends Constants { String chunkNext(); String commentPrev(); String commentNext(); + String top(); + String bottom(); String fileList(); String expandComment(); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchConstants.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchConstants.properties index 5acdb5f532..4812c7a504 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchConstants.properties +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchConstants.properties @@ -28,6 +28,8 @@ chunkPrev = Previous diff chunk or comment chunkNext = Next diff chunk or comment commentPrev = Previous comment commentNext = Next comment +top = Top +bottom = Bottom fileList = Browse files in patch set expandComment = Expand or collapse comment diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/ContentTableKeyNavigation.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/ContentTableKeyNavigation.java index 96df5cbbe6..43c07177e9 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/ContentTableKeyNavigation.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/ContentTableKeyNavigation.java @@ -79,6 +79,28 @@ public abstract class ContentTableKeyNavigation extends AbstractKeyNavigation { } } + private class TopKeyCmd extends KeyCommand { + public TopKeyCmd(int mask, int key, String help) { + super(mask, key, help); + } + + @Override + public void onKeyPress(final KeyPressEvent event) { + onTop(); + } + } + + private class BottomKeyCmd extends KeyCommand { + public BottomKeyCmd(int mask, int key, String help) { + super(mask, key, help); + } + + @Override + public void onKeyPress(final KeyPressEvent event) { + onBottom(); + } + } + private class PublishCommentsKeyCommand extends NeedsSignInKeyCommand { public PublishCommentsKeyCommand(int mask, char key, String help) { super(mask, key, help); @@ -113,6 +135,8 @@ public abstract class ContentTableKeyNavigation extends AbstractKeyNavigation { keysNavigation.add(new NextChunkKeyCmd(0, 'n', PatchUtil.C.chunkNext())); keysNavigation.add(new PrevCommentCmd(0, 'P', PatchUtil.C.commentPrev())); keysNavigation.add(new NextCommentCmd(0, 'N', PatchUtil.C.commentNext())); + keysNavigation.add(new TopKeyCmd(0, 'K', PatchUtil.C.top())); + keysNavigation.add(new BottomKeyCmd(0, 'J', PatchUtil.C.bottom())); if (Gerrit.isSignedIn()) { keysAction.add(new InsertCommentCommand(0, 'c', PatchUtil.C @@ -151,6 +175,10 @@ public abstract class ContentTableKeyNavigation extends AbstractKeyNavigation { protected void onCommentPrev() {} + protected void onTop() {} + + protected void onBottom() {} + protected void onInsertComment() {} protected void onPublishComments() {} -- cgit v1.2.3