package org.eclipse.uml2.diagram.timing.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.runtime.emf.type.core.commands.DestroyElementCommand; import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; import org.eclipse.gmf.runtime.notation.Node; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.uml2.diagram.timing.edit.commands.DTickCreateCommand; import org.eclipse.uml2.diagram.timing.edit.commands.DValueLineCreateCommand; import org.eclipse.uml2.diagram.timing.edit.parts.DTickEditPart; import org.eclipse.uml2.diagram.timing.edit.parts.DValueLineEditPart; import org.eclipse.uml2.diagram.timing.model.timingd.TimingDPackage; import org.eclipse.uml2.diagram.timing.part.TimingDVisualIDRegistry; import org.eclipse.uml2.diagram.timing.providers.TimingDElementTypes; /** * @generated */ public class DBlockItemSemanticEditPolicy extends TimingDBaseItemSemanticEditPolicy { /** * @generated */ public DBlockItemSemanticEditPolicy() { super(TimingDElementTypes.DBlock_3001); } /** * @generated */ protected Command getCreateCommand(CreateElementRequest req) { if (TimingDElementTypes.DValueLine_3002 == req.getElementType()) { if (req.getContainmentFeature() == null) { req.setContainmentFeature(TimingDPackage.eINSTANCE.getDBlock_States()); } return getGEFWrapper(new DValueLineCreateCommand(req)); } if (TimingDElementTypes.DTick_3007 == req.getElementType()) { if (req.getContainmentFeature() == null) { req.setContainmentFeature(TimingDPackage.eINSTANCE.getDBlock_Ticks()); } return getGEFWrapper(new DTickCreateCommand(req)); } return super.getCreateCommand(req); } /** * @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 (TimingDVisualIDRegistry.getVisualID(node)) { case DValueLineEditPart.VISUAL_ID: cmd.add(getDestroyElementCommand(node)); break; case DTickEditPart.VISUAL_ID: cmd.add(getDestroyElementCommand(node)); break; } } } }