blob: ccb3375a339d5699c674865c56f6111e9bb3c361 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/***************************************************************************
* Copyright (c) 2007 Conselleria de Infraestructuras y Transporte,
* Generalitat de la Comunitat Valenciana . 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: Gabriel Merin Cubero (Prodevelop) – Sequence Diagram implementation
*
******************************************************************************/
package org.eclipse.papyrus.diagram.sequence.edit.policies;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
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.Diagram;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.papyrus.diagram.common.util.DiagramEditPartsUtil;
import org.eclipse.papyrus.diagram.common.util.MultiDiagramUtil;
import org.eclipse.papyrus.diagram.sequence.edit.commands.CombinedFragmentCreateCommand;
import org.eclipse.papyrus.diagram.sequence.edit.commands.Interaction2CreateCommand;
import org.eclipse.papyrus.diagram.sequence.edit.commands.LifelineCreateCommand;
import org.eclipse.papyrus.diagram.sequence.providers.UMLElementTypes;
/**
* @generated
*/
public class InteractionInteractionCompartmentItemSemanticEditPolicy extends
UMLBaseItemSemanticEditPolicy {
/**
* @generated
*/
@Override
protected Command getCreateCommand(CreateElementRequest req) {
Diagram diagram = DiagramEditPartsUtil
.findDiagramFromEditPart(getHost());
if (diagram != null) {
req.getParameters().put(MultiDiagramUtil.BelongToDiagramSource,
diagram);
}
if (UMLElementTypes.Interaction_2001 == req.getElementType()) {
if (req.getContainmentFeature() == null) {
req.setContainmentFeature(UMLPackage.eINSTANCE
.getInteraction_Fragment());
}
return getGEFWrapper(new Interaction2CreateCommand(req));
}
if (UMLElementTypes.Lifeline_2002 == req.getElementType()) {
if (req.getContainmentFeature() == null) {
req.setContainmentFeature(UMLPackage.eINSTANCE
.getInteraction_Lifeline());
}
return getGEFWrapper(new LifelineCreateCommand(req));
}
if (UMLElementTypes.CombinedFragment_2004 == req.getElementType()) {
if (req.getContainmentFeature() == null) {
req.setContainmentFeature(UMLPackage.eINSTANCE
.getInteraction_Fragment());
}
return getGEFWrapper(new CombinedFragmentCreateCommand(req));
}
return super.getCreateCommand(req);
}
/**
* @generated
*/
@Override
protected Command getDestroyElementCommand(DestroyElementRequest req) {
return getHost().getParent().getCommand(
new EditCommandRequestWrapper(req));
}
}
|