package lu.tudor.santec.gecamed.core.gui.widgets.autocompletion;

import javax.swing.JDialog;
import javax.swing.JFrame;

import lu.tudor.santec.org.fife.ui.autocomplete.dialog.EditCompletionDialog;

public class GECAMedEditCompletionDialog extends EditCompletionDialog
{
	private static final long serialVersionUID = 1L;
	
	
	public GECAMedEditCompletionDialog(JDialog owner, GECAMedAutoCompletionTextComponent textArea)
	{
		super(owner, textArea);
	}
	
	public GECAMedEditCompletionDialog(JFrame owner, GECAMedAutoCompletionTextComponent textArea)
	{
		super(owner, textArea);
	}
	
	@Override
	protected void add()
	{
		GECAMedSaveCompletionDialog dialog 		= new GECAMedSaveCompletionDialog(this, 
				(GECAMedAutoCompletionTextComponent) view);
		dialog.setReplacementText("");
		dialog.setVisible(true);
		search();
	}
	
	@Override
	protected void edit()
	{
		GECAMedAutoCompletion oldCompletion 	= (GECAMedAutoCompletion)resultList.getSelectedValue();
		
		GECAMedChangeCompletionDialog change 	= new GECAMedChangeCompletionDialog(this,
				(GECAMedAutoCompletionTextComponent)view, oldCompletion);
		change.setVisible(true);
		
		if (change.isChanged())
			search();
	}
}
