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

io.imunity.console.views.services.base.ServicesViewBase Maven / Gradle / Ivy

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

package io.imunity.console.views.services.base;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;

import com.google.common.collect.Sets;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.confirmdialog.ConfirmDialog;
import com.vaadin.flow.component.grid.Grid.Column;
import com.vaadin.flow.component.grid.GridSortOrder;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.data.provider.SortDirection;
import com.vaadin.flow.router.QueryParameters;
import com.vaadin.flow.router.RouterLink;

import io.imunity.console.views.CommonViewParam;
import io.imunity.console.views.ConsoleViewComponent;
import io.imunity.console.views.ShowViewActionLayoutFactory;
import io.imunity.vaadin.elements.NotificationPresenter;
import io.imunity.vaadin.elements.grid.GridWithActionColumn;
import io.imunity.vaadin.elements.grid.SingleActionHandler;
import io.imunity.vaadin.auth.services.ServiceDefinition;
import io.imunity.vaadin.auth.services.ServiceEditorComponent.ServiceEditorTab;
import io.imunity.vaadin.auth.services.ServiceTypeInfoHelper;
import pl.edu.icm.unity.base.endpoint.Endpoint.EndpointState;
import pl.edu.icm.unity.base.message.MessageSource;
import pl.edu.icm.unity.engine.api.utils.MessageUtils;

import io.imunity.vaadin.endpoint.common.exceptions.ControllerException;

/**
 * 
 * @author P.Piernik
 *
 */

public abstract class ServicesViewBase extends ConsoleViewComponent
{
	protected final MessageSource msg;
	private final NotificationPresenter notificationPresenter;
	private final ServiceControllerBase controller;
	private final Class newServiceViewName;
	private final Class editServiceViewName;
	private GridWithActionColumn servicesGrid;

	public ServicesViewBase(MessageSource msg, NotificationPresenter notificationPresenter,
			ServiceControllerBase controller, Class newServiceViewName,
			Class editServiceViewName)
	{
		this.msg = msg;
		this.notificationPresenter = notificationPresenter;
		this.controller = controller;
		this.newServiceViewName = newServiceViewName;
		this.editServiceViewName = editServiceViewName;
	}

	protected void initUI()
	{

		servicesGrid = new GridWithActionColumn<>(msg::getMessage, getActionsHandlers());
		Column name = servicesGrid
				.addComponentColumn(e -> new RouterLink(e.getName(), editServiceViewName, e.getName()))
				.setHeader(msg.getMessage("ServicesView.nameCaption"))
				.setAutoWidth(true)
				.setSortable(true)
				.setComparator(Comparator.comparing(r -> r.getName()));
		servicesGrid.addComponentColumn(e -> getStatusLabel(e.getState()))
				.setHeader(msg.getMessage("ServicesView.statusCaption"));
		servicesGrid.addColumn(e -> ServiceTypeInfoHelper.getType(msg, e.getType()))
				.setHeader(msg.getMessage("ServicesView.typeCaption"));
		servicesGrid.addColumn(e -> ServiceTypeInfoHelper.getBinding(msg, e.getBinding()))
				.setHeader(msg.getMessage("ServicesView.bindingCaption"));
		servicesGrid.addHamburgerActions(getHamburgerActionsHandlers());
		servicesGrid.setItems(getServices());
		servicesGrid.sort(List.of(new GridSortOrder<>(name, SortDirection.ASCENDING)));
		servicesGrid.setAllRowsVisible(true);
		
		List




© 2015 - 2025 Weber Informatics LLC | Privacy Policy