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 [UsageScenarioCanonicalEditPolicy.java]

nameclass, %method, %block, %line, %
UsageScenarioCanonicalEditPolicy.java0%   (0/1)0%   (0/16)0%   (0/773)0%   (0/222)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class UsageScenarioCanonicalEditPolicy0%   (0/1)0%   (0/16)0%   (0/773)0%   (0/222)
UsageScenarioCanonicalEditPolicy (): void 0%   (0/1)0%   (0/3)0%   (0/1)
collectAllLinks (View, Map): Collection 0%   (0/1)0%   (0/439)0%   (0/117)
createConnections (Collection, Map): Collection 0%   (0/1)0%   (0/92)0%   (0/30)
getDefaultFactoryHint (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getDiagram (): Diagram 0%   (0/1)0%   (0/6)0%   (0/1)
getEditPart (EObject, Map): EditPart 0%   (0/1)0%   (0/17)0%   (0/5)
getFeaturesToSynchronize (): Set 0%   (0/1)0%   (0/17)0%   (0/5)
getSemanticChildrenList (): List 0%   (0/1)0%   (0/26)0%   (0/8)
getSemanticConnectionsList (): List 0%   (0/1)0%   (0/2)0%   (0/1)
getSourceElement (EObject): EObject 0%   (0/1)0%   (0/2)0%   (0/1)
getTargetElement (EObject): EObject 0%   (0/1)0%   (0/2)0%   (0/1)
isOrphaned (Collection, View): boolean 0%   (0/1)0%   (0/14)0%   (0/5)
refreshConnections (): Collection 0%   (0/1)0%   (0/96)0%   (0/32)
refreshSemantic (): void 0%   (0/1)0%   (0/51)0%   (0/12)
shouldDeleteView (View): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
shouldIncludeConnection (Edge, Collection): boolean 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.Collection;
7import java.util.Collections;
8import java.util.HashMap;
9import java.util.HashSet;
10import java.util.Iterator;
11import java.util.LinkedList;
12import java.util.List;
13import java.util.Map;
14import java.util.Set;
15 
16import org.eclipse.core.runtime.IAdaptable;
17import org.eclipse.emf.ecore.EObject;
18import org.eclipse.gef.EditPart;
19import org.eclipse.gef.commands.Command;
20import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
21import org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand;
22import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
23import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
24import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalConnectionEditPolicy;
25import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
26import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
27import org.eclipse.gmf.runtime.notation.Diagram;
28import org.eclipse.gmf.runtime.notation.Edge;
29import org.eclipse.gmf.runtime.notation.View;
30 
31import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.BranchEditPart;
32import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.BranchTransitionEditPart;
33import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.ClosedWorkloadEditPart;
34import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.DelayEditPart;
35import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.EntryLevelSystemCallEditPart;
36import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.LoopEditPart;
37import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.OpenWorkloadEditPart;
38import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.ScenarioBehaviour2EditPart;
39import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.ScenarioBehaviour3EditPart;
40import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.ScenarioBehaviourEditPart;
41import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.StartEditPart;
42import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.StopEditPart;
43import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.UsageScenario2EditPart;
44import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.UsageScenarioEditPart;
45import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.VariableUsageEditPart;
46import de.uka.ipd.sdq.pcm.gmf.usage.part.PalladioComponentModelDiagramUpdater;
47import de.uka.ipd.sdq.pcm.gmf.usage.part.PalladioComponentModelLinkDescriptor;
48import de.uka.ipd.sdq.pcm.gmf.usage.part.PalladioComponentModelNodeDescriptor;
49import de.uka.ipd.sdq.pcm.gmf.usage.part.PalladioComponentModelVisualIDRegistry;
50import de.uka.ipd.sdq.pcm.usagemodel.UsagemodelPackage;
51 
52/**
53 * @generated
54 */
55public class UsageScenarioCanonicalEditPolicy extends
56                CanonicalConnectionEditPolicy {
57 
58        /**
59         * @generated
60         */
61        Set myFeaturesToSynchronize;
62 
63        /**
64         * @generated
65         */
66        protected List getSemanticChildrenList() {
67                View viewObject = (View) getHost().getModel();
68                List result = new LinkedList();
69                for (Iterator it = PalladioComponentModelDiagramUpdater
70                                .getUsageModel_1000SemanticChildren(viewObject).iterator(); it
71                                .hasNext();) {
72                        result.add(((PalladioComponentModelNodeDescriptor) it.next())
73                                        .getModelElement());
74                }
75                return result;
76        }
77 
78        /**
79         * @generated
80         */
81        protected boolean shouldDeleteView(View view) {
82                return true;
83        }
84 
85        /**
86         * @generated
87         */
88        protected boolean isOrphaned(Collection semanticChildren, final View view) {
89                int visualID = PalladioComponentModelVisualIDRegistry.getVisualID(view);
90                switch (visualID) {
91                case UsageScenario2EditPart.VISUAL_ID:
92                        if (!semanticChildren.contains(view.getElement())) {
93                                return true;
94                        }
95                }
96                return false;
97        }
98 
99        /**
100         * @generated
101         */
102        protected String getDefaultFactoryHint() {
103                return null;
104        }
105 
106        /**
107         * @generated
108         */
109        protected Set getFeaturesToSynchronize() {
110                if (myFeaturesToSynchronize == null) {
111                        myFeaturesToSynchronize = new HashSet();
112                        myFeaturesToSynchronize.add(UsagemodelPackage.eINSTANCE
113                                        .getUsageModel_UsageScenario_UsageModel());
114                }
115                return myFeaturesToSynchronize;
116        }
117 
118        /**
119         * @generated
120         */
121        protected List getSemanticConnectionsList() {
122                return Collections.EMPTY_LIST;
123        }
124 
125        /**
126         * @generated
127         */
128        protected EObject getSourceElement(EObject relationship) {
129                return null;
130        }
131 
132        /**
133         * @generated
134         */
135        protected EObject getTargetElement(EObject relationship) {
136                return null;
137        }
138 
139        /**
140         * @generated
141         */
142        protected boolean shouldIncludeConnection(Edge connector,
143                        Collection children) {
144                return false;
145        }
146 
147        /**
148         * @generated
149         */
150        protected void refreshSemantic() {
151                List createdViews = new LinkedList();
152                createdViews.addAll(refreshSemanticChildren());
153                List createdConnectionViews = new LinkedList();
154                createdConnectionViews.addAll(refreshSemanticConnections());
155                createdConnectionViews.addAll(refreshConnections());
156 
157                if (createdViews.size() > 1) {
158                        // perform a layout of the container
159                        DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host()
160                                        .getEditingDomain(), createdViews, host());
161                        executeCommand(new ICommandProxy(layoutCmd));
162                }
163 
164                createdViews.addAll(createdConnectionViews);
165                makeViewsImmutable(createdViews);
166        }
167 
168        /**
169         * @generated
170         */
171        private Collection refreshConnections() {
172                Map domain2NotationMap = new HashMap();
173                Collection linkDescriptors = collectAllLinks(getDiagram(),
174                                domain2NotationMap);
175                Collection existingLinks = new LinkedList(getDiagram().getEdges());
176                for (Iterator linksIterator = existingLinks.iterator(); linksIterator
177                                .hasNext();) {
178                        Edge nextDiagramLink = (Edge) linksIterator.next();
179                        int diagramLinkVisualID = PalladioComponentModelVisualIDRegistry
180                                        .getVisualID(nextDiagramLink);
181                        if (diagramLinkVisualID == -1) {
182                                if (nextDiagramLink.getSource() != null
183                                                && nextDiagramLink.getTarget() != null) {
184                                        linksIterator.remove();
185                                }
186                                continue;
187                        }
188                        EObject diagramLinkObject = nextDiagramLink.getElement();
189                        EObject diagramLinkSrc = nextDiagramLink.getSource().getElement();
190                        EObject diagramLinkDst = nextDiagramLink.getTarget().getElement();
191                        for (Iterator linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator
192                                        .hasNext();) {
193                                PalladioComponentModelLinkDescriptor nextLinkDescriptor = (PalladioComponentModelLinkDescriptor) linkDescriptorsIterator
194                                                .next();
195                                if (diagramLinkObject == nextLinkDescriptor.getModelElement()
196                                                && diagramLinkSrc == nextLinkDescriptor.getSource()
197                                                && diagramLinkDst == nextLinkDescriptor
198                                                                .getDestination()
199                                                && diagramLinkVisualID == nextLinkDescriptor
200                                                                .getVisualID()) {
201                                        linksIterator.remove();
202                                        linkDescriptorsIterator.remove();
203                                        break;
204                                }
205                        }
206                }
207                deleteViews(existingLinks.iterator());
208                return createConnections(linkDescriptors, domain2NotationMap);
209        }
210 
211        /**
212         * @generated
213         */
214        private Collection collectAllLinks(View view, Map domain2NotationMap) {
215                if (!UsageScenarioEditPart.MODEL_ID
216                                .equals(PalladioComponentModelVisualIDRegistry.getModelID(view))) {
217                        return Collections.EMPTY_LIST;
218                }
219                Collection result = new LinkedList();
220                switch (PalladioComponentModelVisualIDRegistry.getVisualID(view)) {
221                case UsageScenarioEditPart.VISUAL_ID: {
222                        if (!domain2NotationMap.containsKey(view.getElement())) {
223                                result.addAll(PalladioComponentModelDiagramUpdater
224                                                .getUsageModel_1000ContainedLinks(view));
225                        }
226                        if (!domain2NotationMap.containsKey(view.getElement())
227                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
228                                domain2NotationMap.put(view.getElement(), view);
229                        }
230                        break;
231                }
232                case UsageScenario2EditPart.VISUAL_ID: {
233                        if (!domain2NotationMap.containsKey(view.getElement())) {
234                                result.addAll(PalladioComponentModelDiagramUpdater
235                                                .getUsageScenario_2004ContainedLinks(view));
236                        }
237                        if (!domain2NotationMap.containsKey(view.getElement())
238                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
239                                domain2NotationMap.put(view.getElement(), view);
240                        }
241                        break;
242                }
243                case ScenarioBehaviourEditPart.VISUAL_ID: {
244                        if (!domain2NotationMap.containsKey(view.getElement())) {
245                                result.addAll(PalladioComponentModelDiagramUpdater
246                                                .getScenarioBehaviour_3014ContainedLinks(view));
247                        }
248                        if (!domain2NotationMap.containsKey(view.getElement())
249                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
250                                domain2NotationMap.put(view.getElement(), view);
251                        }
252                        break;
253                }
254                case StartEditPart.VISUAL_ID: {
255                        if (!domain2NotationMap.containsKey(view.getElement())) {
256                                result.addAll(PalladioComponentModelDiagramUpdater
257                                                .getStart_3001ContainedLinks(view));
258                        }
259                        if (!domain2NotationMap.containsKey(view.getElement())
260                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
261                                domain2NotationMap.put(view.getElement(), view);
262                        }
263                        break;
264                }
265                case StopEditPart.VISUAL_ID: {
266                        if (!domain2NotationMap.containsKey(view.getElement())) {
267                                result.addAll(PalladioComponentModelDiagramUpdater
268                                                .getStop_3002ContainedLinks(view));
269                        }
270                        if (!domain2NotationMap.containsKey(view.getElement())
271                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
272                                domain2NotationMap.put(view.getElement(), view);
273                        }
274                        break;
275                }
276                case EntryLevelSystemCallEditPart.VISUAL_ID: {
277                        if (!domain2NotationMap.containsKey(view.getElement())) {
278                                result.addAll(PalladioComponentModelDiagramUpdater
279                                                .getEntryLevelSystemCall_3003ContainedLinks(view));
280                        }
281                        if (!domain2NotationMap.containsKey(view.getElement())
282                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
283                                domain2NotationMap.put(view.getElement(), view);
284                        }
285                        break;
286                }
287                case VariableUsageEditPart.VISUAL_ID: {
288                        if (!domain2NotationMap.containsKey(view.getElement())) {
289                                result.addAll(PalladioComponentModelDiagramUpdater
290                                                .getVariableUsage_3012ContainedLinks(view));
291                        }
292                        if (!domain2NotationMap.containsKey(view.getElement())
293                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
294                                domain2NotationMap.put(view.getElement(), view);
295                        }
296                        break;
297                }
298                case LoopEditPart.VISUAL_ID: {
299                        if (!domain2NotationMap.containsKey(view.getElement())) {
300                                result.addAll(PalladioComponentModelDiagramUpdater
301                                                .getLoop_3005ContainedLinks(view));
302                        }
303                        if (!domain2NotationMap.containsKey(view.getElement())
304                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
305                                domain2NotationMap.put(view.getElement(), view);
306                        }
307                        break;
308                }
309                case ScenarioBehaviour2EditPart.VISUAL_ID: {
310                        if (!domain2NotationMap.containsKey(view.getElement())) {
311                                result.addAll(PalladioComponentModelDiagramUpdater
312                                                .getScenarioBehaviour_3007ContainedLinks(view));
313                        }
314                        if (!domain2NotationMap.containsKey(view.getElement())
315                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
316                                domain2NotationMap.put(view.getElement(), view);
317                        }
318                        break;
319                }
320                case BranchEditPart.VISUAL_ID: {
321                        if (!domain2NotationMap.containsKey(view.getElement())) {
322                                result.addAll(PalladioComponentModelDiagramUpdater
323                                                .getBranch_3008ContainedLinks(view));
324                        }
325                        if (!domain2NotationMap.containsKey(view.getElement())
326                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
327                                domain2NotationMap.put(view.getElement(), view);
328                        }
329                        break;
330                }
331                case BranchTransitionEditPart.VISUAL_ID: {
332                        if (!domain2NotationMap.containsKey(view.getElement())) {
333                                result.addAll(PalladioComponentModelDiagramUpdater
334                                                .getBranchTransition_3009ContainedLinks(view));
335                        }
336                        if (!domain2NotationMap.containsKey(view.getElement())
337                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
338                                domain2NotationMap.put(view.getElement(), view);
339                        }
340                        break;
341                }
342                case ScenarioBehaviour3EditPart.VISUAL_ID: {
343                        if (!domain2NotationMap.containsKey(view.getElement())) {
344                                result.addAll(PalladioComponentModelDiagramUpdater
345                                                .getScenarioBehaviour_3010ContainedLinks(view));
346                        }
347                        if (!domain2NotationMap.containsKey(view.getElement())
348                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
349                                domain2NotationMap.put(view.getElement(), view);
350                        }
351                        break;
352                }
353                case DelayEditPart.VISUAL_ID: {
354                        if (!domain2NotationMap.containsKey(view.getElement())) {
355                                result.addAll(PalladioComponentModelDiagramUpdater
356                                                .getDelay_3017ContainedLinks(view));
357                        }
358                        if (!domain2NotationMap.containsKey(view.getElement())
359                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
360                                domain2NotationMap.put(view.getElement(), view);
361                        }
362                        break;
363                }
364                case ClosedWorkloadEditPart.VISUAL_ID: {
365                        if (!domain2NotationMap.containsKey(view.getElement())) {
366                                result.addAll(PalladioComponentModelDiagramUpdater
367                                                .getClosedWorkload_3015ContainedLinks(view));
368                        }
369                        if (!domain2NotationMap.containsKey(view.getElement())
370                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
371                                domain2NotationMap.put(view.getElement(), view);
372                        }
373                        break;
374                }
375                case OpenWorkloadEditPart.VISUAL_ID: {
376                        if (!domain2NotationMap.containsKey(view.getElement())) {
377                                result.addAll(PalladioComponentModelDiagramUpdater
378                                                .getOpenWorkload_3016ContainedLinks(view));
379                        }
380                        if (!domain2NotationMap.containsKey(view.getElement())
381                                        || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
382                                domain2NotationMap.put(view.getElement(), view);
383                        }
384                        break;
385                }
386                }
387                for (Iterator children = view.getChildren().iterator(); children
388                                .hasNext();) {
389                        result.addAll(collectAllLinks((View) children.next(),
390                                        domain2NotationMap));
391                }
392                for (Iterator edges = view.getSourceEdges().iterator(); edges.hasNext();) {
393                        result.addAll(collectAllLinks((View) edges.next(),
394                                        domain2NotationMap));
395                }
396                return result;
397        }
398 
399        /**
400         * @generated
401         */
402        private Collection createConnections(Collection linkDescriptors,
403                        Map domain2NotationMap) {
404                List adapters = new LinkedList();
405                for (Iterator linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator
406                                .hasNext();) {
407                        final PalladioComponentModelLinkDescriptor nextLinkDescriptor = (PalladioComponentModelLinkDescriptor) linkDescriptorsIterator
408                                        .next();
409                        EditPart sourceEditPart = getEditPart(nextLinkDescriptor
410                                        .getSource(), domain2NotationMap);
411                        EditPart targetEditPart = getEditPart(nextLinkDescriptor
412                                        .getDestination(), domain2NotationMap);
413                        if (sourceEditPart == null || targetEditPart == null) {
414                                continue;
415                        }
416                        CreateConnectionViewRequest.ConnectionViewDescriptor descriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(
417                                        nextLinkDescriptor.getSemanticAdapter(), String
418                                                        .valueOf(nextLinkDescriptor.getVisualID()),
419                                        ViewUtil.APPEND, false, ((IGraphicalEditPart) getHost())
420                                                        .getDiagramPreferencesHint());
421                        CreateConnectionViewRequest ccr = new CreateConnectionViewRequest(
422                                        descriptor);
423                        ccr.setType(RequestConstants.REQ_CONNECTION_START);
424                        ccr.setSourceEditPart(sourceEditPart);
425                        sourceEditPart.getCommand(ccr);
426                        ccr.setTargetEditPart(targetEditPart);
427                        ccr.setType(RequestConstants.REQ_CONNECTION_END);
428                        Command cmd = targetEditPart.getCommand(ccr);
429                        if (cmd != null && cmd.canExecute()) {
430                                executeCommand(cmd);
431                                IAdaptable viewAdapter = (IAdaptable) ccr.getNewObject();
432                                if (viewAdapter != null) {
433                                        adapters.add(viewAdapter);
434                                }
435                        }
436                }
437                return adapters;
438        }
439 
440        /**
441         * @generated
442         */
443        private EditPart getEditPart(EObject domainModelElement,
444                        Map domain2NotationMap) {
445                View view = (View) domain2NotationMap.get(domainModelElement);
446                if (view != null) {
447                        return (EditPart) getHost().getViewer().getEditPartRegistry().get(
448                                        view);
449                }
450                return null;
451        }
452 
453        /**
454         * @generated
455         */
456        private Diagram getDiagram() {
457                return ((View) getHost().getModel()).getDiagram();
458        }
459 
460}

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