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

COVERAGE SUMMARY FOR SOURCE FILE [PcmNewAllocationDiagramFileWizard.java]

nameclass, %method, %block, %line, %
PcmNewAllocationDiagramFileWizard.java0%   (0/2)0%   (0/8)0%   (0/156)0%   (0/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PcmNewAllocationDiagramFileWizard0%   (0/1)0%   (0/6)0%   (0/97)0%   (0/30)
PcmNewAllocationDiagramFileWizard (URI, EObject, TransactionalEditingDomain):... 0%   (0/1)0%   (0/46)0%   (0/13)
access$0 (PcmNewAllocationDiagramFileWizard): Allocation 0%   (0/1)0%   (0/3)0%   (0/1)
access$1 (PcmNewAllocationDiagramFileWizard): ResourceEnvironmentSelectorPage 0%   (0/1)0%   (0/3)0%   (0/1)
access$2 (PcmNewAllocationDiagramFileWizard): SystemSelectorPage 0%   (0/1)0%   (0/3)0%   (0/1)
addPages (): void 0%   (0/1)0%   (0/11)0%   (0/4)
performFinish (): boolean 0%   (0/1)0%   (0/31)0%   (0/10)
     
class PcmNewAllocationDiagramFileWizard$10%   (0/1)0%   (0/2)0%   (0/59)0%   (0/12)
PcmNewAllocationDiagramFileWizard$1 (PcmNewAllocationDiagramFileWizard, Trans... 0%   (0/1)0%   (0/9)0%   (0/2)
doExecuteWithResult (IProgressMonitor, IAdaptable): CommandResult 0%   (0/1)0%   (0/50)0%   (0/10)

1package de.uka.ipd.sdq.pcm.gmf.allocation.part;
2 
3import java.io.IOException;
4import java.util.HashMap;
5import java.util.Map;
6 
7import org.eclipse.core.commands.ExecutionException;
8import org.eclipse.core.commands.operations.OperationHistoryFactory;
9import org.eclipse.core.resources.IFile;
10import org.eclipse.core.runtime.IAdaptable;
11import org.eclipse.core.runtime.IProgressMonitor;
12import org.eclipse.core.runtime.NullProgressMonitor;
13import org.eclipse.emf.ecore.EObject;
14import org.eclipse.emf.ecore.xmi.XMIResource;
15import org.eclipse.emf.transaction.TransactionalEditingDomain;
16import org.eclipse.gmf.runtime.common.core.command.CommandResult;
17import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
18import org.eclipse.jface.viewers.IStructuredSelection;
19import org.eclipse.ui.IWorkbenchPage;
20 
21import de.uka.ipd.sdq.pcm.allocation.Allocation;
22import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceEnvironment;
23import de.uka.ipd.sdq.pcm.system.System;
24 
25/**
26 * This wizard has added pages that require the user to select a System
27 * and a ResourceEnvironment, when initializing the diagram.
28 * 
29 * @author Philipp Meier
30 *
31 */
32public class PcmNewAllocationDiagramFileWizard 
33extends PalladioComponentModelNewDiagramFileWizard {
34 
35        private Allocation myDiagramRoot;
36        private TransactionalEditingDomain myEditingDomain;
37        private ResourceEnvironmentSelectorPage myResourceEnvironmentSelectorPage;
38        private SystemSelectorPage mySystemSelectorPage;
39 
40        public PcmNewAllocationDiagramFileWizard(org.eclipse.emf.common.util.URI domainModelURI,
41                        EObject diagramRoot, TransactionalEditingDomain editingDomain) {
42                super(domainModelURI, diagramRoot, editingDomain);
43 
44                myEditingDomain = editingDomain;
45 
46                myDiagramRoot = null;
47                if (diagramRoot instanceof Allocation) {
48                        myDiagramRoot = (Allocation)diagramRoot;
49                }
50                
51                ResourceEnvironment resourceEnvironment = null;
52                System system = null;
53                if (myDiagramRoot != null) {
54                        resourceEnvironment = myDiagramRoot.getTargetResourceEnvironment_Allocation();
55                        system = myDiagramRoot.getSystem_Allocation();
56                }                
57                myResourceEnvironmentSelectorPage = new ResourceEnvironmentSelectorPage(resourceEnvironment);
58                mySystemSelectorPage = new SystemSelectorPage(system);
59        }
60 
61        @Override
62        public void addPages() {
63                super.addPages();
64                
65                addPage(myResourceEnvironmentSelectorPage);
66                addPage(mySystemSelectorPage);
67        }
68 
69        @Override
70        public boolean performFinish() {
71                if (myDiagramRoot == null) {
72                        return false;
73                }                        
74 
75                // TODO retrieve the IFile handle to the allocation model and add to list of modified files for command
76 
77                AbstractTransactionalCommand command = new AbstractTransactionalCommand(
78                                myEditingDomain, "Save allocation model.", null) { //$NON-NLS-1$
79                        protected CommandResult doExecuteWithResult(
80                                        IProgressMonitor monitor, IAdaptable info)
81                        throws ExecutionException {
82                                myDiagramRoot.setTargetResourceEnvironment_Allocation(myResourceEnvironmentSelectorPage.getSelectedResourceEnvironment());
83                                myDiagramRoot.setSystem_Allocation(mySystemSelectorPage.getSelectedSystem());
84                                try {
85                                        Map<String,String> options = new HashMap<String,String>();
86                                        options.put(XMIResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
87                                        myDiagramRoot.eResource().save(options);
88                                } catch (IOException e) {
89                                        PalladioComponentModelAllocationDiagramEditorPlugin
90                                        .getInstance()
91                                        .logError(
92                                                        "Save operation failed for: " + myDiagramRoot.eResource().getURI().path(), e); //$NON-NLS-1$
93                                }
94                                return CommandResult.newOKCommandResult();
95                        }
96                };
97 
98                try {
99                        OperationHistoryFactory.getOperationHistory().execute(command,
100                                        new NullProgressMonitor(), null);
101                } catch (ExecutionException e) {
102                        PalladioComponentModelAllocationDiagramEditorPlugin.getInstance().logError(
103                                        "Unable to save allocation model.", e); //$NON-NLS-1$
104                }
105 
106                return super.performFinish();                
107        }
108 
109        
110 
111        
112 
113        
114 
115}

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