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

COVERAGE SUMMARY FOR SOURCE FILE [AllocationContextEditHelperAdvice.java]

nameclass, %method, %block, %line, %
AllocationContextEditHelperAdvice.java0%   (0/1)0%   (0/2)0%   (0/123)0%   (0/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AllocationContextEditHelperAdvice0%   (0/1)0%   (0/2)0%   (0/123)0%   (0/35)
AllocationContextEditHelperAdvice (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getAfterConfigureCommand (ConfigureRequest): ICommand 0%   (0/1)0%   (0/120)0%   (0/34)

1package de.uka.ipd.sdq.pcm.gmf.allocation.helper;
2 
3import java.util.ArrayList;
4 
5import org.eclipse.emf.ecore.EReference;
6import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
7import org.eclipse.gmf.runtime.common.core.command.ICommand;
8import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
9import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
10import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
11import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
12import org.eclipse.ui.PlatformUI;
13 
14import de.uka.ipd.sdq.pcm.allocation.AllocationPackage;
15import de.uka.ipd.sdq.pcm.core.composition.AssemblyContext;
16import de.uka.ipd.sdq.pcm.core.entity.EntityPackage;
17import de.uka.ipd.sdq.pcm.dialogs.selection.PalladioSelectEObjectDialog;
18 
19public class AllocationContextEditHelperAdvice
20        extends AbstractEditHelperAdvice {
21 
22        @Override
23        protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
24                AssemblyContext resource = null;
25 
26                ArrayList<Object> filterList = new ArrayList<Object>();
27                filterList.add(de.uka.ipd.sdq.pcm.system.System.class);
28                filterList.add(AssemblyContext.class);
29 
30                ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
31                PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(
32                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
33                                filterList, 
34                                additionalReferences,
35                                request.getElementToConfigure().eResource().getResourceSet());
36                dialog.setProvidedService(AssemblyContext.class);
37                dialog.open();
38                if (dialog.getResult() == null)
39                        return new CanceledCommand();
40                if (!(dialog.getResult() instanceof AssemblyContext))
41                        return new CanceledCommand();
42                resource = (AssemblyContext) dialog.getResult();
43                
44                ICommand cmd = new SetValueCommand(
45                                new SetRequest(
46                                                request.getElementToConfigure(), 
47                                                AllocationPackage.eINSTANCE.getAllocationContext_AssemblyContext_AllocationContext(),
48                                                resource));
49                
50                String allocationName = "Allocation_"+resource.getEntityName();
51                if (resource.getEncapsulatedComponent__AssemblyContext() != null)
52                        allocationName += " <"+resource.getEncapsulatedComponent__AssemblyContext().getEntityName()+">";
53 
54                ICommand cmd2 = new SetValueCommand(
55                                new SetRequest(
56                                                request.getElementToConfigure(), 
57                                                EntityPackage.eINSTANCE.getNamedElement_EntityName(),
58                                                allocationName));
59                
60                CompositeCommand cc = new CompositeCommand("Configure Allocation Context");
61                cc.add(cmd);
62                cc.add(cmd2);
63                
64                return cc;
65        }
66}

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