summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-05-16 11:07:25 -0700
committerShawn O. Pearce <sop@google.com>2009-05-16 11:07:25 -0700
commitc464ccd7d441bab91f7e0e93805606ce1d3c48ee (patch)
treef1211ad31c726cd203ac31d3cacda6da4f1b048a
parent196f5d7492faa63c567b85c4f5344a1bfa715be6 (diff)
Add keyboard bindings n/p for all change lists to paginate
This makes it easier to browse through a very long list of changes, as you can use the keyboard keys n to move to the next page and p to move to the prior, along with the existing j/k/o to move around within the page, and open a record. Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r--src/main/java/com/google/gerrit/client/changes/AllSingleListScreen.java40
-rw-r--r--src/main/java/com/google/gerrit/client/changes/ChangeConstants.java2
-rw-r--r--src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties2
3 files changed, 37 insertions, 7 deletions
diff --git a/src/main/java/com/google/gerrit/client/changes/AllSingleListScreen.java b/src/main/java/com/google/gerrit/client/changes/AllSingleListScreen.java
index 15a65abca5..b8ecfad0f7 100644
--- a/src/main/java/com/google/gerrit/client/changes/AllSingleListScreen.java
+++ b/src/main/java/com/google/gerrit/client/changes/AllSingleListScreen.java
@@ -18,9 +18,12 @@ import com.google.gerrit.client.data.ChangeInfo;
import com.google.gerrit.client.data.SingleListChangeInfo;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.Screen;
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Hyperlink;
+import com.google.gwtexpui.globalkey.client.KeyCommand;
import java.util.List;
@@ -50,19 +53,26 @@ public abstract class AllSingleListScreen extends Screen {
@Override
protected void onInitUI() {
super.onInitUI();
- table = new ChangeTable();
- section = new ChangeTable.Section();
-
- table.addSection(section);
- table.setSavePointerId(anchorPrefix);
- add(table);
-
prev = new Hyperlink(Util.C.pagedChangeListPrev(), true, "");
prev.setVisible(false);
next = new Hyperlink(Util.C.pagedChangeListNext(), true, "");
next.setVisible(false);
+ table = new ChangeTable() {
+ {
+ keysNavigation.add(new DoLinkCommand(0, 'p', Util.C
+ .changeTablePagePrev(), prev));
+ keysNavigation.add(new DoLinkCommand(0, 'n', Util.C
+ .changeTablePageNext(), next));
+ }
+ };
+ section = new ChangeTable.Section();
+
+ table.addSection(section);
+ table.setSavePointerId(anchorPrefix);
+ add(table);
+
final HorizontalPanel buttons = new HorizontalPanel();
buttons.setStyleName("gerrit-ChangeTable-PrevNextLinks");
buttons.add(prev);
@@ -122,4 +132,20 @@ public abstract class AllSingleListScreen extends Screen {
section.display(result.getChanges());
table.finishDisplay();
}
+
+ private static final class DoLinkCommand extends KeyCommand {
+ private final Hyperlink link;
+
+ private DoLinkCommand(int mask, char key, String help, Hyperlink l) {
+ super(mask, key, help);
+ link = l;
+ }
+
+ @Override
+ public void onKeyPress(final KeyPressEvent event) {
+ if (link.isVisible()) {
+ History.newItem(link.getTargetHistoryToken());
+ }
+ }
+ }
}
diff --git a/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java b/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java
index 9c8b5f8e15..77f866d995 100644
--- a/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java
+++ b/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java
@@ -42,6 +42,8 @@ public interface ChangeConstants extends Constants {
String changeTableNext();
String changeTableOpen();
String changeTableStar();
+ String changeTablePagePrev();
+ String changeTablePageNext();
String upToDashboard();
String keyPublishComments();
diff --git a/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties b/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties
index 5a08e2a927..7392c2789d 100644
--- a/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties
+++ b/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties
@@ -22,6 +22,8 @@ changeTablePrev = Previous change
changeTableNext = Next change
changeTableOpen = Open change
changeTableStar = Star (or unstar) change
+changeTablePagePrev = Previous page of changes
+changeTablePageNext = Next page of changes
upToDashboard = Up to dashboard
keyPublishComments = Review and publish comments