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

COVERAGE SUMMARY FOR SOURCE FILE [InfrastructureRequiredRoleCreateCommand.java]

nameclass, %method, %block, %line, %
InfrastructureRequiredRoleCreateCommand.java0%   (0/1)0%   (0/7)0%   (0/145)0%   (0/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InfrastructureRequiredRoleCreateCommand0%   (0/1)0%   (0/7)0%   (0/145)0%   (0/47)
InfrastructureRequiredRoleCreateCommand (CreateRelationshipRequest, EObject, ... 0%   (0/1)0%   (0/13)0%   (0/4)
canExecute (): boolean 0%   (0/1)0%   (0/37)0%   (0/13)
doConfigure (InfrastructureRequiredRole, IProgressMonitor, IAdaptable): void 0%   (0/1)0%   (0/49)0%   (0/16)
doExecuteWithResult (IProgressMonitor, IAdaptable): CommandResult 0%   (0/1)0%   (0/34)0%   (0/11)
getSource (): InterfaceRequiringEntity 0%   (0/1)0%   (0/4)0%   (0/1)
getTarget (): InfrastructureInterface 0%   (0/1)0%   (0/4)0%   (0/1)
setElementToEdit (EObject): void 0%   (0/1)0%   (0/4)0%   (0/1)

1/*
2 * Copyright 2007, IPD, SDQ, University of Karlsruhe
3 */
4package de.uka.ipd.sdq.pcm.gmf.repository.edit.commands;
5 
6import org.eclipse.core.commands.ExecutionException;
7import org.eclipse.core.runtime.IAdaptable;
8import org.eclipse.core.runtime.IProgressMonitor;
9import org.eclipse.emf.ecore.EObject;
10import org.eclipse.gmf.runtime.common.core.command.CommandResult;
11import org.eclipse.gmf.runtime.common.core.command.ICommand;
12import org.eclipse.gmf.runtime.emf.type.core.IElementType;
13import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
14import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
15import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
16import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
17 
18import de.uka.ipd.sdq.pcm.core.entity.InterfaceRequiringEntity;
19import de.uka.ipd.sdq.pcm.gmf.repository.edit.policies.PalladioComponentModelBaseItemSemanticEditPolicy;
20import de.uka.ipd.sdq.pcm.repository.InfrastructureInterface;
21import de.uka.ipd.sdq.pcm.repository.InfrastructureRequiredRole;
22import de.uka.ipd.sdq.pcm.repository.RepositoryFactory;
23 
24/**
25 * @generated
26 */
27public class InfrastructureRequiredRoleCreateCommand extends EditElementCommand {
28 
29        /**
30         * @generated
31         */
32        private final EObject source;
33 
34        /**
35         * @generated
36         */
37        private final EObject target;
38 
39        /**
40         * @generated
41         */
42        public InfrastructureRequiredRoleCreateCommand(
43                        CreateRelationshipRequest request, EObject source, EObject target) {
44                super(request.getLabel(), null, request);
45                this.source = source;
46                this.target = target;
47        }
48 
49        /**
50         * @generated
51         */
52        public boolean canExecute() {
53                if (source == null && target == null) {
54                        return false;
55                }
56                if (source != null
57                                && false == source instanceof InterfaceRequiringEntity) {
58                        return false;
59                }
60                if (target != null
61                                && false == target instanceof InfrastructureInterface) {
62                        return false;
63                }
64                if (getSource() == null) {
65                        return true; // link creation is in progress; source is not defined yet
66                }
67                // target may be null here but it's possible to check constraint
68                return PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
69                                .canCreateInfrastructureRequiredRole_4112(getSource(),
70                                                getTarget());
71        }
72 
73        /**
74         * @generated
75         */
76        protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
77                        IAdaptable info) throws ExecutionException {
78                if (!canExecute()) {
79                        throw new ExecutionException(
80                                        "Invalid arguments in create link command"); //$NON-NLS-1$
81                }
82 
83                InfrastructureRequiredRole newElement = RepositoryFactory.eINSTANCE
84                                .createInfrastructureRequiredRole();
85                getSource().getRequiredRoles_InterfaceRequiringEntity().add(newElement);
86                newElement
87                                .setRequiredInterface__InfrastructureRequiredRole(getTarget());
88                doConfigure(newElement, monitor, info);
89                ((CreateElementRequest) getRequest()).setNewElement(newElement);
90                return CommandResult.newOKCommandResult(newElement);
91 
92        }
93 
94        /**
95         * @generated
96         */
97        protected void doConfigure(InfrastructureRequiredRole newElement,
98                        IProgressMonitor monitor, IAdaptable info)
99                        throws ExecutionException {
100                IElementType elementType = ((CreateElementRequest) getRequest())
101                                .getElementType();
102                ConfigureRequest configureRequest = new ConfigureRequest(
103                                getEditingDomain(), newElement, elementType);
104                configureRequest.setClientContext(((CreateElementRequest) getRequest())
105                                .getClientContext());
106                configureRequest.addParameters(getRequest().getParameters());
107                configureRequest.setParameter(CreateRelationshipRequest.SOURCE,
108                                getSource());
109                configureRequest.setParameter(CreateRelationshipRequest.TARGET,
110                                getTarget());
111                ICommand configureCommand = elementType
112                                .getEditCommand(configureRequest);
113                if (configureCommand != null && configureCommand.canExecute()) {
114                        configureCommand.execute(monitor, info);
115                }
116        }
117 
118        /**
119         * @generated
120         */
121        protected void setElementToEdit(EObject element) {
122                throw new UnsupportedOperationException();
123        }
124 
125        /**
126         * @generated
127         */
128        protected InterfaceRequiringEntity getSource() {
129                return (InterfaceRequiringEntity) source;
130        }
131 
132        /**
133         * @generated
134         */
135        protected InfrastructureInterface getTarget() {
136                return (InfrastructureInterface) target;
137        }
138 
139}

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