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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelBaseItemSemanticEditPolicy.java]

nameclass, %method, %block, %line, %
PalladioComponentModelBaseItemSemanticEditPolicy.java0%   (0/2)0%   (0/26)0%   (0/369)0%   (0/107)

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/3)0%   (0/23)0%   (0/8)
PalladioComponentModelBaseItemSemanticEditPolicy$LinkConstraints (): void 0%   (0/1)0%   (0/3)0%   (0/1)
canCreateAbstractUserActionSuccessor_4002 (AbstractUserAction, AbstractUserAc... 0%   (0/1)0%   (0/18)0%   (0/6)
canExistAbstractUserActionSuccessor_4002 (AbstractUserAction, AbstractUserAct... 0%   (0/1)0%   (0/2)0%   (0/1)

1/*
2 * Copyright 2007, SDQ, IPD, University of Karlsruhe
3 */
4package de.uka.ipd.sdq.pcm.gmf.usage.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.gmf.usage.edit.helpers.PalladioComponentModelBaseEditHelper;
38import de.uka.ipd.sdq.pcm.gmf.usage.part.PalladioComponentModelVisualIDRegistry;
39import de.uka.ipd.sdq.pcm.gmf.usage.providers.PalladioComponentModelElementTypes;
40import de.uka.ipd.sdq.pcm.usagemodel.AbstractUserAction;
41 
42/**
43 * @generated
44 */
45public class PalladioComponentModelBaseItemSemanticEditPolicy extends
46                SemanticEditPolicy {
47 
48        /**
49         * Extended request data key to hold editpart visual id.
50         * 
51         * @generated
52         */
53        public static final String VISUAL_ID_KEY = "visual_id"; //$NON-NLS-1$
54 
55        /**
56         * @generated
57         */
58        private final IElementType myElementType;
59 
60        /**
61         * @generated
62         */
63        protected PalladioComponentModelBaseItemSemanticEditPolicy(
64                        IElementType elementType) {
65                myElementType = elementType;
66        }
67 
68        /**
69         * Add visual id of edited editpart to extended data of the request
70         * so command switch can decide what kind of diagram element is being edited.
71         * It is done in those cases when it's not possible to deduce diagram
72         * element kind from domain element.
73         * 
74         * @generated
75         */
76        public Command getCommand(Request request) {
77                if (request instanceof ReconnectRequest) {
78                        Object view = ((ReconnectRequest) request).getConnectionEditPart()
79                                        .getModel();
80                        if (view instanceof View) {
81                                Integer id = new Integer(PalladioComponentModelVisualIDRegistry
82                                                .getVisualID((View) view));
83                                request.getExtendedData().put(VISUAL_ID_KEY, id);
84                        }
85                }
86                return super.getCommand(request);
87        }
88 
89        /**
90         * Returns visual id from request parameters.
91         * 
92         * @generated
93         */
94        protected int getVisualID(IEditCommandRequest request) {
95                Object id = request.getParameter(VISUAL_ID_KEY);
96                return id instanceof Integer ? ((Integer) id).intValue() : -1;
97        }
98 
99        /**
100         * @generated
101         */
102        protected Command getSemanticCommand(IEditCommandRequest request) {
103                IEditCommandRequest completedRequest = completeRequest(request);
104                Command semanticCommand = getSemanticCommandSwitch(completedRequest);
105                semanticCommand = getEditHelperCommand(completedRequest,
106                                semanticCommand);
107                if (completedRequest instanceof DestroyRequest) {
108                        DestroyRequest destroyRequest = (DestroyRequest) completedRequest;
109                        return shouldProceed(destroyRequest) ? addDeleteViewCommand(
110                                        semanticCommand, destroyRequest) : null;
111                }
112                return semanticCommand;
113        }
114 
115        /**
116         * @generated
117         */
118        protected Command addDeleteViewCommand(Command mainCommand,
119                        DestroyRequest completedRequest) {
120                Command deleteViewCommand = getGEFWrapper(new DeleteCommand(
121                                getEditingDomain(), (View) getHost().getModel()));
122                return mainCommand == null ? deleteViewCommand : mainCommand
123                                .chain(deleteViewCommand);
124        }
125 
126        /**
127         * @generated
128         */
129        private Command getEditHelperCommand(IEditCommandRequest request,
130                        Command editPolicyCommand) {
131                if (editPolicyCommand != null) {
132                        ICommand command = editPolicyCommand instanceof ICommandProxy ? ((ICommandProxy) editPolicyCommand)
133                                        .getICommand()
134                                        : new CommandProxy(editPolicyCommand);
135                        request.setParameter(
136                                        PalladioComponentModelBaseEditHelper.EDIT_POLICY_COMMAND,
137                                        command);
138                }
139                IElementType requestContextElementType = getContextElementType(request);
140                request.setParameter(
141                                PalladioComponentModelBaseEditHelper.CONTEXT_ELEMENT_TYPE,
142                                requestContextElementType);
143                ICommand command = requestContextElementType.getEditCommand(request);
144                request.setParameter(
145                                PalladioComponentModelBaseEditHelper.EDIT_POLICY_COMMAND, null);
146                request
147                                .setParameter(
148                                                PalladioComponentModelBaseEditHelper.CONTEXT_ELEMENT_TYPE,
149                                                null);
150                if (command != null) {
151                        if (!(command instanceof CompositeTransactionalCommand)) {
152                                command = new CompositeTransactionalCommand(getEditingDomain(),
153                                                command.getLabel()).compose(command);
154                        }
155                        return new ICommandProxy(command);
156                }
157                return editPolicyCommand;
158        }
159 
160        /**
161         * @generated
162         */
163        private IElementType getContextElementType(IEditCommandRequest request) {
164                IElementType requestContextElementType = PalladioComponentModelElementTypes
165                                .getElementType(getVisualID(request));
166                return requestContextElementType != null ? requestContextElementType
167                                : myElementType;
168        }
169 
170        /**
171         * @generated
172         */
173        protected Command getSemanticCommandSwitch(IEditCommandRequest req) {
174                if (req instanceof CreateRelationshipRequest) {
175                        return getCreateRelationshipCommand((CreateRelationshipRequest) req);
176                } else if (req instanceof CreateElementRequest) {
177                        return getCreateCommand((CreateElementRequest) req);
178                } else if (req instanceof ConfigureRequest) {
179                        return getConfigureCommand((ConfigureRequest) req);
180                } else if (req instanceof DestroyElementRequest) {
181                        return getDestroyElementCommand((DestroyElementRequest) req);
182                } else if (req instanceof DestroyReferenceRequest) {
183                        return getDestroyReferenceCommand((DestroyReferenceRequest) req);
184                } else if (req instanceof DuplicateElementsRequest) {
185                        return getDuplicateCommand((DuplicateElementsRequest) req);
186                } else if (req instanceof GetEditContextRequest) {
187                        return getEditContextCommand((GetEditContextRequest) req);
188                } else if (req instanceof MoveRequest) {
189                        return getMoveCommand((MoveRequest) req);
190                } else if (req instanceof ReorientReferenceRelationshipRequest) {
191                        return getReorientReferenceRelationshipCommand((ReorientReferenceRelationshipRequest) req);
192                } else if (req instanceof ReorientRelationshipRequest) {
193                        return getReorientRelationshipCommand((ReorientRelationshipRequest) req);
194                } else if (req instanceof SetRequest) {
195                        return getSetCommand((SetRequest) req);
196                }
197                return null;
198        }
199 
200        /**
201         * @generated
202         */
203        protected Command getConfigureCommand(ConfigureRequest req) {
204                return null;
205        }
206 
207        /**
208         * @generated
209         */
210        protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
211                return null;
212        }
213 
214        /**
215         * @generated
216         */
217        protected Command getCreateCommand(CreateElementRequest req) {
218                return null;
219        }
220 
221        /**
222         * @generated
223         */
224        protected Command getSetCommand(SetRequest req) {
225                return null;
226        }
227 
228        /**
229         * @generated
230         */
231        protected Command getEditContextCommand(GetEditContextRequest req) {
232                return null;
233        }
234 
235        /**
236         * @generated
237         */
238        protected Command getDestroyElementCommand(DestroyElementRequest req) {
239                return null;
240        }
241 
242        /**
243         * @generated
244         */
245        protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) {
246                return null;
247        }
248 
249        /**
250         * @generated
251         */
252        protected Command getDuplicateCommand(DuplicateElementsRequest req) {
253                return null;
254        }
255 
256        /**
257         * @generated
258         */
259        protected Command getMoveCommand(MoveRequest req) {
260                return null;
261        }
262 
263        /**
264         * @generated
265         */
266        protected Command getReorientReferenceRelationshipCommand(
267                        ReorientReferenceRelationshipRequest req) {
268                return UnexecutableCommand.INSTANCE;
269        }
270 
271        /**
272         * @generated
273         */
274        protected Command getReorientRelationshipCommand(
275                        ReorientRelationshipRequest req) {
276                return UnexecutableCommand.INSTANCE;
277        }
278 
279        /**
280         * @generated
281         */
282        protected final Command getGEFWrapper(ICommand cmd) {
283                return new ICommandProxy(cmd);
284        }
285 
286        /**
287         * Returns editing domain from the host edit part.
288         * 
289         * @generated
290         */
291        protected TransactionalEditingDomain getEditingDomain() {
292                return ((IGraphicalEditPart) getHost()).getEditingDomain();
293        }
294 
295        /**
296         * Clean all shortcuts to the host element from the same diagram
297         * @generated
298         */
299        protected void addDestroyShortcutsCommand(ICompositeCommand cmd, View view) {
300                assert view.getEAnnotation("Shortcut") == null; //$NON-NLS-1$
301                for (Iterator it = view.getDiagram().getChildren().iterator(); it
302                                .hasNext();) {
303                        View nextView = (View) it.next();
304                        if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { //$NON-NLS-1$
305                                continue;
306                        }
307                        cmd.add(new DeleteCommand(getEditingDomain(), nextView));
308                }
309        }
310 
311        /**
312         * @generated
313         */
314        public static class LinkConstraints {
315 
316                /**
317                 * @generated
318                 */
319                public static boolean canCreateAbstractUserActionSuccessor_4002(
320                                AbstractUserAction source, AbstractUserAction target) {
321                        if (source != null) {
322                                if (source.getSuccessor() != null) {
323                                        return false;
324                                }
325                        }
326                        if (target != null && (target.getPredecessor() != null)) {
327                                return false;
328                        }
329 
330                        return canExistAbstractUserActionSuccessor_4002(source, target);
331                }
332 
333                /**
334                 * @generated
335                 */
336                public static boolean canExistAbstractUserActionSuccessor_4002(
337                                AbstractUserAction source, AbstractUserAction target) {
338                        return true;
339                }
340 
341        }
342 
343}

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