// File: ActionRevert.java
// Classes: ActionRevert
// Author: Kedar Patankar

package edu.neu.ccs.demeter.tools.apstudio.graphedit;

public class ActionRevert extends Action
{

	private String _filename;
	private ActionOpen _ao;
	public ActionRevert(Editor editor,String filename,ActionOpen ao) 
	{
		super(editor);
		_filename=filename;
		_ao=ao;
	}

    public String name() { return "Revert back to last saved copy"; }
    public void doIt() 
	{
		String title="Confirm File Open";
		String message1="File Already open";
		String message2="Want to revert back to the last saved version ?";
		String buttonString="YN";
		AlarmDialog ad = new AlarmDialog(_editor,title,message1,message2,buttonString,"N");
		ad.setVisible(true);

		if(ad.getChoice().equals("YES"))
		{
			_editor.detach(_filename);
			_ao.goAheadandOpen();
		}
		else
		{
			_editor.showDocument(_filename);
			_editor.setCurrentMenuString(_filename);
		}
	}

	public void undoIt() { }
	
} /* end class ActionRevert */

