1 | /* |
2 | * Copyright 2007, IPD, SDQ, University of Karlsruhe |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.repository.edit.parts; |
5 | |
6 | import org.eclipse.draw2d.Connection; |
7 | import org.eclipse.draw2d.PolylineDecoration; |
8 | import org.eclipse.draw2d.RotatableDecoration; |
9 | import org.eclipse.draw2d.geometry.PointList; |
10 | import org.eclipse.gef.EditPart; |
11 | import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart; |
12 | import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart; |
13 | import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; |
14 | import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx; |
15 | import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; |
16 | import org.eclipse.gmf.runtime.notation.View; |
17 | |
18 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.policies.CompleteComponentTypeParentProvidesComponentTypesItemSemanticEditPolicy; |
19 | |
20 | /** |
21 | * @generated |
22 | */ |
23 | public class CompleteComponentTypeParentProvidesComponentTypesEditPart extends |
24 | ConnectionNodeEditPart implements ITreeBranchEditPart { |
25 | |
26 | /** |
27 | * @generated |
28 | */ |
29 | public static final int VISUAL_ID = 4104; |
30 | |
31 | /** |
32 | * @generated |
33 | */ |
34 | public CompleteComponentTypeParentProvidesComponentTypesEditPart(View view) { |
35 | super(view); |
36 | } |
37 | |
38 | /** |
39 | * @generated |
40 | */ |
41 | protected void createDefaultEditPolicies() { |
42 | super.createDefaultEditPolicies(); |
43 | installEditPolicy( |
44 | EditPolicyRoles.SEMANTIC_ROLE, |
45 | new CompleteComponentTypeParentProvidesComponentTypesItemSemanticEditPolicy()); |
46 | } |
47 | |
48 | /** |
49 | * @generated |
50 | */ |
51 | protected boolean addFixedChild(EditPart childEditPart) { |
52 | if (childEditPart instanceof CompleteComponentTypeParentProvidesComponentTypesLabelEditPart) { |
53 | ((CompleteComponentTypeParentProvidesComponentTypesLabelEditPart) childEditPart) |
54 | .setLabel(getPrimaryShape() |
55 | .getFigureProvidesParentStereotypeLabelFigure()); |
56 | return true; |
57 | } |
58 | return false; |
59 | } |
60 | |
61 | /** |
62 | * @generated |
63 | */ |
64 | protected void addChildVisual(EditPart childEditPart, int index) { |
65 | if (addFixedChild(childEditPart)) { |
66 | return; |
67 | } |
68 | super.addChildVisual(childEditPart, -1); |
69 | } |
70 | |
71 | /** |
72 | * @generated |
73 | */ |
74 | protected boolean removeFixedChild(EditPart childEditPart) { |
75 | if (childEditPart instanceof CompleteComponentTypeParentProvidesComponentTypesLabelEditPart) { |
76 | return true; |
77 | } |
78 | return false; |
79 | } |
80 | |
81 | /** |
82 | * @generated |
83 | */ |
84 | protected void removeChildVisual(EditPart childEditPart) { |
85 | if (removeFixedChild(childEditPart)) { |
86 | return; |
87 | } |
88 | super.removeChildVisual(childEditPart); |
89 | } |
90 | |
91 | /** |
92 | * Creates figure for this edit part. |
93 | * |
94 | * Body of this method does not depend on settings in generation model |
95 | * so you may safely remove <i>generated</i> tag and modify it. |
96 | * |
97 | * @generated |
98 | */ |
99 | protected Connection createConnectionFigure() { |
100 | return new ParentProvidesTypeFigure(); |
101 | } |
102 | |
103 | /** |
104 | * @generated |
105 | */ |
106 | public ParentProvidesTypeFigure getPrimaryShape() { |
107 | return (ParentProvidesTypeFigure) getFigure(); |
108 | } |
109 | |
110 | /** |
111 | * @generated |
112 | */ |
113 | public class ParentProvidesTypeFigure extends PolylineConnectionEx { |
114 | |
115 | /** |
116 | * @generated |
117 | */ |
118 | private WrappingLabel fFigureProvidesParentStereotypeLabelFigure; |
119 | |
120 | /** |
121 | * @generated |
122 | */ |
123 | public ParentProvidesTypeFigure() { |
124 | this.setLineWidth(1); |
125 | |
126 | createContents(); |
127 | setTargetDecoration(createTargetDecoration()); |
128 | } |
129 | |
130 | /** |
131 | * @generated |
132 | */ |
133 | private void createContents() { |
134 | |
135 | fFigureProvidesParentStereotypeLabelFigure = new WrappingLabel(); |
136 | fFigureProvidesParentStereotypeLabelFigure.setText("<<conforms>>"); |
137 | |
138 | this.add(fFigureProvidesParentStereotypeLabelFigure); |
139 | |
140 | } |
141 | |
142 | /** |
143 | * @generated |
144 | */ |
145 | private RotatableDecoration createTargetDecoration() { |
146 | PolylineDecoration df = new PolylineDecoration(); |
147 | df.setLineWidth(1); |
148 | PointList pl = new PointList(); |
149 | pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(-1)); |
150 | pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0)); |
151 | pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(1)); |
152 | df.setTemplate(pl); |
153 | df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3)); |
154 | return df; |
155 | } |
156 | |
157 | /** |
158 | * @generated |
159 | */ |
160 | public WrappingLabel getFigureProvidesParentStereotypeLabelFigure() { |
161 | return fFigureProvidesParentStereotypeLabelFigure; |
162 | } |
163 | |
164 | } |
165 | |
166 | } |