// Path: src/main/java/re/vianneyfaiv/persephone/domain/app/Application.java
// public class Application {
// 
// 	private int id;
// 	private String name;
// 	private String environment;
// 	private String url;
// 	private boolean up; // set when application is clicked
// 	private Endpoints endpoints;
// 	private AuthScheme authScheme;
// 	private String actuatorUsername;
// 	private String actuatorPassword;
// 	private ActuatorVersion actuatorVersion; // set when application is clicked
// 
// 	/**
// 	 * Application without HTTP Auth
// 	 */
// 	public Application(int id, String name, String environment, String url) {
// 		this.id = id;
// 		this.name = name;
// 		this.environment = environment;
// 		this.url = url;
// 		this.endpoints = new Endpoints(url);
// 		this.authScheme = AuthScheme.NONE;
// 	}
// 
// 	/**
// 	 * Application with HTTP Auth Basic enabled
// 	 */
// 	public Application(int id, String name, String environment, String url, String username, String password) {
// 		this.id = id;
// 		this.name = name;
// 		this.environment = environment;
// 		this.url = url;
// 		this.endpoints = new Endpoints(url);
// 		this.authScheme = AuthScheme.BASIC;
// 		this.actuatorUsername = username;
// 		this.actuatorPassword = password;
// 	}
// 
// 	public boolean isAuthValid() {
// 		if(AuthScheme.BASIC == authScheme) {
// 			return !StringUtils.isEmpty(actuatorUsername) && !StringUtils.isEmpty(actuatorPassword);
// 		}
// 
// 		return true;
// 	}
// 
// 	public int getId() {
// 		return this.id;
// 	}
// 
// 	public String getName() {
// 		return this.name;
// 	}
// 
// 	public String getEnvironment() {
// 		return this.environment;
// 	}
// 
// 	public String getUrl() {
// 		return this.url;
// 	}
// 
// 	public void setUp(boolean up) {
// 		this.up = up;
// 	}
// 
// 	public boolean isUp() {
// 		return this.up;
// 	}
// 
// 	public Endpoints endpoints() {
// 		return this.endpoints;
// 	}
// 
// 	public AuthScheme getAuthScheme() {
// 		return authScheme;
// 	}
// 
// 	public String getActuatorUsername() {
// 		return actuatorUsername;
// 	}
// 
// 	public String getActuatorPassword() {
// 		return actuatorPassword;
// 	}
// 
// 	public ActuatorVersion getActuatorVersion() {
// 		return actuatorVersion;
// 	}
// 
// 	public void setActuatorVersion(ActuatorVersion actuatorVersion) {
// 		this.actuatorVersion = actuatorVersion;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "Application [id=" + id + ", name=" + name + ", environment=" + environment + ", url=" + url + ", up="
// 				+ up + ", authScheme=" + authScheme + "]";
// 	}
// }
// 
// Path: src/main/java/re/vianneyfaiv/persephone/ui/PersephoneViews.java
// public class PersephoneViews {
// 	/**
// 	 * {@link ApplicationsPage}
// 	 */
// 	public static final String APPLICATIONS = "";
// 
// 	/**
// 	 * {@link PropertiesPage}
// 	 */
// 	public static final String PROPERTIES = "properties";
// 
// 	/**
// 	 * {@link LogsPage}
// 	 */
// 	public static final String LOGS = "logs";
// 
// 	/**
// 	 * {@link EndpointsPage}
// 	 */
// 	public static final String ENDPOINTS = "endpoints";
// 
// 	/**
// 	 * {@link LoggersPage}
// 	 */
// 	public static final String LOGGERS = "loggers";
// 
// 
// 	/**
// 	 * {@link MetricsPage}
// 	 */
// 	public static final String METRICS = "metrics";
// 
// 	/**
// 	 * {@link TracePage}
// 	 */
// 	public static final String TRACE = "trace";
// }


import com.vaadin.icons.VaadinIcons;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import re.vianneyfaiv.persephone.domain.app.Application;
import re.vianneyfaiv.persephone.ui.PersephoneViews;
package re.vianneyfaiv.persephone.ui.component;



/**
 * Page header based on current application.
 *
 * Contains a title and a button bar
 */
public class PageHeader extends VerticalLayout {

	/**
	 * @param components components that will be added horizontally before the back button
	 */
	public PageHeader(Application app, String subtitle, Component... components) {

		this.addComponent(getTitle(app, subtitle));
		this.addComponent(getButtons(components));

		this.setMargin(false);
	}

	private HorizontalLayout getTitle(Application app, String subtitle) {
		Label title = new Label(String.format("<h2>%s (%s): %s</h2>", app.getName(), app.getEnvironment(), subtitle), ContentMode.HTML);

		return new HorizontalLayout(title);
	}

