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

nameclass, %method, %block, %line, %
PalladioComponentModelCreateShortcutAction.java0%   (0/1)0%   (0/5)0%   (0/135)0%   (0/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelCreateShortcutAction0%   (0/1)0%   (0/5)0%   (0/135)0%   (0/47)
PalladioComponentModelCreateShortcutAction (): void 0%   (0/1)0%   (0/3)0%   (0/1)
isEnabled (): boolean 0%   (0/1)0%   (0/7)0%   (0/1)
run (IAction): void 0%   (0/1)0%   (0/92)0%   (0/34)
selectionChanged (IAction, ISelection): void 0%   (0/1)0%   (0/27)0%   (0/9)
setActivePart (IAction, IWorkbenchPart): void 0%   (0/1)0%   (0/6)0%   (0/2)

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.ExecutionException;
7import org.eclipse.core.commands.operations.OperationHistoryFactory;
8import org.eclipse.core.runtime.NullProgressMonitor;
9import org.eclipse.emf.common.util.URI;
10import org.eclipse.emf.common.util.WrappedException;
11import org.eclipse.emf.ecore.EObject;
12import org.eclipse.gmf.runtime.common.core.command.ICommand;
13import org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand;
14import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
15import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
16import org.eclipse.gmf.runtime.notation.Node;
17import org.eclipse.gmf.runtime.notation.View;
18import org.eclipse.jface.action.IAction;
19import org.eclipse.jface.viewers.ISelection;
20import org.eclipse.jface.viewers.IStructuredSelection;
21import org.eclipse.jface.window.Window;
22import org.eclipse.swt.widgets.Shell;
23import org.eclipse.ui.IObjectActionDelegate;
24import org.eclipse.ui.IWorkbenchPart;
25 
26import de.uka.ipd.sdq.pcm.gmf.repository.edit.commands.PalladioComponentModelCreateShortcutDecorationsCommand;
27import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.RepositoryEditPart;
28 
29/**
30 * @generated
31 */
32public class PalladioComponentModelCreateShortcutAction implements
33                IObjectActionDelegate {
34 
35        /**
36         * @generated
37         */
38        private RepositoryEditPart mySelectedElement;
39 
40        /**
41         * @generated
42         */
43        private Shell myShell;
44 
45        /**
46         * @generated
47         */
48        public void setActivePart(IAction action, IWorkbenchPart targetPart) {
49                myShell = targetPart.getSite().getShell();
50        }
51 
52        /**
53         * @generated
54         */
55        public void selectionChanged(IAction action, ISelection selection) {
56                mySelectedElement = null;
57                if (selection instanceof IStructuredSelection) {
58                        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
59                        if (structuredSelection.size() == 1
60                                        && structuredSelection.getFirstElement() instanceof RepositoryEditPart) {
61                                mySelectedElement = (RepositoryEditPart) structuredSelection
62                                                .getFirstElement();
63                        }
64                }
65                action.setEnabled(isEnabled());
66        }
67 
68        /**
69         * @generated
70         */
71        private boolean isEnabled() {
72                return mySelectedElement != null;
73        }
74 
75        /**
76         * @generated
77         */
78        public void run(IAction action) {
79                final View view = (View) mySelectedElement.getModel();
80                PalladioComponentModelElementChooserDialog elementChooser = new PalladioComponentModelElementChooserDialog(
81                                myShell, view);
82                int result = elementChooser.open();
83                if (result != Window.OK) {
84                        return;
85                }
86                URI selectedModelElementURI = elementChooser
87                                .getSelectedModelElementURI();
88                final EObject selectedElement;
89                try {
90                        selectedElement = mySelectedElement.getEditingDomain()
91                                        .getResourceSet().getEObject(selectedModelElementURI, true);
92                } catch (WrappedException e) {
93                        PalladioComponentModelRepositoryDiagramEditorPlugin
94                                        .getInstance()
95                                        .logError(
96                                                        "Exception while loading object: " + selectedModelElementURI.toString(), e); //$NON-NLS-1$
97                        return;
98                }
99 
100                if (selectedElement == null) {
101                        return;
102                }
103                CreateViewRequest.ViewDescriptor viewDescriptor = new CreateViewRequest.ViewDescriptor(
104                                new EObjectAdapter(selectedElement),
105                                Node.class,
106                                null,
107                                PalladioComponentModelRepositoryDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
108                ICommand command = new CreateCommand(mySelectedElement
109                                .getEditingDomain(), viewDescriptor, view);
110                command = command
111                                .compose(new PalladioComponentModelCreateShortcutDecorationsCommand(
112                                                mySelectedElement.getEditingDomain(), view,
113                                                viewDescriptor));
114                try {
115                        OperationHistoryFactory.getOperationHistory().execute(command,
116                                        new NullProgressMonitor(), null);
117                } catch (ExecutionException e) {
118                        PalladioComponentModelRepositoryDiagramEditorPlugin.getInstance()
119                                        .logError("Unable to create shortcut", e); //$NON-NLS-1$
120                }
121        }
122}

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