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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelBaseItemSemanticEditPolicy.java]

nameclass, %method, %block, %line, %
PalladioComponentModelBaseItemSemanticEditPolicy.java0%   (0/2)0%   (0/24)0%   (0/419)0%   (0/118)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelBaseItemSemanticEditPolicy0%   (0/1)0%   (0/23)0%   (0/416)0%   (0/117)
PalladioComponentModelBaseItemSemanticEditPolicy (): void 0%   (0/1)0%   (0/3)0%   (0/1)
addDestroyShortcutsCommand (CompoundCommand): void 0%   (0/1)0%   (0/42)0%   (0/10)
getCommand (Request): Command 0%   (0/1)0%   (0/28)0%   (0/8)
getConfigureCommand (ConfigureRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getCreateCommand (CreateElementRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getDestroyEdgesCommand (): CompoundCommand 0%   (0/1)0%   (0/41)0%   (0/7)
getDestroyElementCommand (DestroyElementRequest): Command 0%   (0/1)0%   (0/2)0%   (0/1)
getDestroyElementCommand (View): Command 0%   (0/1)0%   (0/23)0%   (0/6)
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)
getEditingDomain (): TransactionalEditingDomain 0%   (0/1)0%   (0/5)0%   (0/1)
getGEFWrapper (ICommand): Command 0%   (0/1)0%   (0/5)0%   (0/1)
getMSLWrapper (ICommand): Command 0%   (0/1)0%   (0/4)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/134)0%   (0/45)
getSemanticCommandSwitch (IEditCommandRequest): Command 0%   (0/1)0%   (0/90)0%   (0/23)
getSemanticElement (): EObject 0%   (0/1)0%   (0/6)0%   (0/1)
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/1)0%   (0/3)0%   (0/1)
PalladioComponentModelBaseItemSemanticEditPolicy$LinkConstraints (): void 0%   (0/1)0%   (0/3)0%   (0/1)

