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

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

import java.util.Vector;

public class ActionCloseall extends Action
{
	public ActionCloseall(Editor e)
	{
		super(e);
	}

	public String name() { return "Close All Files"; }

	public void doIt() 
	{
		Vector all = _editor.get_openDocnames();
		Vector non = _editor.get_outStanding();
		Vector vClose = new Vector();
		Vector vSaveNClose = new Vector();

		int j=all.size();
		for(int i=0;i<j;i++)
		{
			String name = (String) all.elementAt(i);
			if(non.contains(name))
				vSaveNClose.addElement(name);
			else
				vClose.addElement(name);
		}
		j=vClose.size();
		for(int i=0;i<j;i++)
		{
			ActionClose act= new ActionClose(_editor,_editor.getDocument((String) vClose.elementAt(i)));
			act.doIt();
		}


// Files those need saving are passed to ActionCloseMultiple to handle
		ActionCloseMultipleCds act = new ActionCloseMultipleCds(_editor,vSaveNClose); 
		act.doIt(); // This can come out inbetween because user clicked cancel sometime during saving.
	}

	public void undoIt() { }

} /* end class ActionCloseall */

