modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 3 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java | 19 ---------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java | 16 +++++++- 3 files changed, 17 insertions(+), 21 deletions(-)
New commits: commit 5371ea38e16142e129d59dcf0631a909a3c910e2 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Nov 24 15:28:48 2010 -0500
Ensure that the username is correct in the menu bar when the session changes. The timer solution previously used in Footer is replaceed with a request from CoreGUI to redraw the menu bar, and the menu bar overrides markForRedraw to update the session info as needed.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java index 1fb3d29..f039fda 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java @@ -169,6 +169,9 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { }
if (History.getToken().equals("") || History.getToken().equals("LogOut")) { + // request a redraw of the MenuBarItem to ensure the correct sessio info is displayed + rootCanvas.getMember(0).markForRedraw(); + // go to default view if user doesn't specify a history token History.newItem(getDefaultView()); } else { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java index 96b2e17..e6da3f3 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java @@ -58,7 +58,6 @@ public class Footer extends LocatableToolStrip { protected void onDraw() { super.onDraw();
- //final UserSessionState userSessionState = new UserSessionState("UserSessionState"); final MessageCenterView messageCenter = new MessageCenterView(extendLocatorId(MessageCenterView.LOCATOR_ID)); final FavoritesButton favoritesButton = new FavoritesButton(extendLocatorId("Favorites")); final AlertsMessage alertsMessage = new AlertsMessage(extendLocatorId("Alerts")); @@ -73,7 +72,6 @@ public class Footer extends LocatableToolStrip {
addMember(favoritesButton);
- //userSessionState.schedule(15000); alertsMessage.schedule(60000); }
@@ -114,23 +112,6 @@ public class Footer extends LocatableToolStrip { } }
- // public static class UserSessionState extends RefreshableLabel { - // public UserSessionState(String locatorId) { - // super(locatorId); - // setWrap(false); - // setMargin(5); - // setValign(VerticalAlignment.CENTER); - // } - // - // public void refreshLoggedIn() { - // setContents(MSG.view_core_loggedInAs(UserSessionManager.getSessionSubject().getName())); - // } - // - // public void refreshLoggedOut() { - // setContents(MSG.view_core_loggedOut()); - // } - // } - public static class AlertsMessage extends RefreshableLabel { public AlertsMessage(String locatorId) { super(locatorId); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java index a87fcc4..8a090dd 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java @@ -54,6 +54,7 @@ public class MenuBarView extends LocatableVLayout { BundleTopView.VIEW_ID, AdministrationView.VIEW_ID, HelpView.VIEW_ID };
private String currentlySelectedSection = DashboardsView.VIEW_ID.getName(); + private LocatableLabel userLabel;
public MenuBarView(String locatorId) { super(locatorId); @@ -78,6 +79,18 @@ public class MenuBarView extends LocatableVLayout { markForRedraw(); }
+ // When redrawing, ensire the correct session infor is displayed + @Override + public void markForRedraw() { + String currentDisplayName = userLabel.getContents(); + String currentUsername = UserSessionManager.getSessionSubject().getName(); + if (!currentUsername.equals(currentDisplayName)) { + userLabel.setContents(currentUsername); + } + + super.markForRedraw(); + } + private Canvas getLogoSection() { final AboutModalWindow aboutModalWindow = new AboutModalWindow(); Img logo = new Img("header/rhq_logo_28px.png", 80, 28); @@ -140,8 +153,7 @@ public class MenuBarView extends LocatableVLayout { layout.setMargin(10); layout.setAlign(Alignment.RIGHT);
- LocatableLabel userLabel = new LocatableLabel(this.extendLocatorId("User"), UserSessionManager - .getSessionSubject().getName()); + userLabel = new LocatableLabel(this.extendLocatorId("User"), UserSessionManager.getSessionSubject().getName()); userLabel.setAutoWidth();
LocatableLabel lineLabel = new LocatableLabel(this.extendLocatorId("Line"), " | ");
rhq-commits@lists.fedorahosted.org