package org.openhealthtools.mdht.uml.ui.navigator.actions;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.command.DeleteCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.action.DeleteAction;
import org.eclipse.uml2.uml.Association;

public class DeleteUMLAction extends DeleteAction {

	public DeleteUMLAction(EditingDomain domain, boolean removeAllReferences) {
		super(domain, removeAllReferences);
	}

	public DeleteUMLAction(EditingDomain domain) {
		super(domain);
	}

	public DeleteUMLAction(boolean removeAllReferences) {
		super(removeAllReferences);
	}

	public DeleteUMLAction() {
		super();
	}

	@Override
	public Command createCommand(Collection<?> selection) {
		List<Object> elements = new ArrayList<Object>();
		for (Object object : selection) {
			if (object instanceof Association) {
				Association association = (Association) object;
				elements.addAll(association.getMemberEnds());
				elements.add(association);
			} else {
				elements.add(object);
			}
		}

		return removeAllReferences
				? DeleteCommand.create(domain, elements)
				: RemoveCommand.create(domain, elements);
	}

}

@@ -437,16 +437,91 @@
 iation;%0D
+%0Aimport org.eclipse.uml2.uml.Class;%0D%0Aimport org.eclipse.uml2.uml.Property;%0D
 %0A%0D%0Apubli
@@ -1090,16 +1090,298 @@
 tanceof 
+Class) %7B%0D%0A%09%09%09%09Class umlClass = (Class) object;%0D%0A%09%09%09%09for (Property property : umlClass.getOwnedAttributes()) %7B%0D%0A%09%09%09%09%09if (property.getAssociation() != null) %7B%0D%0A%09%09%09%09%09%09elements.add(property.getAssociation());%0D%0A%09%09%09%09%09%7D%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%09elements.add(umlClass);%0D%0A%09%09%09%7D else if (object instanceof 
 Associat

Fix for artf2847 : Deleting a Class should also delete Associations from that class