// Copyright (c) 1995, 1996 Regents of the University of California.
// All rights reserved.
//
// This software was developed by the Arcadia project
// at the University of California, Irvine.
//
// Redistribution and use in source and binary forms are permitted
// provided that the above copyright notice and this paragraph are
// duplicated in all such forms and that any documentation,
// advertising materials, and other materials related to such
// distribution and use acknowledge that the software was developed
// by the University of California, Irvine.  The name of the
// University may not be used to endorse or promote products derived
// from this software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

// File: ActionSelectInvert.java
// Classes: ActionSelectInvert
// Original Author: jrobbins@ics.uci.edu
// $Id: ActionSelectInvert.java,v 1.2 1997/06/10 23:42:22 jrobbins Exp $

// Modified by : Kedar Patankar
// Last Modified 22 Oct 1997

package EDU.neu.ccs.demeter.tools.apstudio.graphedit;

import java.util.Vector;
import java.util.Enumeration;

/** Action to select all the DiagramElements in the editor's current
 *  view that were not previously selected.
*/

public class ActionSelectInvert extends Action 
{
	public ActionSelectInvert(Document d) {super(d);}
	
	public String name() { return "Inverts the selection in Layer"; }

	public void doIt() 
	{
		Document ce = _document;
		Vector selected = ce.selectedDEs();
		Vector diagramContents = ce.view().contents();
		Vector inverse = new Vector(diagramContents.size());
		Enumeration contEnum = diagramContents.elements();
		while (contEnum.hasMoreElements()) 
		{
			Object dc = contEnum.nextElement();
			if (!selected.contains(dc)) inverse.addElement(dc);
		}
		ce.selectItems(inverse);
	}

	public void undoIt() 
	{
//		System.out.println("Undo does not make sense for ActionSelectInvert");
	}
} /* end class ActionSelectInvert */