1/*
2 * Copyright 2007, SDQ, IPD, U KA
3 */
4package de.uka.ipd.sdq.pcm.gmf.allocation.edit.policies;
5 
6import java.util.Collections;
7import java.util.Iterator;
8import org.eclipse.emf.ecore.EClass;
9import org.eclipse.emf.ecore.EObject;
10import org.eclipse.emf.transaction.TransactionalEditingDomain;
11import org.eclipse.gef.EditPart;
12import org.eclipse.gef.Request;
13import org.eclipse.gef.commands.Command;
14import org.eclipse.gef.commands.CompoundCommand;
15import org.eclipse.gef.commands.UnexecutableCommand;
16import org.eclipse.gef.requests.ReconnectRequest;
17import org.eclipse.gmf.runtime.common.core.command.ICommand;
18import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
19import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
20import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
21import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
22import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
23import org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy;
24import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
25import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
26import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
27import org.eclipse.gmf.runtime.emf.type.core.IEditHelperContext;
28import org.eclipse.gmf.runtime.emf.type.core.IElementType;
29import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
30import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
31import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
32import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
33import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
34import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest;
35import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
36import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
37import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
38import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
39import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
40import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
41import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
42import org.eclipse.gmf.runtime.notation.Edge;
43import org.eclipse.gmf.runtime.notation.View;
44 
45import de.uka.ipd.sdq.pcm.gmf.allocation.edit.helpers.PalladioComponentModelBaseEditHelper;
46import de.uka.ipd.sdq.pcm.gmf.allocation.part.PalladioComponentModelVisualIDRegistry;
47 
48/**
49 * @generated
50 */
51public class PalladioComponentModelBaseItemSemanticEditPolicy extends
52                SemanticEditPolicy {
53 
54        /**
55         * Extended request data key to hold editpart visual id.
56         * 
57         * @generated
58         */
59        public static final String VISUAL_ID_KEY = "visual_id"; //$NON-NLS-1$
60 
61        /**
62         * Add visual id of edited editpart to extended data of the request
63         * so command switch can decide what kind of diagram element is being edited.
64         * It is done in those cases when it's not possible to deduce diagram
65         * element kind from domain element.
66         * 
67         * @generated
68         */
69        public Command getCommand(Request request) {
70                if (request instanceof ReconnectRequest) {
71                        Object view = ((ReconnectRequest) request).getConnectionEditPart()
72                                        .getModel();
73                        if (view instanceof View) {
74                                Integer id = new Integer(PalladioComponentModelVisualIDRegistry
75                                                .getVisualID((View) view));
76                                request.getExtendedData().put(VISUAL_ID_KEY, id);
77                        }
78                }
79                return super.getCommand(request);
80        }
81 
82        /**
83         * Returns visual id from request parameters.
84         * 
85         * @generated
86         */
87        protected int getVisualID(IEditCommandRequest request) {
88                Object id = request.getParameter(VISUAL_ID_KEY);
89                return id instanceof Integer ? ((Integer) id).intValue() : -1;
90        }
91 
92        /**
93         * @generated
94         */
95        protected Command getSemanticCommand(IEditCommandRequest request) {
96                IEditCommandRequest completedRequest = completeRequest(request);
97                Object editHelperContext = completedRequest.getEditHelperContext();
98                if (editHelperContext instanceof View
99                                || (editHelperContext instanceof IEditHelperContext && ((IEditHelperContext) editHelperContext)
100                                                .getEObject() instanceof View)) {
101                        // no semantic commands are provided for pure design elements
102                        return null;
103                }
104                if (editHelperContext == null) {
105                        editHelperContext = ViewUtil
106                                        .resolveSemanticElement((View) getHost().getModel());
107                }
108                IElementType elementType = ElementTypeRegistry.getInstance()
109                                .getElementType(editHelperContext);
110                if (elementType == ElementTypeRegistry.getInstance().getType(
111                                "org.eclipse.gmf.runtime.emf.type.core.default")) { //$NON-NLS-1$ 
112                        elementType = null;
113                }
114                Command semanticCommand = getSemanticCommandSwitch(completedRequest);
115                if (semanticCommand != null) {
116                        ICommand command = semanticCommand instanceof ICommandProxy ? ((ICommandProxy) semanticCommand)
117                                        .getICommand()
118                                        : new CommandProxy(semanticCommand);
119                        completedRequest.setParameter(
120                                        PalladioComponentModelBaseEditHelper.EDIT_POLICY_COMMAND,
121                                        command);
122                }
123                if (elementType != null) {
124                        ICommand command = elementType.getEditCommand(completedRequest);
125                        if (command != null) {
126                                if (!(command instanceof CompositeTransactionalCommand)) {
127                                        TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
128                                                        .getEditingDomain();
129                                        command = new CompositeTransactionalCommand(editingDomain,
130                                                        null).compose(command);
131                                }
132                                semanticCommand = new ICommandProxy(command);
133                        }
134                }
135                boolean shouldProceed = true;
136                if (completedRequest instanceof DestroyRequest) {
137                        shouldProceed = shouldProceed((DestroyRequest) completedRequest);
138                }
139                if (shouldProceed) {
140                        if (completedRequest instanceof DestroyRequest) {
141                                TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
142                                                .getEditingDomain();
143                                Command deleteViewCommand = new ICommandProxy(
144                                                new DeleteCommand(editingDomain, (View) getHost()
145                                                                .getModel()));
146                                semanticCommand = semanticCommand == null ? deleteViewCommand
147                                                : semanticCommand.chain(deleteViewCommand);
148                        }
149                        return semanticCommand;
150                }
151                return null;
152        }
153 
154        /**
155         * @generated
156         */
157        protected Command getSemanticCommandSwitch(IEditCommandRequest req) {
158                if (req instanceof CreateRelationshipRequest) {
159                        return getCreateRelationshipCommand((CreateRelationshipRequest) req);
160                } else if (req instanceof CreateElementRequest) {
161                        return getCreateCommand((CreateElementRequest) req);
162                } else if (req instanceof ConfigureRequest) {
163                        return getConfigureCommand((ConfigureRequest) req);
164                } else if (req instanceof DestroyElementRequest) {
165                        return getDestroyElementCommand((DestroyElementRequest) req);
166                } else if (req instanceof DestroyReferenceRequest) {
167                        return getDestroyReferenceCommand((DestroyReferenceRequest) req);
168                } else if (req instanceof DuplicateElementsRequest) {
169                        return getDuplicateCommand((DuplicateElementsRequest) req);
170                } else if (req instanceof GetEditContextRequest) {
171                        return getEditContextCommand((GetEditContextRequest) req);
172                } else if (req instanceof MoveRequest) {
173                        return getMoveCommand((MoveRequest) req);
174                } else if (req instanceof ReorientReferenceRelationshipRequest) {
175                        return getReorientReferenceRelationshipCommand((ReorientReferenceRelationshipRequest) req);
176                } else if (req instanceof ReorientRelationshipRequest) {
177                        return getReorientRelationshipCommand((ReorientRelationshipRequest) req);
178                } else if (req instanceof SetRequest) {
179                        return getSetCommand((SetRequest) req);
180                }
181                return null;
182        }
183 
184        /**
185         * @generated
186         */
187        protected Command getConfigureCommand(ConfigureRequest req) {
188                return null;
189        }
190 
191        /**
192         * @generated
193         */
194        protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
195                return null;
196        }
197 
198        /**
199         * @generated
200         */
201        protected Command getCreateCommand(CreateElementRequest req) {
202                return null;
203        }
204 
205        /**
206         * @generated
207         */
208        protected Command getSetCommand(SetRequest req) {
209                return null;
210        }
211 
212        /**
213         * @generated
214         */
215        protected Command getEditContextCommand(GetEditContextRequest req) {
216                return null;
217        }
218 
219        /**
220         * @generated
221         */
222        protected Command getDestroyElementCommand(DestroyElementRequest req) {
223                return null;
224        }
225 
226        /**
227         * @generated
228         */
229        protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) {
230                return null;
231        }
232 
233        /**
234         * @generated
235         */
236        protected Command getDuplicateCommand(DuplicateElementsRequest req) {
237                return null;
238        }
239 
240        /**
241         * @generated
242         */
243        protected Command getMoveCommand(MoveRequest req) {
244                return null;
245        }
246 
247        /**
248         * @generated
249         */
250        protected Command getReorientReferenceRelationshipCommand(
251                        ReorientReferenceRelationshipRequest req) {
252                return UnexecutableCommand.INSTANCE;
253        }
254 
255        /**
256         * @generated
257         */
258        protected Command getReorientRelationshipCommand(
259                        ReorientRelationshipRequest req) {
260                return UnexecutableCommand.INSTANCE;
261        }
262 
263        /**
264         * @generated
265         */
266        protected final Command getGEFWrapper(ICommand cmd) {
267                return new ICommandProxy(cmd);
268        }
269 
270        /**
271         * @generated
272         */
273        protected final Command getMSLWrapper(ICommand cmd) {
274                // XXX deprecated: use getGEFWrapper() instead
275                return getGEFWrapper(cmd);
276        }
277 
278        /**
279         * @generated
280         */
281        protected EObject getSemanticElement() {
282                return ViewUtil.resolveSemanticElement((View) getHost().getModel());
283        }
284 
285        /**
286         * Returns editing domain from the host edit part.
287         * 
288         * @generated
289         */
290        protected TransactionalEditingDomain getEditingDomain() {
291                return ((IGraphicalEditPart) getHost()).getEditingDomain();
292        }
293 
294        /**
295         * Creates command to destroy the link.
296         * 
297         * @generated
298         */
299        protected Command getDestroyElementCommand(View view) {
300                EditPart editPart = (EditPart) getHost().getViewer()
301                                .getEditPartRegistry().get(view);
302                DestroyElementRequest request = new DestroyElementRequest(
303                                getEditingDomain(), false);
304                return editPart.getCommand(new EditCommandRequestWrapper(request,
305                                Collections.EMPTY_MAP));
306        }
307 
308        /**
309         * Creates commands to destroy all host incoming and outgoing links.
310         * 
311         * @generated
312         */
313        protected CompoundCommand getDestroyEdgesCommand() {
314                CompoundCommand cmd = new CompoundCommand();
315                View view = (View) getHost().getModel();
316                for (Iterator it = view.getSourceEdges().iterator(); it.hasNext();) {
317                        cmd.add(getDestroyElementCommand((Edge) it.next()));
318                }
319                for (Iterator it = view.getTargetEdges().iterator(); it.hasNext();) {
320                        cmd.add(getDestroyElementCommand((Edge) it.next()));
321                }
322                return cmd;
323        }
324 
325        /**
326         * @generated
327         */
328        protected void addDestroyShortcutsCommand(CompoundCommand command) {
329                View view = (View) getHost().getModel();
330                if (view.getEAnnotation("Shortcut") != null) { //$NON-NLS-1$
331                        return;
332                }
333                for (Iterator it = view.getDiagram().getChildren().iterator(); it
334                                .hasNext();) {
335                        View nextView = (View) it.next();
336                        if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { //$NON-NLS-1$
337                                continue;
338                        }
339                        command.add(getDestroyElementCommand(nextView));
340                }
341        }
342 
343        /**
344         * @generated
345         */
346        public static class LinkConstraints {
347 
348        }
349 
350}

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