summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIsmo Haataja <ismo.haataja@digia.com>2014-10-07 16:25:14 +0300
committerIsmo Haataja <ismo.haataja@digia.com>2014-10-15 09:15:05 +0200
commit471e496fcca9bb36ba8d3b749543910024550442 (patch)
tree3d0cec45448e4949dd9242720013041ceaa1c70e
parent571879ba35812897223c55864af0db04d1cf5cfb (diff)
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 <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
-rw-r--r--gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java28
-rw-r--r--gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AllInOnePatchScreen.java34
-rw-r--r--gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchConstants.java2
-rw-r--r--gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchConstants.properties2
-rw-r--r--gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/ContentTableKeyNavigation.java28
5 files changed, 94 insertions, 0 deletions
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
@@ -142,6 +142,16 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
}
@Override
+ protected void onTop() {
+ moveToTop();
+ }
+
+ @Override
+ protected void onBottom() {
+ moveToBottom();
+ }
+
+ @Override
protected void onInsertComment() {
ensurePointerVisible();
for (int row = getCurrentRow(); 0 <= row; row--) {
@@ -548,6 +558,24 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
}
}
+ 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() {}