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

io.imunity.console.views.translation_profiles.TranslationsView Maven / Gradle / Ivy

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

package io.imunity.console.views.translation_profiles;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;

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.html.NativeLabel;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.RouterLink;

import io.imunity.console.utils.ObjectToJsonFileExporterHelper;
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 pl.edu.icm.unity.base.message.MessageSource;
import pl.edu.icm.unity.base.translation.ProfileMode;
import pl.edu.icm.unity.base.translation.TranslationProfile;
import pl.edu.icm.unity.engine.api.utils.MessageUtils;
import io.imunity.vaadin.endpoint.common.exceptions.ControllerException;

public abstract class TranslationsView extends ConsoleViewComponent
{
	protected final MessageSource msg;
	protected final TranslationsServiceBase controller;
	protected final NotificationPresenter notificationPresenter;
	private GridWithActionColumn profileList;

	@Autowired
	public TranslationsView(MessageSource msg, TranslationsServiceBase controller,
			NotificationPresenter notificationPresenter)
	{
		this.msg = msg;
		this.controller = controller;
		this.notificationPresenter = notificationPresenter;
		init();
	}

	private void init()
	{
		profileList = new GridWithActionColumn<>(msg::getMessage, getActionsHandlers());
		Column name = profileList
				.addComponentColumn(e -> new RouterLink(e.getName(), getEditView(), e.getName()))
				.setHeader(msg.getMessage("TranslationProfilesView.nameCaption"))
				.setAutoWidth(true)
				.setSortable(true)
				.setComparator(Comparator.comparing(r -> r.getName()));

		refreshProfileList();

		VerticalLayout main = new VerticalLayout();
		main.setSizeFull();
		NativeLabel title = new NativeLabel(getHeaderCaption());
		main.add(title);
		List




© 2015 - 2025 Weber Informatics LLC | Privacy Policy