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 <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-01-07 16:12:28 -08:00
parent 4aeceacd7a
commit e77f4fea70
2 changed files with 18 additions and 2 deletions

View File

@@ -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();
}
}
});
}

View File

@@ -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;