EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.pcm.gmf.composite.edit.parts]

COVERAGE SUMMARY FOR SOURCE FILE [SourceRoleEditPart.java]

nameclass, %method, %block, %line, %
SourceRoleEditPart.java0%   (0/4)0%   (0/28)0%   (0/292)0%   (0/85)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SourceRoleEditPart0%   (0/1)0%   (0/19)0%   (0/194)0%   (0/60)
SourceRoleEditPart (View): void 0%   (0/1)0%   (0/4)0%   (0/2)
access$0 (SourceRoleEditPart): IMapMode 0%   (0/1)0%   (0/3)0%   (0/1)
addBorderItem (IFigure, IBorderItemEditPart): void 0%   (0/1)0%   (0/28)0%   (0/7)
createDefaultEditPolicies (): void 0%   (0/1)0%   (0/19)0%   (0/7)
createLayoutEditPolicy (): LayoutEditPolicy 0%   (0/1)0%   (0/7)0%   (0/2)
createMainFigure (): NodeFigure 0%   (0/1)0%   (0/17)0%   (0/4)
createNodePlate (): NodeFigure 0%   (0/1)0%   (0/14)0%   (0/3)
createNodeShape (): IFigure 0%   (0/1)0%   (0/10)0%   (0/2)
getContentPane (): IFigure 0%   (0/1)0%   (0/9)0%   (0/3)
getMARelTypesOnSource (): List 0%   (0/1)0%   (0/10)0%   (0/4)
getMARelTypesOnSourceAndTarget (IGraphicalEditPart): List 0%   (0/1)0%   (0/13)0%   (0/5)
getMATypesForTarget (IElementType): List 0%   (0/1)0%   (0/13)0%   (0/4)
getPrimaryChildEditPart (): EditPart 0%   (0/1)0%   (0/5)0%   (0/2)
getPrimaryShape (): SourceRoleEditPart$SourceRoleFigure 0%   (0/1)0%   (0/4)0%   (0/1)
setBackgroundColor (Color): void 0%   (0/1)0%   (0/8)0%   (0/3)
setForegroundColor (Color): void 0%   (0/1)0%   (0/8)0%   (0/3)
setLineType (int): void 0%   (0/1)0%   (0/10)0%   (0/3)
setLineWidth (int): void 0%   (0/1)0%   (0/10)0%   (0/3)
setupContentPane (IFigure): IFigure 0%   (0/1)0%   (0/2)0%   (0/1)
     
class SourceRoleEditPart$10%   (0/1)0%   (0/4)0%   (0/34)0%   (0/12)
SourceRoleEditPart$1 (SourceRoleEditPart): void 0%   (0/1)0%   (0/6)0%   (0/2)
createChildEditPolicy (EditPart): EditPolicy 0%   (0/1)0%   (0/24)0%   (0/8)
getCreateCommand (CreateRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getMoveChildrenCommand (Request): Command 0%   (0/1)0%   (0/2)0%   (0/1)
     
class SourceRoleEditPart$1$10%   (0/1)0%   (0/2)0%   (0/19)0%   (0/6)
SourceRoleEditPart$1$1 (SourceRoleEditPart$1): void 0%   (0/1)0%   (0/6)0%   (0/2)
createSelectionHandles (): List 0%   (0/1)0%   (0/13)0%   (0/4)
     
class SourceRoleEditPart$SourceRoleFigure0%   (0/1)0%   (0/3)0%   (0/45)0%   (0/11)
SourceRoleEditPart$SourceRoleFigure (SourceRoleEditPart): void 0%   (0/1)0%   (0/38)0%   (0/8)
setUseLocalCoordinates (boolean): void 0%   (0/1)0%   (0/4)0%   (0/2)
useLocalCoordinates (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)

1/*
2 * Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.composite.edit.parts;
5 
6import java.util.ArrayList;
7import java.util.Collections;
8import java.util.List;
9 
10import org.eclipse.draw2d.IFigure;
11import org.eclipse.draw2d.PositionConstants;
12import org.eclipse.draw2d.RectangleFigure;
13import org.eclipse.draw2d.Shape;
14import org.eclipse.draw2d.StackLayout;
15import org.eclipse.draw2d.geometry.Dimension;
16import org.eclipse.draw2d.geometry.Point;
17import org.eclipse.gef.EditPart;
18import org.eclipse.gef.EditPolicy;
19import org.eclipse.gef.GraphicalEditPart;
20import org.eclipse.gef.Request;
21import org.eclipse.gef.commands.Command;
22import org.eclipse.gef.editpolicies.LayoutEditPolicy;
23import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
24import org.eclipse.gef.handles.MoveHandle;
25import org.eclipse.gef.requests.CreateRequest;
26import org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart;
27import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
28import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
29import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy;
30import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
31import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator;
32import org.eclipse.gmf.runtime.emf.type.core.IElementType;
33import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
34import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
35import org.eclipse.gmf.runtime.notation.View;
36import org.eclipse.swt.graphics.Color;
37 
38import de.uka.ipd.sdq.pcm.gmf.composite.SocketFigure;
39import de.uka.ipd.sdq.pcm.gmf.composite.SourceFigure;
40import de.uka.ipd.sdq.pcm.gmf.composite.AbstractBorderFigure.POSITION_TYPE;
41import de.uka.ipd.sdq.pcm.gmf.composite.edit.policies.SourceRoleItemSemanticEditPolicy;
42import de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelVisualIDRegistry;
43import de.uka.ipd.sdq.pcm.gmf.composite.providers.PalladioComponentModelElementTypes;
44 
45/**
46 * The edit part to draw an internal source role for an assembly context.
47 * 
48 * @generated
49 */
50public class SourceRoleEditPart extends BorderedBorderItemEditPart {
51 
52        /**
53         * size of the figure in LP
54         * 
55         * @generated not
56         */
57        private static final int FIGURE_LOGICAL_SIZE = 30;
58 
59        /**
60         * @generated
61         */
62        public static final int VISUAL_ID = 3013;
63 
64        /**
65         * @generated
66         */
67        protected IFigure contentPane;
68 
69        /**
70         * @generated
71         */
72        protected IFigure primaryShape;
73 
74        /**
75         * @generated
76         */
77        public SourceRoleEditPart(View view) {
78                super(view);
79        }
80 
81        /**
82         * @generated
83         */
84        protected void createDefaultEditPolicies() {
85                super.createDefaultEditPolicies();
86                installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE,
87                                getPrimaryDragEditPolicy());
88                installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
89                                new SourceRoleItemSemanticEditPolicy());
90                installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
91                // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
92                // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
93        }
94 
95        /**
96         * @generated
97         */
98        protected LayoutEditPolicy createLayoutEditPolicy() {
99                LayoutEditPolicy lep = new LayoutEditPolicy() {
100 
101                        protected EditPolicy createChildEditPolicy(EditPart child) {
102                                View childView = (View) child.getModel();
103                                switch (PalladioComponentModelVisualIDRegistry
104                                                .getVisualID(childView)) {
105                                case SourceRoleEntityNameEditPart.VISUAL_ID:
106                                        return new BorderItemSelectionEditPolicy() {
107 
108                                                protected List createSelectionHandles() {
109                                                        MoveHandle mh = new MoveHandle(
110                                                                        (GraphicalEditPart) getHost());
111                                                        mh.setBorder(null);
112                                                        return Collections.singletonList(mh);
113                                                }
114                                        };
115                                }
116                                EditPolicy result = child
117                                                .getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
118                                if (result == null) {
119                                        result = new NonResizableEditPolicy();
120                                }
121                                return result;
122                        }
123 
124                        protected Command getMoveChildrenCommand(Request request) {
125                                return null;
126                        }
127 
128                        protected Command getCreateCommand(CreateRequest request) {
129                                return null;
130                        }
131                };
132                return lep;
133        }
134 
135        /**
136         * @generated
137         */
138        protected IFigure createNodeShape() {
139                SourceRoleFigure figure = new SourceRoleFigure();
140                return primaryShape = figure;
141        }
142 
143        /**
144         * @generated
145         */
146        public SourceRoleFigure getPrimaryShape() {
147                return (SourceRoleFigure) primaryShape;
148        }
149 
150        /**
151         * @generated
152         */
153        protected void addBorderItem(IFigure borderItemContainer,
154                        IBorderItemEditPart borderItemEditPart) {
155                if (borderItemEditPart instanceof SourceRoleEntityNameEditPart) {
156                        BorderItemLocator locator = new BorderItemLocator(getMainFigure(),
157                                        PositionConstants.SOUTH);
158                        locator.setBorderItemOffset(new Dimension(-20, -20));
159                        borderItemContainer.add(borderItemEditPart.getFigure(), locator);
160                } else {
161                        super.addBorderItem(borderItemContainer, borderItemEditPart);
162                }
163        }
164 
165        /**
166         * @generated
167         */
168        protected NodeFigure createNodePlate() {
169                DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(20, 20);
170 
171                //FIXME: workaround for #154536
172                result.getBounds().setSize(result.getPreferredSize());
173                return result;
174        }
175 
176        /**
177         * Creates figure for this edit part.
178         * 
179         * Body of this method does not depend on settings in generation model
180         * so you may safely remove <i>generated</i> tag and modify it.
181         * 
182         * Manually modified to generate a specific source figure 
183         * instead of the standard shape configured in the map model.
184         * 
185         * @generated not
186         */
187        protected NodeFigure createMainFigure() {
188                SourceFigure figure = new SourceFigure(getMapMode().DPtoLP(
189                                FIGURE_LOGICAL_SIZE), POSITION_TYPE.POS_INTERNAL);
190                figure.getBounds().setSize(figure.getPreferredSize());
191                return figure;
192        }
193 
194        /**
195         * Default implementation treats passed figure as content pane.
196         * Respects layout one may have set for generated figure.
197         * @param nodeShape instance of generated figure class
198         * @generated
199         */
200        protected IFigure setupContentPane(IFigure nodeShape) {
201                return nodeShape; // use nodeShape itself as contentPane
202        }
203 
204        /**
205         * @generated
206         */
207        public IFigure getContentPane() {
208                if (contentPane != null) {
209                        return contentPane;
210                }
211                return super.getContentPane();
212        }
213 
214        /**
215         * @generated
216         */
217        protected void setForegroundColor(Color color) {
218                if (primaryShape != null) {
219                        primaryShape.setForegroundColor(color);
220                }
221        }
222 
223        /**
224         * @generated
225         */
226        protected void setBackgroundColor(Color color) {
227                if (primaryShape != null) {
228                        primaryShape.setBackgroundColor(color);
229                }
230        }
231 
232        /**
233         * @generated
234         */
235        protected void setLineWidth(int width) {
236                if (primaryShape instanceof Shape) {
237                        ((Shape) primaryShape).setLineWidth(width);
238                }
239        }
240 
241        /**
242         * @generated
243         */
244        protected void setLineType(int style) {
245                if (primaryShape instanceof Shape) {
246                        ((Shape) primaryShape).setLineStyle(style);
247                }
248        }
249 
250        /**
251         * @generated
252         */
253        public EditPart getPrimaryChildEditPart() {
254                return getChildBySemanticHint(PalladioComponentModelVisualIDRegistry
255                                .getType(SourceRoleEntityNameEditPart.VISUAL_ID));
256        }
257 
258        /**
259         * @generated
260         */
261        public List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/getMARelTypesOnSource() {
262                List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/types = new ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
263                types
264                                .add(PalladioComponentModelElementTypes.AssemblyEventConnector_4007);
265                return types;
266        }
267 
268        /**
269         * @generated
270         */
271        public List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/getMARelTypesOnSourceAndTarget(
272                        IGraphicalEditPart targetEditPart) {
273                List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/types = new ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
274                if (targetEditPart instanceof SinkRoleEditPart) {
275                        types
276                                        .add(PalladioComponentModelElementTypes.AssemblyEventConnector_4007);
277                }
278                return types;
279        }
280 
281        /**
282         * @generated
283         */
284        public List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/getMATypesForTarget(
285                        IElementType relationshipType) {
286                List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/types = new ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
287                if (relationshipType == PalladioComponentModelElementTypes.AssemblyEventConnector_4007) {
288                        types.add(PalladioComponentModelElementTypes.SinkRole_3014);
289                }
290                return types;
291        }
292 
293        /**
294         * @generated
295         */
296        public class SourceRoleFigure extends RectangleFigure {
297 
298                /**
299                 * @generated
300                 */
301                public SourceRoleFigure() {
302                        this.setLineWidth(1);
303                        this.setPreferredSize(new Dimension(getMapMode().DPtoLP(20),
304                                        getMapMode().DPtoLP(20)));
305                        this.setLocation(new Point(getMapMode().DPtoLP(40), getMapMode()
306                                        .DPtoLP(40)));
307                }
308 
309                /**
310                 * @generated
311                 */
312                private boolean myUseLocalCoordinates = false;
313 
314                /**
315                 * @generated
316                 */
317                protected boolean useLocalCoordinates() {
318                        return myUseLocalCoordinates;
319                }
320 
321                /**
322                 * @generated
323                 */
324                protected void setUseLocalCoordinates(boolean useLocalCoordinates) {
325                        myUseLocalCoordinates = useLocalCoordinates;
326                }
327 
328        }
329 
330}

[all classes][de.uka.ipd.sdq.pcm.gmf.composite.edit.parts]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov