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

pl.edu.icm.unity.webadmin.credreq.CredentialRequirementEditDialog Maven / Gradle / Ivy

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

import com.vaadin.ui.Component;

import io.imunity.webadmin.credentialRequirements.CredentialRequirementEditor;
import pl.edu.icm.unity.MessageSource;
import pl.edu.icm.unity.exceptions.IllegalCredentialException;
import pl.edu.icm.unity.types.authn.CredentialRequirements;
import pl.edu.icm.unity.webui.common.AbstractDialog;
import pl.edu.icm.unity.webui.common.NotificationPopup;

/**
 * Dialog allowing to edit a credential requirement. It takes an editor component 
 * as argument, so can be easily used to display edit dialog for an existing CR or CR creation dialog.
 * @author K. Benedyczak
 */
public class CredentialRequirementEditDialog extends AbstractDialog
{
	private CredentialRequirementEditor editor;
	private Callback callback;
	
	public CredentialRequirementEditDialog(MessageSource msg, String caption, 
			CredentialRequirementEditor attributeEditor, Callback callback)
	{
		super(msg, caption);
		this.editor = attributeEditor;
		this.callback = callback;
	}

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

	@Override
	protected void onConfirm()
	{
		try
		{
			CredentialRequirements cr = editor.getCredentialRequirements();
			if (callback.newCredentialRequirement(cr))
				close();
		} catch (IllegalCredentialException e) 
		{
			NotificationPopup.showFormError(msg);
			return;
		}
	}
	
	public interface Callback
	{
		public boolean newCredentialRequirement(CredentialRequirements cr);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy