diff options
author | Shawn O. Pearce <sop@google.com> | 2010-08-19 17:40:53 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2010-08-19 17:40:56 -0700 |
commit | 38347820a40d3efb5cc1c26c552f6cdcdeeb70d1 (patch) | |
tree | 74feb6b1b86c3e140960ea80adb8e801a5c1e64a | |
parent | 4f0d56acd7dc4802e08ff989eb63f5a3641c116e (diff) |
Make 'u' go up to the last change listing
Rather than hard code 'u' from a change page to your dashboard, make
it return to the last major listing of changes you were viewing.
This makes it a whole lot easier to navigate through all changes
that you have starred, or have drafts on, or that are in a particular
query result.
Change-Id: I04c5569125633b4e68eb2a93d2bd313a1b632209
Signed-off-by: Shawn O. Pearce <sop@google.com>
8 files changed, 45 insertions, 77 deletions
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java index ec6b9ed4f9..7bee0af174 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java @@ -16,6 +16,7 @@ package com.google.gerrit.client; import com.google.gerrit.client.auth.openid.OpenIdSignInDialog; import com.google.gerrit.client.auth.userpass.UserPassSignInDialog; +import com.google.gerrit.client.changes.ChangeListScreen; import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.ui.LinkMenuBar; import com.google.gerrit.client.ui.LinkMenuItem; @@ -81,6 +82,8 @@ public class Gerrit implements EntryPoint { private static final Dispatcher dispatcher = new Dispatcher(); private static ViewSite<Screen> body; + private static String lastChangeListToken; + static { SYSTEM_SVC = GWT.create(SystemInfoService.class); JsonUtil.bind(SYSTEM_SVC, "rpc/SystemInfoService"); @@ -91,6 +94,16 @@ public class Gerrit implements EntryPoint { Window.Location.reload(); } + public static void displayLastChangeList() { + if (lastChangeListToken != null) { + display(lastChangeListToken); + } else if (isSignedIn()) { + display(PageLinks.MINE); + } else { + display(PageLinks.toChangeQuery("status:open")); + } + } + /** * Load the screen at the given location, displaying when ready. * <p> @@ -365,6 +378,11 @@ public class Gerrit implements EntryPoint { dispatchHistoryHooks(token); } } + + if (view instanceof ChangeListScreen) { + lastChangeListToken = token; + } + super.onShowView(view); view.onShowView(); } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/AccountDashboardScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/AccountDashboardScreen.java index e122ce428f..f5f3245f53 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/AccountDashboardScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/AccountDashboardScreen.java @@ -25,7 +25,7 @@ import com.google.gerrit.common.data.AccountInfo; import com.google.gerrit.reviewdb.Account; -public class AccountDashboardScreen extends Screen { +public class AccountDashboardScreen extends Screen implements ChangeListScreen { private final Account.Id ownerId; private ChangeTable table; private ChangeTable.Section byOwner; diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java index 9a08932687..42bb28b4c5 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java @@ -46,7 +46,7 @@ public interface ChangeConstants extends Constants { String changeTableStar(); String changeTablePagePrev(); String changeTablePageNext(); - String upToDashboard(); + String upToChangeList(); String expandCollapseDependencies(); String previousPatchSet(); String nextPatchSet(); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties index 59d0bd52c1..996b462139 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties @@ -26,7 +26,7 @@ changeTableOpen = Open change changeTableStar = Star (or unstar) change changeTablePagePrev = Previous page of changes changeTablePageNext = Next page of changes -upToDashboard = Up to dashboard +upToChangeList = Up to change list expandCollapseDependencies = Expands / Collapses dependencies section previousPatchSet = Previous patch set nextPatchSet = Next patch set diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeListScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeListScreen.java new file mode 100644 index 0000000000..8871ee07b6 --- /dev/null +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeListScreen.java @@ -0,0 +1,18 @@ +// Copyright (C) 2010 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.client.changes; + +public interface ChangeListScreen { +} diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeScreen.java index 36d3681592..83870c0a54 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeScreen.java @@ -22,7 +22,6 @@ import com.google.gerrit.client.ui.ExpandAllCommand; import com.google.gerrit.client.ui.LinkMenuBar; import com.google.gerrit.client.ui.NeedsSignInKeyCommand; import com.google.gerrit.client.ui.Screen; -import com.google.gerrit.common.PageLinks; import com.google.gerrit.common.data.AccountInfo; import com.google.gerrit.common.data.AccountInfoCache; import com.google.gerrit.common.data.ChangeDetail; @@ -145,7 +144,7 @@ public class ChangeScreen extends Screen { keysNavigation = new KeyCommandSet(Gerrit.C.sectionNavigation()); keysAction = new KeyCommandSet(Gerrit.C.sectionActions()); - keysNavigation.add(new DashboardKeyCommand(0, 'u', Util.C.upToDashboard())); + keysNavigation.add(new UpToListKeyCommand(0, 'u', Util.C.upToChangeList())); keysNavigation.add(new ExpandCollapseDependencySectionKeyCommand(0, 'd', Util.C.expandCollapseDependencies())); if (Gerrit.isSignedIn()) { @@ -346,18 +345,14 @@ public class ChangeScreen extends Screen { }); } - public class DashboardKeyCommand extends KeyCommand { - public DashboardKeyCommand(int mask, char key, String help) { + public class UpToListKeyCommand extends KeyCommand { + public UpToListKeyCommand(int mask, char key, String help) { super(mask, key, help); } @Override public void onKeyPress(final KeyPressEvent event) { - if (Gerrit.isSignedIn()) { - Gerrit.display(PageLinks.MINE); - } else { - Gerrit.display(PageLinks.toChangeQuery("status:open")); - } + Gerrit.displayLastChangeList(); } } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/MineSingleListScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/MineSingleListScreen.java deleted file mode 100644 index 9016b21fdc..0000000000 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/MineSingleListScreen.java +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2008 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.rpc.ScreenLoadCallback; -import com.google.gerrit.client.ui.AccountScreen; -import com.google.gerrit.common.data.SingleListChangeInfo; -import com.google.gwt.user.client.rpc.AsyncCallback; - - -public abstract class MineSingleListScreen extends AccountScreen { - private final String anchor; - private ChangeTable table; - private ChangeTable.Section drafts; - - protected MineSingleListScreen(final String historyToken) { - anchor = historyToken; - } - - @Override - protected void onInitUI() { - super.onInitUI(); - table = new ChangeTable(); - drafts = new ChangeTable.Section(); - - table.addSection(drafts); - table.setSavePointerId(anchor); - - add(table); - } - - @Override - public void registerKeys() { - super.registerKeys(); - table.setRegisterKeys(true); - } - - protected AsyncCallback<SingleListChangeInfo> loadCallback() { - return new ScreenLoadCallback<SingleListChangeInfo>(this) { - @Override - protected void preDisplay(final SingleListChangeInfo result) { - display(result); - } - }; - } - - private void display(final SingleListChangeInfo result) { - table.setAccountInfoCache(result.getAccounts()); - drafts.display(result.getChanges()); - table.finishDisplay(); - } -} diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/QueryScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/QueryScreen.java index bcd2ed22ce..1192dd0b9b 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/QueryScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/QueryScreen.java @@ -24,7 +24,8 @@ import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwtorm.client.KeyUtil; -public class QueryScreen extends PagedSingleListScreen { +public class QueryScreen extends PagedSingleListScreen implements + ChangeListScreen { public static QueryScreen forQuery(String query) { return forQuery(query, PageLinks.TOP); } |