All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.edu.icm.unity.home.HomeTopHeader Maven / Gradle / Ivy

There is a newer version: 3.3.4
Show newest version
/*
 * Copyright (c) 2019 Bixbit - Krzysztof Benedyczak. All rights reserved.
 * See LICENCE.txt file for licensing information.
 */

package pl.edu.icm.unity.home;

import java.util.Optional;

import com.vaadin.server.Page;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;

import pl.edu.icm.unity.MessageSource;
import pl.edu.icm.unity.webui.authn.StandardWebAuthenticationProcessor;
import pl.edu.icm.unity.webui.common.Images;
import pl.edu.icm.unity.webui.common.Styles;
import pl.edu.icm.unity.webui.common.TopHeader;

/**
 * 
 * Top header for home UI.
 *
 * @author P.Piernik
 */
public class HomeTopHeader extends TopHeader
{
	private Optional projectManLink;

	public HomeTopHeader(String title, StandardWebAuthenticationProcessor authnProcessor, MessageSource msg,
			Optional upManLink)
	{
		super(title, authnProcessor, msg);
		this.projectManLink = upManLink;
		addButtons();
	}

	private void addButtons()
	{		
		if (projectManLink.isPresent())
		{
			Button goToProjectMan = createProjectManLinkButton();
			loggedPanel.addComponent(goToProjectMan);
			loggedPanel.setComponentAlignment(goToProjectMan, Alignment.MIDDLE_RIGHT);	
		}
		
		Button logout = createLogoutButton();
		loggedPanel.addComponent(logout);
		loggedPanel.setComponentAlignment(logout, Alignment.MIDDLE_RIGHT);
	}

	Button createProjectManLinkButton()
	{
		Button goToProjectMan = new Button();
		goToProjectMan.setIcon(Images.family.getResource());
		goToProjectMan.setDescription(msg.getMessage("HomeUIHeader.toProjectManagement"));
		goToProjectMan.addStyleName(Styles.vButtonLink.toString());
		goToProjectMan.addStyleName(Styles.largeIcon.toString());
		goToProjectMan.addClickListener(e -> Page.getCurrent().open(projectManLink.get(), null));
		return goToProjectMan;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy