From e77f4fea7019a8ec80563cfb6a40b39c20d39530 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 7 Jan 2009 16:12:28 -0800 Subject: [PATCH] Allow Screen implementations to control what happens on sign-in,sign-out Some screens may just want to hide UI widgets or recalculate their content, not move to the Link.ALL URL, even though they may be at least partially dependent upon the current user identity. Signed-off-by: Shawn O. Pearce --- .../main/java/com/google/gerrit/client/Gerrit.java | 7 +++++-- .../java/com/google/gerrit/client/ui/Screen.java | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/appjar/src/main/java/com/google/gerrit/client/Gerrit.java b/appjar/src/main/java/com/google/gerrit/client/Gerrit.java index 44f3bae174..a9f97b07af 100644 --- a/appjar/src/main/java/com/google/gerrit/client/Gerrit.java +++ b/appjar/src/main/java/com/google/gerrit/client/Gerrit.java @@ -149,8 +149,8 @@ public class Gerrit implements EntryPoint { } refreshMenuBar(); - if (currentScreen != null && currentScreen.isRequiresSignIn()) { - History.newItem(Link.ALL); + if (currentScreen != null) { + currentScreen.onSignOut(); } } @@ -271,6 +271,9 @@ public class Gerrit implements EntryPoint { for (final SignedInListener l : signedInListeners) { l.onSignIn(); } + if (currentScreen != null) { + currentScreen.onSignIn(); + } } }); } diff --git a/appjar/src/main/java/com/google/gerrit/client/ui/Screen.java b/appjar/src/main/java/com/google/gerrit/client/ui/Screen.java index 82d10a91c2..a3ede641d2 100644 --- a/appjar/src/main/java/com/google/gerrit/client/ui/Screen.java +++ b/appjar/src/main/java/com/google/gerrit/client/ui/Screen.java @@ -15,8 +15,10 @@ package com.google.gerrit.client.ui; import com.google.gerrit.client.Gerrit; +import com.google.gerrit.client.Link; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.History; import com.google.gwt.user.client.ui.FlowPanel; public class Screen extends FlowPanel { @@ -50,6 +52,17 @@ public class Screen extends FlowPanel { return requiresSignIn; } + /** Invoked if this screen is the current screen and the user signs out. */ + public void onSignOut() { + if (isRequiresSignIn()) { + History.newItem(Link.ALL); + } + } + + /** Invoked if this screen is the current screen and the user signs in. */ + public void onSignIn() { + } + /** Get the token to cache this screen's widget; null if it shouldn't cache. */ public Object getScreenCacheToken() { return null;