blob: b5cc765d90ac3e1380518e46baea4a31fdf7a861 (
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
79
80
81
82
83
84
85
86
87
88
89
|
package org.eclipse.papyrus.uml.diagram.sequence.command;
import java.util.ArrayList;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.notation.BasicCompartment;
import org.eclipse.gmf.runtime.notation.Compartment;
import org.eclipse.gmf.runtime.notation.Location;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationFactory;
import org.eclipse.gmf.runtime.notation.StringValueStyle;
import org.eclipse.gmf.runtime.notation.TitleStyle;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.GrillingEditpart;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.GrillingManagementEditPolicy;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
/**
* the goal of this command is to create a basic compartment in the notation that represent a compartment of stereotypes
*
*/
public class CreateCoordinateCommand extends RecordingCommand {
private BasicCompartment compartment;
private String name;
private int position;
private EObject semantic;
/**
*
* Constructor.
*
* @param domain
* @param node
* The EditPart view of the Compartment
*/
public CreateCoordinateCommand(TransactionalEditingDomain domain, BasicCompartment compartment, String name, Element semantic, int position) {
super(domain, "create Grilling Structure");
this.compartment = compartment;
this.name= name;
this.position=position;
this.semantic=semantic;
}
@SuppressWarnings("unchecked")
@Override
public void doExecute() {
//create One line
Node coordinate= NotationFactory.eINSTANCE.createDecorationNode();
Location linelocation=NotationFactory.eINSTANCE.createLocation();
coordinate.setType(name);
if (name.startsWith(GrillingManagementEditPolicy.COLUMN)){
linelocation.setX(position);
}
if (name.startsWith(GrillingManagementEditPolicy.ROW)){
linelocation.setY(position);
}
coordinate.setLayoutConstraint(linelocation);
if( semantic!=null){
//create EAnnotation
EAnnotation eAnnotation =EcoreFactory.eINSTANCE.createEAnnotation();
eAnnotation.setSource(GrillingManagementEditPolicy.GRILL_CONNECTION);
eAnnotation.getReferences().add(semantic);
coordinate.getEAnnotations().add(eAnnotation);
ViewUtil.insertChildView(compartment, coordinate, ViewUtil.APPEND, true);
}
}
}
|