use of com.hack23.cia.web.impl.ui.application.views.pageclicklistener.LogoutClickListener in project cia by Hack23.
the class AbstractView method createTopHeaderActionsForUserContext.
/**
* Creates the top header actions for user context.
*/
private void createTopHeaderActionsForUserContext() {
if (UserContextUtil.allowRoleInSecurityContext(ROLE_ADMIN) || UserContextUtil.allowRoleInSecurityContext(ROLE_USER)) {
final Link userHomePageLink = pageLinkFactory.createUserHomeViewPageLink();
topHeaderRightPanel.addComponent(userHomePageLink);
topHeaderRightPanel.setComponentAlignment(userHomePageLink, Alignment.MIDDLE_RIGHT);
final Button logoutButton = new Button(LOGOUT, VaadinIcons.SIGN_OUT);
final LogoutRequest logoutRequest = new LogoutRequest();
logoutRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
logoutButton.addClickListener(new LogoutClickListener(logoutRequest));
topHeaderRightPanel.addComponent(logoutButton);
topHeaderRightPanel.setComponentAlignment(logoutButton, Alignment.MIDDLE_RIGHT);
} else {
final Link createRegisterPageLink = pageLinkFactory.createRegisterPageLink();
topHeaderRightPanel.addComponent(createRegisterPageLink);
topHeaderRightPanel.setComponentAlignment(createRegisterPageLink, Alignment.MIDDLE_RIGHT);
final Link createLoginPageLink = pageLinkFactory.createLoginPageLink();
topHeaderRightPanel.addComponent(createLoginPageLink);
topHeaderRightPanel.setComponentAlignment(createLoginPageLink, Alignment.MIDDLE_RIGHT);
}
}
use of com.hack23.cia.web.impl.ui.application.views.pageclicklistener.LogoutClickListener in project cia by Hack23.
the class UserHomeOverviewPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
userHomeMenuItemFactory.createUserHomeMenuBar(menuBar, pageId);
LabelFactory.createHeader2Label(panelContent, OVERVIEW);
final Button logoutButton = new Button(LOGOUT, VaadinIcons.SIGN_OUT);
final LogoutRequest logoutRequest = new LogoutRequest();
logoutRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
logoutButton.addClickListener(new LogoutClickListener(logoutRequest));
panelContent.addComponent(logoutButton);
final DataContainer<UserAccount, Long> dataContainer = getApplicationManager().getDataContainer(UserAccount.class);
final Long userIdFromSecurityContext = UserContextUtil.getUserInternalIdFromSecurityContext();
if (userIdFromSecurityContext == null) {
UI.getCurrent().getNavigator().navigateTo(CommonsViews.MAIN_VIEW_NAME);
} else {
final UserAccount userAccount = dataContainer.load(userIdFromSecurityContext);
getFormFactory().addFormPanelTextFields(panelContent, userAccount, UserAccount.class, AS_LIST);
panelContent.setExpandRatio(logoutButton, ContentRatio.SMALL);
final VerticalLayout overviewLayout = new VerticalLayout();
overviewLayout.setSizeFull();
panelContent.addComponent(overviewLayout);
panelContent.setExpandRatio(overviewLayout, ContentRatio.LARGE_FORM);
userHomeMenuItemFactory.createOverviewPage(overviewLayout);
}
panel.setCaption(NAME + "::" + USERHOME);
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_USER_HOME_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
return panelContent;
}
Aggregations