// File: ActionSaveall.java
// Classes: ActionSaveall
// Author: Kedar Patankar
// Last modified : 22 Oct 1997
package EDU.neu.ccs.demeter.tools.apstudio.graphedit;

import java.util.Vector;
import java.util.Enumeration;
import com.sun.java.swing.tree.DefaultMutableTreeNode;


/**Action to save all files.*/

public class ActionSaveallBeh extends Action
{
	DefaultMutableTreeNode _root;
	public ActionSaveallBeh(Editor e,DefaultMutableTreeNode root)
	{
		super(e);_root=root;
	}

	public String name() { return "Save All Files"; }

	public void doIt() 
	{
		// If there are no behaviors opened in the strategy panel return. Should never happen
		if(_root.getChildCount()<1)
			return ;

		// separate into modified and non-modified nodes.
		Enumeration enum = _root.children();
		Vector vSave = new Vector();
		while(enum.hasMoreElements())
		{
			DefaultMutableTreeNode node = (DefaultMutableTreeNode)enum.nextElement();
			if(((BehaviorNode)node.getUserObject()).needsSaving())
				vSave.addElement(node);
		}
// Files those need saving are saved

		int size =  vSave.size();
		for(int i=0;i<size;i++)
		{
			ActionSaveBeh act= new ActionSaveBeh(_editor,(DefaultMutableTreeNode)vSave.elementAt(i));
			if(!act.executeIt())
				return;
		}	
	}

	public void undoIt() { }
} /* end class ActionSaveall */
