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

COVERAGE SUMMARY FOR SOURCE FILE [ResourceContainerAllocationCompartmentEditPart.java]

nameclass, %method, %block, %line, %
ResourceContainerAllocationCompartmentEditPart.java0%   (0/2)0%   (0/12)0%   (0/230)0%   (0/61)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ResourceContainerAllocationCompartmentEditPart0%   (0/1)0%   (0/5)0%   (0/53)0%   (0/21)
ResourceContainerAllocationCompartmentEditPart (View): void 0%   (0/1)0%   (0/4)0%   (0/2)
createDefaultEditPolicies (): void 0%   (0/1)0%   (0/28)0%   (0/11)
createFigure (): IFigure 0%   (0/1)0%   (0/9)0%   (0/4)
getCompartmentName (): String 0%   (0/1)0%   (0/2)0%   (0/1)
setRatio (Double): void 0%   (0/1)0%   (0/10)0%   (0/3)
     
class ResourceContainerAllocationCompartmentEditPart$10%   (0/1)0%   (0/7)0%   (0/177)0%   (0/41)
ResourceContainerAllocationCompartmentEditPart$1 (ResourceContainerAllocation... 0%   (0/1)0%   (0/6)0%   (0/2)
addAddViewCommand (CompositeCommand, Node, EObject): void 0%   (0/1)0%   (0/24)0%   (0/4)
addChangeBoundsCommand (CompositeCommand, Node, EObject, Rectangle): void 0%   (0/1)0%   (0/17)0%   (0/6)
addChangeSemanticModelCommand (CompositeCommand, EObject): void 0%   (0/1)0%   (0/19)0%   (0/6)
getDropCommand (ChangeBoundsRequest): Command 0%   (0/1)0%   (0/62)0%   (0/11)
getNewBounds (Node, EObject, IGraphicalEditPart, ChangeBoundsRequest): Rectangle 0%   (0/1)0%   (0/42)0%   (0/8)
resolveElement (IGraphicalEditPart): EObject 0%   (0/1)0%   (0/7)0%   (0/4)

1/*
2 * Copyright 2007, SDQ, IPD, U KA
3 */
4package de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts;
5 
6import java.util.Iterator;
7 
8import org.eclipse.draw2d.IFigure;
9import org.eclipse.draw2d.geometry.Point;
10import org.eclipse.draw2d.geometry.Rectangle;
11import org.eclipse.emf.ecore.EObject;
12import org.eclipse.gef.RootEditPart;
13import org.eclipse.gef.commands.Command;
14import org.eclipse.gef.requests.ChangeBoundsRequest;
15import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
16import org.eclipse.gmf.runtime.diagram.core.commands.AddCommand;
17import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
18import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
19import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
20import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramRootEditPart;
21import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
22import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
23import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
24import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
25import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
26import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
27import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
28import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
29import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
30import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
31import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
32import org.eclipse.gmf.runtime.notation.Bounds;
33import org.eclipse.gmf.runtime.notation.Diagram;
34import org.eclipse.gmf.runtime.notation.Node;
35import org.eclipse.gmf.runtime.notation.View;
36 
37import de.uka.ipd.sdq.pcm.allocation.AllocationContext;
38import de.uka.ipd.sdq.pcm.allocation.AllocationPackage;
39import de.uka.ipd.sdq.pcm.gmf.allocation.edit.policies.ResourceContainerAllocationCompartmentCanonicalEditPolicy;
40import de.uka.ipd.sdq.pcm.gmf.allocation.edit.policies.ResourceContainerAllocationCompartmentItemSemanticEditPolicy;
41import de.uka.ipd.sdq.pcm.gmf.allocation.part.Messages;
42 
43/**
44 * @generated
45 */
46public class ResourceContainerAllocationCompartmentEditPart extends
47                ShapeCompartmentEditPart {
48 
49        /**
50         * @generated
51         */
52        public static final int VISUAL_ID = 7002;
53 
54        /**
55         * @generated
56         */
57        public ResourceContainerAllocationCompartmentEditPart(View view) {
58                super(view);
59        }
60 
61        /**
62         * @generated
63         */
64        public String getCompartmentName() {
65                return Messages.ResourceContainerAllocationCompartmentEditPart_title;
66        }
67 
68        /**
69         * @generated
70         */
71        public IFigure createFigure() {
72                ResizableCompartmentFigure result = (ResizableCompartmentFigure) super
73                                .createFigure();
74                result.setTitleVisibility(false);
75                return result;
76        }
77 
78        /**
79         * @generated not
80         */
81        protected void createDefaultEditPolicies() {
82                super.createDefaultEditPolicies();
83                installEditPolicy(
84                                EditPolicyRoles.SEMANTIC_ROLE,
85                                new ResourceContainerAllocationCompartmentItemSemanticEditPolicy());
86                installEditPolicy(EditPolicyRoles.CREATION_ROLE,
87                                new CreationEditPolicy());
88                installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE,
89                                new DragDropEditPolicy() {
90 
91                                        /* (non-Javadoc)
92                                         * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy#getDropCommand(org.eclipse.gef.requests.ChangeBoundsRequest)
93                                         * Override this to implement Drag Drop of Allocation Contexts
94                                         */
95                                        @Override
96                                        protected Command getDropCommand(ChangeBoundsRequest request) {
97                                                CompositeCommand cc = new CompositeCommand("Drag Element");
98                                                for (Object editPart : request.getEditParts()) {
99                                                        if (editPart instanceof IGraphicalEditPart) {
100                                                                EObject element = resolveElement((IGraphicalEditPart) editPart);
101                                                                Node allocationContextView = (Node) ((IGraphicalEditPart)editPart).getModel();
102                                                                if (element != null && element instanceof AllocationContext) {
103                                                                        Rectangle newBounds = getNewBounds(allocationContextView,element,(IGraphicalEditPart) editPart,request);
104                                                                        addAddViewCommand(cc,allocationContextView,element);
105                                                                        addChangeSemanticModelCommand(cc,element);
106                                                                        addChangeBoundsCommand(cc,allocationContextView,element,newBounds);
107                                                                }
108                                                        }
109                                                }
110                                                return new ICommandProxy(cc);
111                                        }
112 
113                                        private void addChangeBoundsCommand(CompositeCommand cc,
114                                                        Node source,
115                                                        EObject element, Rectangle newBounds) {
116                                                SetBoundsCommand setBounds = new SetBoundsCommand(ResourceContainerAllocationCompartmentEditPart.this.getEditingDomain(), 
117                                                                "Set Position", 
118                                                                new EObjectAdapter(source),
119                                                            newBounds);
120                                                cc.add(setBounds);
121                                        }
122 
123                                        private Rectangle getNewBounds(Node source, EObject element, IGraphicalEditPart editPart, ChangeBoundsRequest request) {
124                                                Bounds b = (Bounds) source.getLayoutConstraint();
125                                                Rectangle newBounds = new Rectangle(b.getX(),b.getY(),b.getWidth(),b.getHeight());
126                                                editPart.getFigure().translateToAbsolute(newBounds);
127                                                newBounds = request.getTransformedRectangle(newBounds);
128                                                ResourceContainerAllocationCompartmentEditPart.this.getContentPane().translateToRelative(newBounds);
129                                                Point targetPoint = new Point(request.getLocation());
130                                                getFigure().translateToRelative(targetPoint);
131                                                
132                                                return newBounds;
133                                        }
134 
135                                        private void addChangeSemanticModelCommand(
136                                                        CompositeCommand cc, EObject element) {
137                                                SetRequest setRequest = new SetRequest(element, 
138                                                                AllocationPackage.eINSTANCE.getAllocationContext_ResourceContainer_AllocationContext(), 
139                                                                ResourceContainerAllocationCompartmentEditPart.this.resolveSemanticElement());
140                                                SetValueCommand cmd = new SetValueCommand(setRequest);
141                                                cc.add(cmd);
142                                        }
143 
144                                        private void addAddViewCommand(CompositeCommand cc,
145                                                        Node source,
146                                                        EObject element) {
147                                                View targetView = (View) ResourceContainerAllocationCompartmentEditPart.this.getModel();
148                                                AddCommand addCommand = new AddCommand(ResourceContainerAllocationCompartmentEditPart.this.getEditingDomain(),new EObjectAdapter(targetView),new EObjectAdapter(source));
149                                                cc.add(addCommand);
150                                        }
151 
152                                        private EObject resolveElement(IGraphicalEditPart editPart) {
153                                                EObject element = ViewUtil
154                                                        .resolveSemanticElement((View) ((IGraphicalEditPart) editPart)
155                                                                        .getModel());
156                                                return element;
157                                        }                                        
158                        
159                });
160                installEditPolicy(EditPolicyRoles.CANONICAL_ROLE,
161                                new ResourceContainerAllocationCompartmentCanonicalEditPolicy());
162        }
163 
164        /**
165         * @generated
166         */
167        protected void setRatio(Double ratio) {
168                if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
169                        super.setRatio(ratio);
170                }
171        }
172 
173}

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