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