/*
 * Created on Aug 11, 2003
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package APStudio.editparts;
import java.util.List;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.editpolicies.ContainerEditPolicy;
import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gef.requests.GroupRequest;
import APStudio.models.*;
import APStudio.models.commands.OrphanChildCommand;
/**
 * @author srajagop
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class APContainerEditPolicy extends ContainerEditPolicy {

	/* (non-Javadoc)
	 * @see org.eclipse.gef.editpolicies.ContainerEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
	 */
	protected Command getCreateCommand(CreateRequest request) {
		System.out.println("ContainerEditpolicy.getOrphanChildrenCommand:");
		return null;
	}

	public Command getOrphanChildrenCommand(GroupRequest request) {
		System.out.println("ContainerEditpolicy.getOrphanChildrenCommand:");
		List parts = request.getEditParts();
		CompoundCommand result = 
			new CompoundCommand("OrphanCommandLabel");
		for (int i = 0; i < parts.size(); i++) {
			OrphanChildCommand orphan = new OrphanChildCommand();
			orphan.setChild((BasicSubpart)((EditPart)parts.get(i)).getModel());
			orphan.setParent((ClassGraphModel)getHost().getModel());
			orphan.setLabel("OrphanCommandLabel");
			result.add(orphan);
		}
		return result.unwrap();
	}
}
