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

pl.edu.icm.unity.webadmin.bulk.RuleEditDialog Maven / Gradle / Ivy

There is a newer version: 3.3.4
Show newest version
/*
 * Copyright (c) 2016 ICM Uniwersytet Warszawski All rights reserved.
 * See LICENCE.txt file for licensing information.
 */
package pl.edu.icm.unity.webadmin.bulk;

import java.util.function.Consumer;

import com.vaadin.ui.Component;

import io.imunity.webadmin.bulk.RuleEditor;
import pl.edu.icm.unity.MessageSource;
import pl.edu.icm.unity.types.translation.TranslationRule;
import pl.edu.icm.unity.webui.common.AbstractDialog;
import pl.edu.icm.unity.webui.common.FormValidationException;
import pl.edu.icm.unity.webui.common.NotificationPopup;

/**
 * Editor dialog for rule editing.
 * @author K. Benedyczak
 */
public class RuleEditDialog extends AbstractDialog
{
	private Consumer callback;
	private RuleEditor editor;

	public RuleEditDialog(MessageSource msg, String caption, RuleEditor editor,
			Consumer callback)
	{
		super(msg, caption);
		this.editor = editor;
		this.callback = callback;
	}

	@Override
	protected Component getContents() throws Exception
	{
		return editor;
	}

	@Override
	protected void onConfirm()
	{
		try
		{
			callback.accept(editor.getRule());
		} catch (FormValidationException e)
		{
			NotificationPopup.showFormError(msg);
			return;
		}
		close();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy