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

COVERAGE SUMMARY FOR SOURCE FILE [LinkingResource2EditPart.java]

nameclass, %method, %block, %line, %
LinkingResource2EditPart.java0%   (0/3)0%   (0/33)0%   (0/349)0%   (0/113)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LinkingResource2EditPart0%   (0/1)0%   (0/24)0%   (0/245)0%   (0/87)
LinkingResource2EditPart (View): void 0%   (0/1)0%   (0/4)0%   (0/2)
access$0 (LinkingResource2EditPart): IMapMode 0%   (0/1)0%   (0/3)0%   (0/1)
addChildVisual (EditPart, int): void 0%   (0/1)0%   (0/10)0%   (0/4)
addFixedChild (EditPart): boolean 0%   (0/1)0%   (0/13)0%   (0/6)
createDefaultEditPolicies (): void 0%   (0/1)0%   (0/20)0%   (0/7)
createLayoutEditPolicy (): LayoutEditPolicy 0%   (0/1)0%   (0/7)0%   (0/2)
createNodeFigure (): NodeFigure 0%   (0/1)0%   (0/21)0%   (0/6)
createNodePlate (): NodeFigure 0%   (0/1)0%   (0/8)0%   (0/2)
createNodeShape (): IFigure 0%   (0/1)0%   (0/10)0%   (0/2)
getContentPane (): IFigure 0%   (0/1)0%   (0/9)0%   (0/3)
getContentPaneFor (IGraphicalEditPart): IFigure 0%   (0/1)0%   (0/3)0%   (0/1)
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/5)
getPrimaryChildEditPart (): EditPart 0%   (0/1)0%   (0/5)0%   (0/2)
getPrimaryShape (): LinkingResource2EditPart$NetworkSwitchFigure 0%   (0/1)0%   (0/4)0%   (0/1)
getTargetEditPart (Request): EditPart 0%   (0/1)0%   (0/25)0%   (0/10)
removeChildVisual (EditPart): void 0%   (0/1)0%   (0/9)0%   (0/4)
removeFixedChild (EditPart): boolean 0%   (0/1)0%   (0/7)0%   (0/3)
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/15)0%   (0/5)
     
class LinkingResource2EditPart$10%   (0/1)0%   (0/4)0%   (0/22)0%   (0/9)
LinkingResource2EditPart$1 (LinkingResource2EditPart): void 0%   (0/1)0%   (0/6)0%   (0/2)
createChildEditPolicy (EditPart): EditPolicy 0%   (0/1)0%   (0/12)0%   (0/5)
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 LinkingResource2EditPart$NetworkSwitchFigure0%   (0/1)0%   (0/5)0%   (0/82)0%   (0/19)
LinkingResource2EditPart$NetworkSwitchFigure (LinkingResource2EditPart): void 0%   (0/1)0%   (0/58)0%   (0/11)
createContents (): void 0%   (0/1)0%   (0/14)0%   (0/4)
getFigureNetworkSwitchNameFigure (): WrappingLabel 0%   (0/1)0%   (0/3)0%   (0/1)
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 2009, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.resource.edit.parts;
5 
6import java.util.ArrayList;
7import java.util.List;
8 
9import org.eclipse.draw2d.IFigure;
10import org.eclipse.draw2d.MarginBorder;
11import org.eclipse.draw2d.RoundedRectangle;
12import org.eclipse.draw2d.Shape;
13import org.eclipse.draw2d.StackLayout;
14import org.eclipse.draw2d.geometry.Dimension;
15import org.eclipse.gef.EditPart;
16import org.eclipse.gef.EditPolicy;
17import org.eclipse.gef.Request;
18import org.eclipse.gef.commands.Command;
19import org.eclipse.gef.editpolicies.LayoutEditPolicy;
20import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
21import org.eclipse.gef.requests.CreateRequest;
22import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
23import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
24import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
25import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
26import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
27import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
28import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
29import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
30import org.eclipse.gmf.runtime.emf.type.core.IElementType;
31import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
32import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
33import org.eclipse.gmf.runtime.notation.View;
34import org.eclipse.swt.graphics.Color;
35 
36import de.uka.ipd.sdq.pcm.gmf.resource.edit.policies.LinkingResource2ItemSemanticEditPolicy;
37import de.uka.ipd.sdq.pcm.gmf.resource.part.PalladioComponentModelVisualIDRegistry;
38import de.uka.ipd.sdq.pcm.gmf.resource.providers.PalladioComponentModelElementTypes;
39 
40/**
41 * @generated
42 */
43public class LinkingResource2EditPart extends ShapeNodeEditPart {
44 
45        /**
46         * @generated
47         */
48        public static final int VISUAL_ID = 2003;
49 
50        /**
51         * @generated
52         */
53        protected IFigure contentPane;
54 
55        /**
56         * @generated
57         */
58        protected IFigure primaryShape;
59 
60        /**
61         * @generated
62         */
63        public LinkingResource2EditPart(View view) {
64                super(view);
65        }
66 
67        /**
68         * @generated
69         */
70        protected void createDefaultEditPolicies() {
71                installEditPolicy(EditPolicyRoles.CREATION_ROLE,
72                                new CreationEditPolicy());
73                super.createDefaultEditPolicies();
74                installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
75                                new LinkingResource2ItemSemanticEditPolicy());
76                installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
77                // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
78                // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
79        }
80 
81        /**
82         * @generated
83         */
84        protected LayoutEditPolicy createLayoutEditPolicy() {
85                LayoutEditPolicy lep = new LayoutEditPolicy() {
86 
87                        protected EditPolicy createChildEditPolicy(EditPart child) {
88                                EditPolicy result = child
89                                                .getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
90                                if (result == null) {
91                                        result = new NonResizableEditPolicy();
92                                }
93                                return result;
94                        }
95 
96                        protected Command getMoveChildrenCommand(Request request) {
97                                return null;
98                        }
99 
100                        protected Command getCreateCommand(CreateRequest request) {
101                                return null;
102                        }
103                };
104                return lep;
105        }
106 
107        /**
108         * @generated
109         */
110        protected IFigure createNodeShape() {
111                NetworkSwitchFigure figure = new NetworkSwitchFigure();
112                return primaryShape = figure;
113        }
114 
115        /**
116         * @generated
117         */
118        public NetworkSwitchFigure getPrimaryShape() {
119                return (NetworkSwitchFigure) primaryShape;
120        }
121 
122        /**
123         * @generated
124         */
125        protected boolean addFixedChild(EditPart childEditPart) {
126                if (childEditPart instanceof LinkingResourceEntityNameEditPart) {
127                        ((LinkingResourceEntityNameEditPart) childEditPart)
128                                        .setLabel(getPrimaryShape()
129                                                        .getFigureNetworkSwitchNameFigure());
130                        return true;
131                }
132                return false;
133        }
134 
135        /**
136         * @generated
137         */
138        protected boolean removeFixedChild(EditPart childEditPart) {
139                if (childEditPart instanceof LinkingResourceEntityNameEditPart) {
140                        return true;
141                }
142                return false;
143        }
144 
145        /**
146         * @generated
147         */
148        protected void addChildVisual(EditPart childEditPart, int index) {
149                if (addFixedChild(childEditPart)) {
150                        return;
151                }
152                super.addChildVisual(childEditPart, -1);
153        }
154 
155        /**
156         * @generated
157         */
158        protected void removeChildVisual(EditPart childEditPart) {
159                if (removeFixedChild(childEditPart)) {
160                        return;
161                }
162                super.removeChildVisual(childEditPart);
163        }
164 
165        /**
166         * @generated
167         */
168        protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
169                return getContentPane();
170        }
171 
172        /**
173         * @generated
174         */
175        protected NodeFigure createNodePlate() {
176                DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(250, 50);
177                return result;
178        }
179 
180        /**
181         * Creates figure for this edit part.
182         * 
183         * Body of this method does not depend on settings in generation model
184         * so you may safely remove <i>generated</i> tag and modify it.
185         * 
186         * @generated
187         */
188        protected NodeFigure createNodeFigure() {
189                NodeFigure figure = createNodePlate();
190                figure.setLayoutManager(new StackLayout());
191                IFigure shape = createNodeShape();
192                figure.add(shape);
193                contentPane = setupContentPane(shape);
194                return figure;
195        }
196 
197        /**
198         * Default implementation treats passed figure as content pane.
199         * Respects layout one may have set for generated figure.
200         * @param nodeShape instance of generated figure class
201         * @generated
202         */
203        protected IFigure setupContentPane(IFigure nodeShape) {
204                if (nodeShape.getLayoutManager() == null) {
205                        ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
206                        layout.setSpacing(5);
207                        nodeShape.setLayoutManager(layout);
208                }
209                return nodeShape; // use nodeShape itself as contentPane
210        }
211 
212        /**
213         * @generated
214         */
215        public IFigure getContentPane() {
216                if (contentPane != null) {
217                        return contentPane;
218                }
219                return super.getContentPane();
220        }
221 
222        /**
223         * @generated
224         */
225        protected void setForegroundColor(Color color) {
226                if (primaryShape != null) {
227                        primaryShape.setForegroundColor(color);
228                }
229        }
230 
231        /**
232         * @generated
233         */
234        protected void setBackgroundColor(Color color) {
235                if (primaryShape != null) {
236                        primaryShape.setBackgroundColor(color);
237                }
238        }
239 
240        /**
241         * @generated
242         */
243        protected void setLineWidth(int width) {
244                if (primaryShape instanceof Shape) {
245                        ((Shape) primaryShape).setLineWidth(width);
246                }
247        }
248 
249        /**
250         * @generated
251         */
252        protected void setLineType(int style) {
253                if (primaryShape instanceof Shape) {
254                        ((Shape) primaryShape).setLineStyle(style);
255                }
256        }
257 
258        /**
259         * @generated
260         */
261        public EditPart getPrimaryChildEditPart() {
262                return getChildBySemanticHint(PalladioComponentModelVisualIDRegistry
263                                .getType(LinkingResourceEntityNameEditPart.VISUAL_ID));
264        }
265 
266        /**
267         * @generated
268         */
269        public List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/getMARelTypesOnSource() {
270                List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/types = new ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
271                types
272                                .add(PalladioComponentModelElementTypes.LinkingResourceConnectedResourceContainers_LinkingResource_4002);
273                return types;
274        }
275 
276        /**
277         * @generated
278         */
279        public List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/getMARelTypesOnSourceAndTarget(
280                        IGraphicalEditPart targetEditPart) {
281                List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/types = new ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
282                if (targetEditPart instanceof ResourceContainerEditPart) {
283                        types
284                                        .add(PalladioComponentModelElementTypes.LinkingResourceConnectedResourceContainers_LinkingResource_4002);
285                }
286                return types;
287        }
288 
289        /**
290         * @generated
291         */
292        public List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/getMATypesForTarget(
293                        IElementType relationshipType) {
294                List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/types = new ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
295                if (relationshipType == PalladioComponentModelElementTypes.LinkingResourceConnectedResourceContainers_LinkingResource_4002) {
296                        types
297                                        .add(PalladioComponentModelElementTypes.ResourceContainer_2001);
298                }
299                return types;
300        }
301 
302        /**
303         * @generated
304         */
305        public EditPart getTargetEditPart(Request request) {
306                if (request instanceof CreateViewAndElementRequest) {
307                        CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request)
308                                        .getViewAndElementDescriptor()
309                                        .getCreateElementRequestAdapter();
310                        IElementType type = (IElementType) adapter
311                                        .getAdapter(IElementType.class);
312                        if (type == PalladioComponentModelElementTypes.CommunicationLinkResourceSpecification_3002) {
313                                return getChildBySemanticHint(PalladioComponentModelVisualIDRegistry
314                                                .getType(LinkingResourceNetworkSwitchCompartmentEditPart.VISUAL_ID));
315                        }
316                }
317                return super.getTargetEditPart(request);
318        }
319 
320        /**
321         * @generated
322         */
323        public class NetworkSwitchFigure extends RoundedRectangle {
324 
325                /**
326                 * @generated
327                 */
328                private WrappingLabel fFigureNetworkSwitchNameFigure;
329 
330                /**
331                 * @generated
332                 */
333                public NetworkSwitchFigure() {
334                        this.setCornerDimensions(new Dimension(getMapMode().DPtoLP(27),
335                                        getMapMode().DPtoLP(27)));
336                        this.setLineWidth(1);
337                        this.setSize(getMapMode().DPtoLP(200), getMapMode().DPtoLP(40));
338 
339                        this.setBorder(new MarginBorder(getMapMode().DPtoLP(10),
340                                        getMapMode().DPtoLP(10), getMapMode().DPtoLP(10),
341                                        getMapMode().DPtoLP(10)));
342                        createContents();
343                }
344 
345                /**
346                 * @generated
347                 */
348                private void createContents() {
349 
350                        fFigureNetworkSwitchNameFigure = new WrappingLabel();
351                        fFigureNetworkSwitchNameFigure.setText("");
352 
353                        this.add(fFigureNetworkSwitchNameFigure);
354 
355                }
356 
357                /**
358                 * @generated
359                 */
360                private boolean myUseLocalCoordinates = false;
361 
362                /**
363                 * @generated
364                 */
365                protected boolean useLocalCoordinates() {
366                        return myUseLocalCoordinates;
367                }
368 
369                /**
370                 * @generated
371                 */
372                protected void setUseLocalCoordinates(boolean useLocalCoordinates) {
373                        myUseLocalCoordinates = useLocalCoordinates;
374                }
375 
376                /**
377                 * @generated
378                 */
379                public WrappingLabel getFigureNetworkSwitchNameFigure() {
380                        return fFigureNetworkSwitchNameFigure;
381                }
382 
383        }
384 
385}

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