public VaadinPortletSession getSession() {
return (VaadinPortletSession) super.getSession();
}
private void possiblyChangedModeOrState() {
VaadinPortletRequest request = (VaadinPortletRequest) VaadinPortletService
.getCurrentRequest();
userAgent.setValue(getPage().getWebBrowser().getBrowserApplication());
screenWidth.setValue(String.valueOf(getPage().getBrowserWindowWidth()));
screenHeight.setValue(String
.valueOf(getPage().getBrowserWindowHeight()));
boolean inViewMode = (request.getPortletMode() == PortletMode.VIEW);
boolean inNormalState = (request.getWindowState() == WindowState.NORMAL);
// Portlet up-and-running, enable stuff
portletEdit.setEnabled(true);
portletMax.setEnabled(true);
// Editable if we're in editmode
tf.setEnabled(!inViewMode);
// Show notification about current mode and state
getPage().showNotification(
new Notification("Portlet status", "Mode: "
+ request.getPortletMode() + " State: "
+ request.getWindowState(), Type.WARNING_MESSAGE));
// Display current user info
Map<?, ?> uinfo = (Map<?, ?>) request
.getAttribute(PortletRequest.USER_INFO);
if (uinfo != null) {
String s = "";
for (Iterator<?> it = uinfo.keySet().iterator(); it.hasNext();) {
Object key = it.next();
Object val = uinfo.get(key);
s += key + ": " + val + "\n";
}
if (request.isUserInRole("administrator")) {
s += "(administrator)";
}
userInfo.setValue(s);
} else {
userInfo.setValue("-");