Search in sources :

Example 1 with LogoutClickListener

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);
    }
}
Also used : LogoutClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.LogoutClickListener) Button(com.vaadin.ui.Button) LogoutRequest(com.hack23.cia.service.api.action.application.LogoutRequest) Link(com.vaadin.ui.Link)

Example 2 with LogoutClickListener

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;
}
Also used : LogoutClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.LogoutClickListener) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) LogoutRequest(com.hack23.cia.service.api.action.application.LogoutRequest) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

LogoutRequest (com.hack23.cia.service.api.action.application.LogoutRequest)2 LogoutClickListener (com.hack23.cia.web.impl.ui.application.views.pageclicklistener.LogoutClickListener)2 Button (com.vaadin.ui.Button)2 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)1 Link (com.vaadin.ui.Link)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Secured (org.springframework.security.access.annotation.Secured)1