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

COVERAGE SUMMARY FOR SOURCE FILE [CreateShortcutAction.java]

nameclass, %method, %block, %line, %
CreateShortcutAction.java0%   (0/1)0%   (0/3)0%   (0/158)0%   (0/45)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CreateShortcutAction0%   (0/1)0%   (0/3)0%   (0/158)0%   (0/45)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
CreateShortcutAction (): void 0%   (0/1)0%   (0/3)0%   (0/1)
execute (ExecutionEvent): Object 0%   (0/1)0%   (0/147)0%   (0/44)

1/*
2 * Copyright 2007, IPD, SDQ, University of Karlsruhe
3 */
4package de.uka.ipd.sdq.pcm.gmf.repository.part;
5 
6import org.eclipse.core.commands.AbstractHandler;
7import org.eclipse.core.commands.ExecutionEvent;
8import org.eclipse.core.commands.ExecutionException;
9import org.eclipse.core.commands.operations.OperationHistoryFactory;
10import org.eclipse.core.runtime.NullProgressMonitor;
11import org.eclipse.emf.common.util.URI;
12import org.eclipse.emf.common.util.WrappedException;
13import org.eclipse.emf.ecore.EObject;
14import org.eclipse.emf.transaction.TransactionalEditingDomain;
15import org.eclipse.gef.EditPart;
16import org.eclipse.gmf.runtime.common.core.command.ICommand;
17import org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand;
18import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
19import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
20import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
21import org.eclipse.gmf.runtime.notation.Node;
22import org.eclipse.gmf.runtime.notation.View;
23import org.eclipse.jface.viewers.ISelection;
24import org.eclipse.jface.viewers.IStructuredSelection;
25import org.eclipse.jface.window.Window;
26import org.eclipse.swt.widgets.Shell;
27import org.eclipse.ui.IEditorPart;
28import org.eclipse.ui.handlers.HandlerUtil;
29 
30import de.uka.ipd.sdq.pcm.gmf.repository.edit.commands.PalladioComponentModelCreateShortcutDecorationsCommand;
31 
32/**
33 * @generated
34 */
35public class CreateShortcutAction extends AbstractHandler {
36        /**
37         * @generated
38         */
39        public Object execute(ExecutionEvent event) throws ExecutionException {
40                IEditorPart diagramEditor = HandlerUtil.getActiveEditorChecked(event);
41                Shell shell = diagramEditor.getEditorSite().getShell();
42                assert diagramEditor instanceof DiagramEditor;
43                TransactionalEditingDomain editingDomain = ((DiagramEditor) diagramEditor)
44                                .getEditingDomain();
45                ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
46                assert selection instanceof IStructuredSelection;
47                assert ((IStructuredSelection) selection).size() == 1;
48                assert ((IStructuredSelection) selection).getFirstElement() instanceof EditPart;
49                EditPart selectedDiagramPart = (EditPart) ((IStructuredSelection) selection)
50                                .getFirstElement();
51                final View view = (View) selectedDiagramPart.getModel();
52                PalladioComponentModelElementChooserDialog elementChooser = new PalladioComponentModelElementChooserDialog(
53                                shell, view);
54                int result = elementChooser.open();
55                if (result != Window.OK) {
56                        return null;
57                }
58                URI selectedModelElementURI = elementChooser
59                                .getSelectedModelElementURI();
60                final EObject selectedElement;
61                try {
62                        selectedElement = editingDomain.getResourceSet().getEObject(
63                                        selectedModelElementURI, true);
64                } catch (WrappedException e) {
65                        PalladioComponentModelRepositoryDiagramEditorPlugin
66                                        .getInstance()
67                                        .logError(
68                                                        "Exception while loading object: " + selectedModelElementURI.toString(), e); //$NON-NLS-1$
69                        return null;
70                }
71 
72                if (selectedElement == null) {
73                        return null;
74                }
75                CreateViewRequest.ViewDescriptor viewDescriptor = new CreateViewRequest.ViewDescriptor(
76                                new EObjectAdapter(selectedElement),
77                                Node.class,
78                                null,
79                                PalladioComponentModelRepositoryDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
80                ICommand command = new CreateCommand(editingDomain, viewDescriptor,
81                                view);
82                command = command
83                                .compose(new PalladioComponentModelCreateShortcutDecorationsCommand(
84                                                editingDomain, view, viewDescriptor));
85                try {
86                        OperationHistoryFactory.getOperationHistory().execute(command,
87                                        new NullProgressMonitor(), null);
88                } catch (ExecutionException e) {
89                        PalladioComponentModelRepositoryDiagramEditorPlugin.getInstance()
90                                        .logError("Unable to create shortcut", e); //$NON-NLS-1$
91                }
92                return null;
93        }
94 
95}

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