/* * Copyright (c) 2006, 2007 Borland Software Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Richard Gronback (Borland) - initial API and implementation */ package org.eclipse.gmf.examples.mindmap.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.diagram.edit.parts.ThreadItemEditPart; import org.eclipse.gmf.examples.mindmap.diagram.edit.parts.ThreadThreadItemCompartmentEditPart; import org.eclipse.gmf.examples.mindmap.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; } } } }