	private HorizontalLayout getButtons(Component... components) {
		Button backButton = new Button("Go Back", VaadinIcons.BACKSPACE_A);
		backButton.setId("back-btn");
// Path: src/main/java/re/vianneyfaiv/persephone/domain/app/Application.java
// public class Application {
// 
// 	private int id;
// 	private String name;
// 	private String environment;
// 	private String url;
// 	private boolean up; // set when application is clicked
// 	private Endpoints endpoints;
// 	private AuthScheme authScheme;
// 	private String actuatorUsername;
// 	private String actuatorPassword;
// 	private ActuatorVersion actuatorVersion; // set when application is clicked
// 
// 	/**
// 	 * Application without HTTP Auth
// 	 */
// 	public Application(int id, String name, String environment, String url) {
// 		this.id = id;
// 		this.name = name;
// 		this.environment = environment;
// 		this.url = url;
// 		this.endpoints = new Endpoints(url);
// 		this.authScheme = AuthScheme.NONE;
// 	}
// 
// 	/**
// 	 * Application with HTTP Auth Basic enabled
// 	 */
// 	public Application(int id, String name, String environment, String url, String username, String password) {
// 		this.id = id;
// 		this.name = name;
// 		this.environment = environment;
// 		this.url = url;
// 		this.endpoints = new Endpoints(url);
// 		this.authScheme = AuthScheme.BASIC;
// 		this.actuatorUsername = username;
// 		this.actuatorPassword = password;
// 	}
// 
// 	public boolean isAuthValid() {
// 		if(AuthScheme.BASIC == authScheme) {
// 			return !StringUtils.isEmpty(actuatorUsername) && !StringUtils.isEmpty(actuatorPassword);
// 		}
// 
// 		return true;
// 	}
// 
// 	public int getId() {
// 		return this.id;
// 	}
// 
// 	public String getName() {
// 		return this.name;
// 	}
// 
// 	public String getEnvironment() {
// 		return this.environment;
// 	}
// 
// 	public String getUrl() {
// 		return this.url;
// 	}
// 
// 	public void setUp(boolean up) {
// 		this.up = up;
// 	}
// 
// 	public boolean isUp() {
// 		return this.up;
// 	}
// 
// 	public Endpoints endpoints() {
// 		return this.endpoints;
// 	}
// 
// 	public AuthScheme getAuthScheme() {
// 		return authScheme;
// 	}
// 
// 	public String getActuatorUsername() {
// 		return actuatorUsername;
// 	}
// 
// 	public String getActuatorPassword() {
// 		return actuatorPassword;
// 	}
// 
// 	public ActuatorVersion getActuatorVersion() {
// 		return actuatorVersion;
// 	}
// 
// 	public void setActuatorVersion(ActuatorVersion actuatorVersion) {
// 		this.actuatorVersion = actuatorVersion;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "Application [id=" + id + ", name=" + name + ", environment=" + environment + ", url=" + url + ", up="
// 				+ up + ", authScheme=" + authScheme + "]";
// 	}
// }
// 
// Path: src/main/java/re/vianneyfaiv/persephone/ui/PersephoneViews.java
// public class PersephoneViews {
// 	/**
// 	 * {@link ApplicationsPage}
// 	 */
// 	public static final String APPLICATIONS = "";
// 
// 	/**
// 	 * {@link PropertiesPage}
// 	 */
// 	public static final String PROPERTIES = "properties";
// 
// 	/**
// 	 * {@link LogsPage}
// 	 */
// 	public static final String LOGS = "logs";
// 
// 	/**
// 	 * {@link EndpointsPage}
// 	 */
// 	public static final String ENDPOINTS = "endpoints";
// 
// 	/**
// 	 * {@link LoggersPage}
// 	 */
// 	public static final String LOGGERS = "loggers";
// 
// 
// 	/**
// 	 * {@link MetricsPage}
// 	 */
// 	public static final String METRICS = "metrics";
// 
// 	/**
// 	 * {@link TracePage}
// 	 */
// 	public static final String TRACE = "trace";
// }


// Path: src/main/java/re/vianneyfaiv/persephone/ui/component/PageHeader.java
import com.vaadin.icons.VaadinIcons;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import re.vianneyfaiv.persephone.domain.app.Application;
import re.vianneyfaiv.persephone.ui.PersephoneViews;

package re.vianneyfaiv.persephone.ui.component;



/**
 * Page header based on current application.
 *
 * Contains a title and a button bar
 */
public class PageHeader extends VerticalLayout {

	/**
	 * @param components components that will be added horizontally before the back button
	 */
	public PageHeader(Application app, String subtitle, Component... components) {

		this.addComponent(getTitle(app, subtitle));
		this.addComponent(getButtons(components));

		this.setMargin(false);
	}

	private HorizontalLayout getTitle(Application app, String subtitle) {
		Label title = new Label(String.format("<h2>%s (%s): %s</h2>", app.getName(), app.getEnvironment(), subtitle), ContentMode.HTML);

		return new HorizontalLayout(title);
	}

	private HorizontalLayout getButtons(Component... components) {
		Button backButton = new Button("Go Back", VaadinIcons.BACKSPACE_A);
		backButton.setId("back-btn");
		backButton.addClickListener(e -> getUI().getNavigator().navigateTo(PersephoneViews.APPLICATIONS));