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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelBaseItemSemanticEditPolicy.java]

nameclass, %method, %block, %line, %
PalladioComponentModelBaseItemSemanticEditPolicy.java0%   (0/2)0%   (0/35)0%   (0/430)0%   (0/128)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelBaseItemSemanticEditPolicy0%   (0/1)0%   (0/24)0%   (0/392)0%   (0/113)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
PalladioComponentModelBaseItemSemanticEditPolicy (IElementType): void 0%   (0/1)0%   (0/6)0%   (0/3)
addDeleteViewCommand (Command, DestroyRequest): Command 0%   (0/1)0%   (0/20)0%   (0/4)
addDestroyShortcutsCommand (ICompositeCommand, View): void 0%   (0/1)0%   (0/45)0%   (0/8)
getCommand (Request): Command 0%   (0/1)0%   (0/28)0%   (0/8)
getConfigureCommand (ConfigureRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getContextElementType (IEditCommandRequest): IElementType 0%   (0/1)0%   (0/12)0%   (0/4)
getCreateCommand (CreateElementRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getDestroyElementCommand (DestroyElementRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getDestroyReferenceCommand (DestroyReferenceRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getDuplicateCommand (DuplicateElementsRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getEditContextCommand (GetEditContextRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getEditHelperCommand (IEditCommandRequest, Command): Command 0%   (0/1)0%   (0/60)0%   (0/24)
getEditingDomain (): TransactionalEditingDomain 0%   (0/1)0%   (0/5)0%   (0/1)
getGEFWrapper (ICommand): Command 0%   (0/1)0%   (0/5)0%   (0/1)
getMoveCommand (MoveRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getRelationshipContainer (Object, EClass, IElementType): EObject 0%   (0/1)0%   (0/46)0%   (0/14)
getReorientReferenceRelationshipCommand (ReorientReferenceRelationshipRequest... 0%   (0/1)0%   (0/2)0%   (0/1)
getReorientRelationshipCommand (ReorientRelationshipRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getSemanticCommand (IEditCommandRequest): Command 0%   (0/1)0%   (0/32)0%   (0/9)
getSemanticCommandSwitch (IEditCommandRequest): Command 0%   (0/1)0%   (0/90)0%   (0/23)
getSetCommand (SetRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getVisualID (IEditCommandRequest): int 0%   (0/1)0%   (0/13)0%   (0/2)
     
class PalladioComponentModelBaseItemSemanticEditPolicy$LinkConstraints0%   (0/1)0%   (0/11)0%   (0/38)0%   (0/15)
PalladioComponentModelBaseItemSemanticEditPolicy$LinkConstraints (): void 0%   (0/1)0%   (0/3)0%   (0/1)
canCreateAssemblyConnector_4004 (ComposedStructure, OperationRequiredRole, Op... 0%   (0/1)0%   (0/5)0%   (0/1)
canCreateAssemblyEventConnector_4007 (ComposedStructure, SourceRole, SinkRole... 0%   (0/1)0%   (0/5)0%   (0/2)
canCreateAssemblyInfrastructureConnector_4008 (ComposedStructure, Infrastruct... 0%   (0/1)0%   (0/5)0%   (0/2)
canCreateProvidedDelegationConnector_4006 (ComposedStructure, OperationProvid... 0%   (0/1)0%   (0/5)0%   (0/2)
canCreateRequiredDelegationConnector_4005 (ComposedStructure, OperationRequir... 0%   (0/1)0%   (0/5)0%   (0/2)
canExistAssemblyConnector_4004 (ComposedStructure, OperationRequiredRole, Ope... 0%   (0/1)0%   (0/2)0%   (0/1)
canExistAssemblyEventConnector_4007 (ComposedStructure, SourceRole, SinkRole)... 0%   (0/1)0%   (0/2)0%   (0/1)
canExistAssemblyInfrastructureConnector_4008 (ComposedStructure, Infrastructu... 0%   (0/1)0%   (0/2)0%   (0/1)
canExistProvidedDelegationConnector_4006 (ComposedStructure, OperationProvide... 0%   (0/1)0%   (0/2)0%   (0/1)
canExistRequiredDelegationConnector_4005 (ComposedStructure, OperationRequire... 0%   (0/1)0%   (0/2)0%   (0/1)

1/*
2 * Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.composite.edit.policies;
5 
6import java.util.Iterator;
7 
8import org.eclipse.emf.ecore.EClass;
9import org.eclipse.emf.ecore.EObject;
10import org.eclipse.emf.transaction.TransactionalEditingDomain;
11import org.eclipse.gef.Request;
12import org.eclipse.gef.commands.Command;
13import org.eclipse.gef.commands.UnexecutableCommand;
14import org.eclipse.gef.requests.ReconnectRequest;
15import org.eclipse.gmf.runtime.common.core.command.ICommand;
16import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
17import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
18import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
19import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
20import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
21import org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy;
22import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
23import org.eclipse.gmf.runtime.emf.type.core.IElementType;
24import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
25import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
26import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
27import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
28import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
29import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest;
30import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
31import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
32import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
33import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
34import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
35import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
36import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
37import org.eclipse.gmf.runtime.notation.View;
38 
39import de.uka.ipd.sdq.pcm.core.composition.ComposedStructure;
40import de.uka.ipd.sdq.pcm.gmf.composite.edit.helpers.PalladioComponentModelBaseEditHelper;
41import de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelVisualIDRegistry;
42import de.uka.ipd.sdq.pcm.gmf.composite.providers.PalladioComponentModelElementTypes;
43import de.uka.ipd.sdq.pcm.repository.InfrastructureProvidedRole;
44import de.uka.ipd.sdq.pcm.repository.InfrastructureRequiredRole;
45import de.uka.ipd.sdq.pcm.repository.OperationProvidedRole;
46import de.uka.ipd.sdq.pcm.repository.OperationRequiredRole;
47import de.uka.ipd.sdq.pcm.repository.SinkRole;
48import de.uka.ipd.sdq.pcm.repository.SourceRole;
49 
50/**
51 * @generated
52 */
53public class PalladioComponentModelBaseItemSemanticEditPolicy extends
54                SemanticEditPolicy {
55 
56        /**
57         * Extended request data key to hold editpart visual id.
58         * 
59         * @generated
60         */
61        public static final String VISUAL_ID_KEY = "visual_id"; //$NON-NLS-1$
62 
63        /**
64         * @generated
65         */
66        private final IElementType myElementType;
67 
68        /**
69         * @generated
70         */
71        protected PalladioComponentModelBaseItemSemanticEditPolicy(
72                        IElementType elementType) {
73                myElementType = elementType;
74        }
75 
76        /**
77         * Add visual id of edited editpart to extended data of the request
78         * so command switch can decide what kind of diagram element is being edited.
79         * It is done in those cases when it's not possible to deduce diagram
80         * element kind from domain element.
81         * 
82         * @generated
83         */
84        public Command getCommand(Request request) {
85                if (request instanceof ReconnectRequest) {
86                        Object view = ((ReconnectRequest) request).getConnectionEditPart()
87                                        .getModel();
88                        if (view instanceof View) {
89                                Integer id = new Integer(PalladioComponentModelVisualIDRegistry
90                                                .getVisualID((View) view));
91                                request.getExtendedData().put(VISUAL_ID_KEY, id);
92                        }
93                }
94                return super.getCommand(request);
95        }
96 
97        /**
98         * Returns visual id from request parameters.
99         * 
100         * @generated
101         */
102        protected int getVisualID(IEditCommandRequest request) {
103                Object id = request.getParameter(VISUAL_ID_KEY);
104                return id instanceof Integer ? ((Integer) id).intValue() : -1;
105        }
106 
107        /**
108         * @generated
109         */
110        protected Command getSemanticCommand(IEditCommandRequest request) {
111                IEditCommandRequest completedRequest = completeRequest(request);
112                Command semanticCommand = getSemanticCommandSwitch(completedRequest);
113                semanticCommand = getEditHelperCommand(completedRequest,
114                                semanticCommand);
115                if (completedRequest instanceof DestroyRequest) {
116                        DestroyRequest destroyRequest = (DestroyRequest) completedRequest;
117                        return shouldProceed(destroyRequest) ? addDeleteViewCommand(
118                                        semanticCommand, destroyRequest) : null;
119                }
120                return semanticCommand;
121        }
122 
123        /**
124         * @generated
125         */
126        protected Command addDeleteViewCommand(Command mainCommand,
127                        DestroyRequest completedRequest) {
128                Command deleteViewCommand = getGEFWrapper(new DeleteCommand(
129                                getEditingDomain(), (View) getHost().getModel()));
130                return mainCommand == null ? deleteViewCommand : mainCommand
131                                .chain(deleteViewCommand);
132        }
133 
134        /**
135         * @generated
136         */
137        private Command getEditHelperCommand(IEditCommandRequest request,
138                        Command editPolicyCommand) {
139                if (editPolicyCommand != null) {
140                        ICommand command = editPolicyCommand instanceof ICommandProxy ? ((ICommandProxy) editPolicyCommand)
141                                        .getICommand()
142                                        : new CommandProxy(editPolicyCommand);
143                        request.setParameter(
144                                        PalladioComponentModelBaseEditHelper.EDIT_POLICY_COMMAND,
145                                        command);
146                }
147                IElementType requestContextElementType = getContextElementType(request);
148                request.setParameter(
149                                PalladioComponentModelBaseEditHelper.CONTEXT_ELEMENT_TYPE,
150                                requestContextElementType);
151                ICommand command = requestContextElementType.getEditCommand(request);
152                request.setParameter(
153                                PalladioComponentModelBaseEditHelper.EDIT_POLICY_COMMAND, null);
154                request
155                                .setParameter(
156                                                PalladioComponentModelBaseEditHelper.CONTEXT_ELEMENT_TYPE,
157                                                null);
158                if (command != null) {
159                        if (!(command instanceof CompositeTransactionalCommand)) {
160                                command = new CompositeTransactionalCommand(getEditingDomain(),
161                                                command.getLabel()).compose(command);
162                        }
163                        return new ICommandProxy(command);
164                }
165                return editPolicyCommand;
166        }
167 
168        /**
169         * @generated
170         */
171        private IElementType getContextElementType(IEditCommandRequest request) {
172                IElementType requestContextElementType = PalladioComponentModelElementTypes
173                                .getElementType(getVisualID(request));
174                return requestContextElementType != null ? requestContextElementType
175                                : myElementType;
176        }
177 
178        /**
179         * @generated
180         */
181        protected Command getSemanticCommandSwitch(IEditCommandRequest req) {
182                if (req instanceof CreateRelationshipRequest) {
183                        return getCreateRelationshipCommand((CreateRelationshipRequest) req);
184                } else if (req instanceof CreateElementRequest) {
185                        return getCreateCommand((CreateElementRequest) req);
186                } else if (req instanceof ConfigureRequest) {
187                        return getConfigureCommand((ConfigureRequest) req);
188                } else if (req instanceof DestroyElementRequest) {
189                        return getDestroyElementCommand((DestroyElementRequest) req);
190                } else if (req instanceof DestroyReferenceRequest) {
191                        return getDestroyReferenceCommand((DestroyReferenceRequest) req);
192                } else if (req instanceof DuplicateElementsRequest) {
193                        return getDuplicateCommand((DuplicateElementsRequest) req);
194                } else if (req instanceof GetEditContextRequest) {
195                        return getEditContextCommand((GetEditContextRequest) req);
196                } else if (req instanceof MoveRequest) {
197                        return getMoveCommand((MoveRequest) req);
198                } else if (req instanceof ReorientReferenceRelationshipRequest) {
199                        return getReorientReferenceRelationshipCommand((ReorientReferenceRelationshipRequest) req);
200                } else if (req instanceof ReorientRelationshipRequest) {
201                        return getReorientRelationshipCommand((ReorientRelationshipRequest) req);
202                } else if (req instanceof SetRequest) {
203                        return getSetCommand((SetRequest) req);
204                }
205                return null;
206        }
207 
208        /**
209         * @generated
210         */
211        protected Command getConfigureCommand(ConfigureRequest req) {
212                return null;
213        }
214 
215        /**
216         * @generated
217         */
218        protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
219                return null;
220        }
221 
222        /**
223         * @generated
224         */
225        protected Command getCreateCommand(CreateElementRequest req) {
226                return null;
227        }
228 
229        /**
230         * @generated
231         */
232        protected Command getSetCommand(SetRequest req) {
233                return null;
234        }
235 
236        /**
237         * @generated
238         */
239        protected Command getEditContextCommand(GetEditContextRequest req) {
240                return null;
241        }
242 
243        /**
244         * @generated
245         */
246        protected Command getDestroyElementCommand(DestroyElementRequest req) {
247                return null;
248        }
249 
250        /**
251         * @generated
252         */
253        protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) {
254                return null;
255        }
256 
257        /**
258         * @generated
259         */
260        protected Command getDuplicateCommand(DuplicateElementsRequest req) {
261                return null;
262        }
263 
264        /**
265         * @generated
266         */
267        protected Command getMoveCommand(MoveRequest req) {
268                return null;
269        }
270 
271        /**
272         * @generated
273         */
274        protected Command getReorientReferenceRelationshipCommand(
275                        ReorientReferenceRelationshipRequest req) {
276                return UnexecutableCommand.INSTANCE;
277        }
278 
279        /**
280         * @generated
281         */
282        protected Command getReorientRelationshipCommand(
283                        ReorientRelationshipRequest req) {
284                return UnexecutableCommand.INSTANCE;
285        }
286 
287        /**
288         * @generated
289         */
290        protected final Command getGEFWrapper(ICommand cmd) {
291                return new ICommandProxy(cmd);
292        }
293 
294        /**
295         * Returns editing domain from the host edit part.
296         * @generated
297         */
298        protected TransactionalEditingDomain getEditingDomain() {
299                return ((IGraphicalEditPart) getHost()).getEditingDomain();
300        }
301 
302        /**
303         * Clean all shortcuts to the host element from the same diagram
304         * @generated
305         */
306        protected void addDestroyShortcutsCommand(ICompositeCommand cmd, View view) {
307                assert view.getEAnnotation("Shortcut") == null; //$NON-NLS-1$
308                for (Iterator it = view.getDiagram().getChildren().iterator(); it
309                                .hasNext();) {
310                        View nextView = (View) it.next();
311                        if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { //$NON-NLS-1$
312                                continue;
313                        }
314                        cmd.add(new DeleteCommand(getEditingDomain(), nextView));
315                }
316        }
317 
318        /**
319         * Finds container element for the new relationship of the specified type.
320         * Default implementation goes up by containment hierarchy starting from
321         * the specified element and returns the first element that is instance of
322         * the specified container class.
323         * 
324         * @generated not
325         */
326        protected EObject getRelationshipContainer(Object uelement,
327                        EClass containerClass, IElementType relationshipType) {
328                if (uelement instanceof EObject) {
329                        if (uelement instanceof OperationProvidedRole
330                                        || uelement instanceof OperationRequiredRole
331                                        || uelement instanceof InfrastructureProvidedRole
332                                        || uelement instanceof InfrastructureRequiredRole
333                                        || uelement instanceof SinkRole
334                                        || uelement instanceof SourceRole) {
335                                uelement = ((View) getHost().getParent().getModel())
336                                                .getElement();
337                        }
338                        EObject element = (EObject) uelement;
339                        for (; element != null; element = element.eContainer()) {
340                                if (containerClass.isSuperTypeOf(element.eClass())) {
341                                        return element;
342                                }
343                        }
344                }
345                return null;
346        }
347 
348        /**
349         * @generated
350         */
351        public static class LinkConstraints {
352 
353                /**
354                 * @generated
355                 */
356                public static boolean canCreateAssemblyConnector_4004(
357                                ComposedStructure container, OperationRequiredRole source,
358                                OperationProvidedRole target) {
359                        return canExistAssemblyConnector_4004(container, source, target);
360                }
361 
362                /**
363                 * @generated
364                 */
365                public static boolean canCreateAssemblyEventConnector_4007(
366                                ComposedStructure container, SourceRole source, SinkRole target) {
367                        return canExistAssemblyEventConnector_4007(container, source,
368                                        target);
369                }
370 
371                /**
372                 * @generated
373                 */
374                public static boolean canCreateRequiredDelegationConnector_4005(
375                                ComposedStructure container, OperationRequiredRole source,
376                                OperationRequiredRole target) {
377                        return canExistRequiredDelegationConnector_4005(container, source,
378                                        target);
379                }
380 
381                /**
382                 * @generated
383                 */
384                public static boolean canCreateProvidedDelegationConnector_4006(
385                                ComposedStructure container, OperationProvidedRole source,
386                                OperationProvidedRole target) {
387                        return canExistProvidedDelegationConnector_4006(container, source,
388                                        target);
389                }
390 
391                /**
392                 * @generated
393                 */
394                public static boolean canCreateAssemblyInfrastructureConnector_4008(
395                                ComposedStructure container, InfrastructureRequiredRole source,
396                                InfrastructureProvidedRole target) {
397                        return canExistAssemblyInfrastructureConnector_4008(container,
398                                        source, target);
399                }
400 
401                /**
402                 * @generated
403                 */
404                public static boolean canExistAssemblyConnector_4004(
405                                ComposedStructure container, OperationRequiredRole source,
406                                OperationProvidedRole target) {
407                        return true;
408                }
409 
410                /**
411                 * @generated
412                 */
413                public static boolean canExistAssemblyEventConnector_4007(
414                                ComposedStructure container, SourceRole source, SinkRole target) {
415                        return true;
416                }
417 
418                /**
419                 * @generated
420                 */
421                public static boolean canExistRequiredDelegationConnector_4005(
422                                ComposedStructure container, OperationRequiredRole source,
423                                OperationRequiredRole target) {
424                        return true;
425                }
426 
427                /**
428                 * @generated
429                 */
430                public static boolean canExistProvidedDelegationConnector_4006(
431                                ComposedStructure container, OperationProvidedRole source,
432                                OperationProvidedRole target) {
433                        return true;
434                }
435 
436                /**
437                 * @generated
438                 */
439                public static boolean canExistAssemblyInfrastructureConnector_4008(
440                                ComposedStructure container, InfrastructureRequiredRole source,
441                                InfrastructureProvidedRole target) {
442                        return true;
443                }
444 
445        }
446 
447}

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