package org.eclipse.gmf.examples.mindmap.rcp.diagram.edit.policies; import java.util.Iterator; import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.gef.commands.Command; import org.eclipse.gef.commands.CompoundCommand; import org.eclipse.gmf.examples.mindmap.rcp.diagram.edit.parts.ThreadItemEditPart; import org.eclipse.gmf.examples.mindmap.rcp.diagram.edit.parts.ThreadThreadItemCompartmentEditPart; import org.eclipse.gmf.examples.mindmap.rcp.diagram.part.MindmapVisualIDRegistry; import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand; import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; import org.eclipse.gmf.runtime.notation.Node; import org.eclipse.gmf.runtime.notation.View; /** * @generated */ public class ThreadItemSemanticEditPolicy extends MindmapBaseItemSemanticEditPolicy { /** * @generated */ protected Command getDestroyElementCommand(DestroyElementRequest req) { CompoundCommand cc = getDestroyEdgesCommand(); addDestroyChildNodesCommand(cc); addDestroyShortcutsCommand(cc); cc.add(getGEFWrapper(new DestroyElementCommand(req))); return cc.unwrap(); } /** * @generated */ protected void addDestroyChildNodesCommand(CompoundCommand cmd) { View view = (View) getHost().getModel(); EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ if (annotation != null) { return; } for (Iterator it = view.getChildren().iterator(); it.hasNext();) { Node node = (Node) it.next(); switch (MindmapVisualIDRegistry.getVisualID(node)) { case ThreadThreadItemCompartmentEditPart.VISUAL_ID: for (Iterator cit = node.getChildren().iterator(); cit .hasNext();) { Node cnode = (Node) cit.next(); switch (MindmapVisualIDRegistry.getVisualID(cnode)) { case ThreadItemEditPart.VISUAL_ID: cmd.add(getDestroyElementCommand(cnode)); break; } } break; } } } }