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

io.imunity.upman.console.UpmanServiceEditorGeneralTab Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2019 Bixbit - Krzysztof Benedyczak. All rights reserved.
 * See LICENCE.txt file for licensing information.
 */

package io.imunity.upman.console;

import static io.imunity.vaadin.elements.CssClassNames.MEDIUM_VAADIN_FORM_ITEM_LABEL;

import java.util.List;
import java.util.Set;

import com.vaadin.flow.component.accordion.AccordionPanel;
import com.vaadin.flow.component.checkbox.Checkbox;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.data.binder.Binder;

import io.imunity.vaadin.auth.services.DefaultServiceDefinition;
import io.imunity.vaadin.auth.services.tabs.GeneralTab;
import pl.edu.icm.unity.base.endpoint.EndpointTypeDescription;
import pl.edu.icm.unity.base.message.MessageSource;

public class UpmanServiceEditorGeneralTab extends GeneralTab
{
	private Binder upmanBinder;
	private List homeServices;

	public UpmanServiceEditorGeneralTab(MessageSource msg, EndpointTypeDescription type,
			List usedEndpointsPaths, List usedNames, Set serverContextPaths, List homeServices)
	{
		super(msg, type, usedEndpointsPaths, usedNames, serverContextPaths);
		this.homeServices = homeServices;
	}

	public void initUI(Binder binder, Binder homeBinder,
			boolean editMode)
	{
		super.initUI(binder, editMode);
		this.upmanBinder = homeBinder;
		add(buildContentSection());
	}

	private AccordionPanel buildContentSection()
	{
		FormLayout main = new FormLayout();
		main.setResponsiveSteps(new FormLayout.ResponsiveStep("0", 1));
		main.addClassName(MEDIUM_VAADIN_FORM_ITEM_LABEL.getName());

		Checkbox enableHome = new Checkbox();
		upmanBinder.forField(enableHome)
				.bind("enableHome");
		enableHome.setLabel(msg.getMessage("UpmanServiceEditorGeneralTab.enableHome"));
		main.addFormItem(enableHome, "");

		ComboBox homeService = new ComboBox<>();
		homeService.setEnabled(false);
		homeService.setItems(homeServices);
		upmanBinder.forField(homeService)
				.bind("homeService");
		main.addFormItem(homeService, msg.getMessage("UpmanServiceEditorGeneralTab.homeService"));

		enableHome.addValueChangeListener(e ->
		{
			homeService.setEnabled(e.getValue());
		});

		AccordionPanel contentSection = new AccordionPanel(msg.getMessage("UpmanServiceEditorGeneralTab.content"),
				main);
		contentSection.setOpened(true);
		contentSection.setWidthFull();
		return contentSection;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy