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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelBaseItemSemanticEditPolicy.java]

nameclass, %method, %block, %line, %
PalladioComponentModelBaseItemSemanticEditPolicy.java0%   (0/2)0%   (0/40)0%   (0/415)0%   (0/124)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelBaseItemSemanticEditPolicy0%   (0/1)0%   (0/23)0%   (0/346)0%   (0/99)
<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)
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/17)0%   (0/69)0%   (0/25)
PalladioComponentModelBaseItemSemanticEditPolicy$LinkConstraints (): void 0%   (0/1)0%   (0/3)0%   (0/1)
canCreateCompleteComponentTypeParentProvidesComponentTypes_4104 (CompleteComp... 0%   (0/1)0%   (0/13)0%   (0/5)
canCreateImplementationComponentTypeParentCompleteComponentTypes_4103 (Implem... 0%   (0/1)0%   (0/13)0%   (0/5)
canCreateInfrastructureProvidedRole_4111 (InterfaceProvidingEntity, Infrastru... 0%   (0/1)0%   (0/4)0%   (0/1)
canCreateInfrastructureRequiredRole_4112 (InterfaceRequiringEntity, Infrastru... 0%   (0/1)0%   (0/4)0%   (0/1)
canCreateOperationProvidedRole_4105 (InterfaceProvidingEntity, OperationInter... 0%   (0/1)0%   (0/4)0%   (0/1)
canCreateOperationRequiredRole_4106 (InterfaceRequiringEntity, OperationInter... 0%   (0/1)0%   (0/4)0%   (0/1)
canCreateSinkRole_4109 (InterfaceProvidingEntity, EventGroup): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
canCreateSourceRole_4110 (InterfaceRequiringEntity, EventGroup): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
canExistCompleteComponentTypeParentProvidesComponentTypes_4104 (CompleteCompo... 0%   (0/1)0%   (0/2)0%   (0/1)
canExistImplementationComponentTypeParentCompleteComponentTypes_4103 (Impleme... 0%   (0/1)0%   (0/2)0%   (0/1)
canExistInfrastructureProvidedRole_4111 (InterfaceProvidingEntity, Infrastruc... 0%   (0/1)0%   (0/2)0%   (0/1)
canExistInfrastructureRequiredRole_4112 (InterfaceRequiringEntity, Infrastruc... 0%   (0/1)0%   (0/2)0%   (0/1)
canExistOperationProvidedRole_4105 (InterfaceProvidingEntity, OperationInterf... 0%   (0/1)0%   (0/2)0%   (0/1)
canExistOperationRequiredRole_4106 (InterfaceRequiringEntity, OperationInterf... 0%   (0/1)0%   (0/2)0%   (0/1)
canExistSinkRole_4109 (InterfaceProvidingEntity, EventGroup): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
canExistSourceRole_4110 (InterfaceRequiringEntity, EventGroup): boolean 0%   (0/1)0%   (0/2)0%   (0/1)

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

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