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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelTextNonResizableEditPolicy.java]

nameclass, %method, %block, %line, %
PalladioComponentModelTextNonResizableEditPolicy.java0%   (0/3)0%   (0/19)0%   (0/312)0%   (0/86)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelTextNonResizableEditPolicy0%   (0/1)0%   (0/15)0%   (0/288)0%   (0/81)
PalladioComponentModelTextNonResizableEditPolicy (): void 0%   (0/1)0%   (0/3)0%   (0/1)
createFocusFeedbackFigure (): IFigure 0%   (0/1)0%   (0/5)0%   (0/1)
createSelectionFeedbackFigure (): IFigure 0%   (0/1)0%   (0/28)0%   (0/11)
createSelectionHandles (): List 0%   (0/1)0%   (0/20)0%   (0/4)
getFeedbackBounds (): Rectangle 0%   (0/1)0%   (0/32)0%   (0/7)
getHostPositionListener (): FigureListener 0%   (0/1)0%   (0/12)0%   (0/3)
hideFocus (): void 0%   (0/1)0%   (0/21)0%   (0/6)
hideSelection (): void 0%   (0/1)0%   (0/33)0%   (0/9)
refreshFeedback (): void 0%   (0/1)0%   (0/5)0%   (0/3)
refreshFocusFeedback (): void 0%   (0/1)0%   (0/9)0%   (0/3)
refreshSelectionFeedback (): void 0%   (0/1)0%   (0/27)0%   (0/7)
showFocus (): void 0%   (0/1)0%   (0/22)0%   (0/6)
showPrimarySelection (): void 0%   (0/1)0%   (0/20)0%   (0/6)
showSelection (): void 0%   (0/1)0%   (0/34)0%   (0/9)
updateLabel (Label): void 0%   (0/1)0%   (0/17)0%   (0/5)
     
class PalladioComponentModelTextNonResizableEditPolicy$10%   (0/1)0%   (0/2)0%   (0/14)0%   (0/4)
PalladioComponentModelTextNonResizableEditPolicy$1 (PalladioComponentModelTex... 0%   (0/1)0%   (0/6)0%   (0/2)
paintFigure (Graphics): void 0%   (0/1)0%   (0/8)0%   (0/2)
     
class PalladioComponentModelTextNonResizableEditPolicy$20%   (0/1)0%   (0/2)0%   (0/10)0%   (0/4)
PalladioComponentModelTextNonResizableEditPolicy$2 (PalladioComponentModelTex... 0%   (0/1)0%   (0/6)0%   (0/2)
figureMoved (IFigure): void 0%   (0/1)0%   (0/4)0%   (0/2)

1/*
2 * Copyright 2009, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.resource.edit.policies;
5 
6import java.util.Collections;
7import java.util.List;
8 
9import org.eclipse.draw2d.ColorConstants;
10import org.eclipse.draw2d.Figure;
11import org.eclipse.draw2d.FigureListener;
12import org.eclipse.draw2d.Graphics;
13import org.eclipse.draw2d.IFigure;
14import org.eclipse.draw2d.Label;
15import org.eclipse.draw2d.RectangleFigure;
16import org.eclipse.draw2d.geometry.Rectangle;
17import org.eclipse.gef.GraphicalEditPart;
18import org.eclipse.gef.handles.MoveHandle;
19import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableEditPolicyEx;
20import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
21import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
22 
23/**
24 * @generated
25 */
26public class PalladioComponentModelTextNonResizableEditPolicy extends
27                NonResizableEditPolicyEx {
28 
29        /**
30         * @generated
31         */
32        private IFigure selectionFeedbackFigure;
33 
34        /**
35         * @generated
36         */
37        private IFigure focusFeedbackFigure;
38 
39        /**
40         * @generated
41         */
42        private FigureListener hostPositionListener;
43 
44        /**
45         * @generated
46         */
47        protected void showPrimarySelection() {
48                if (getHostFigure() instanceof WrappingLabel) {
49                        ((WrappingLabel) getHostFigure()).setSelected(true);
50                        ((WrappingLabel) getHostFigure()).setFocus(true);
51                } else {
52                        showSelection();
53                        showFocus();
54                }
55        }
56 
57        /**
58         * @generated
59         */
60        protected void showSelection() {
61                if (getHostFigure() instanceof WrappingLabel) {
62                        ((WrappingLabel) getHostFigure()).setSelected(true);
63                        ((WrappingLabel) getHostFigure()).setFocus(false);
64                } else {
65                        hideSelection();
66                        addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure());
67                        getHostFigure().addFigureListener(getHostPositionListener());
68                        refreshSelectionFeedback();
69                        hideFocus();
70                }
71        }
72 
73        /**
74         * @generated
75         */
76        protected void hideSelection() {
77                if (getHostFigure() instanceof WrappingLabel) {
78                        ((WrappingLabel) getHostFigure()).setSelected(false);
79                        ((WrappingLabel) getHostFigure()).setFocus(false);
80                } else {
81                        if (selectionFeedbackFigure != null) {
82                                removeFeedback(selectionFeedbackFigure);
83                                getHostFigure().removeFigureListener(getHostPositionListener());
84                                selectionFeedbackFigure = null;
85                        }
86                        hideFocus();
87                }
88        }
89 
90        /**
91         * @generated
92         */
93        protected void showFocus() {
94                if (getHostFigure() instanceof WrappingLabel) {
95                        ((WrappingLabel) getHostFigure()).setFocus(true);
96                } else {
97                        hideFocus();
98                        addFeedback(focusFeedbackFigure = createFocusFeedbackFigure());
99                        refreshFocusFeedback();
100                }
101        }
102 
103        /**
104         * @generated
105         */
106        protected void hideFocus() {
107                if (getHostFigure() instanceof WrappingLabel) {
108                        ((WrappingLabel) getHostFigure()).setFocus(false);
109                } else {
110                        if (focusFeedbackFigure != null) {
111                                removeFeedback(focusFeedbackFigure);
112                                focusFeedbackFigure = null;
113                        }
114                }
115        }
116 
117        /**
118         * @generated
119         */
120        protected Rectangle getFeedbackBounds() {
121                Rectangle bounds;
122                if (getHostFigure() instanceof Label) {
123                        bounds = ((Label) getHostFigure()).getTextBounds();
124                        bounds.intersect(getHostFigure().getBounds());
125                } else {
126                        bounds = getHostFigure().getBounds().getCopy();
127                }
128                getHostFigure().getParent().translateToAbsolute(bounds);
129                getFeedbackLayer().translateToRelative(bounds);
130                return bounds;
131        }
132 
133        /**
134         * @generated
135         */
136        protected IFigure createSelectionFeedbackFigure() {
137                if (getHostFigure() instanceof Label) {
138                        Label feedbackFigure = new Label();
139                        feedbackFigure.setOpaque(true);
140                        feedbackFigure
141                                        .setBackgroundColor(ColorConstants.menuBackgroundSelected);
142                        feedbackFigure
143                                        .setForegroundColor(ColorConstants.menuForegroundSelected);
144                        return feedbackFigure;
145                } else {
146                        RectangleFigure feedbackFigure = new RectangleFigure();
147                        feedbackFigure.setFill(false);
148                        return feedbackFigure;
149                }
150        }
151 
152        /**
153         * @generated
154         */
155        protected IFigure createFocusFeedbackFigure() {
156                return new Figure() {
157 
158                        protected void paintFigure(Graphics graphics) {
159                                graphics.drawFocus(getBounds().getResized(-1, -1));
160                        }
161                };
162        }
163 
164        /**
165         * @generated
166         */
167        protected void updateLabel(Label target) {
168                Label source = (Label) getHostFigure();
169                target.setText(source.getText());
170                target.setTextAlignment(source.getTextAlignment());
171                target.setFont(source.getFont());
172        }
173 
174        /**
175         * @generated
176         */
177        protected void refreshSelectionFeedback() {
178                if (selectionFeedbackFigure != null) {
179                        if (selectionFeedbackFigure instanceof Label) {
180                                updateLabel((Label) selectionFeedbackFigure);
181                                selectionFeedbackFigure.setBounds(getFeedbackBounds());
182                        } else {
183                                selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5,
184                                                5));
185                        }
186                }
187        }
188 
189        /**
190         * @generated
191         */
192        protected void refreshFocusFeedback() {
193                if (focusFeedbackFigure != null) {
194                        focusFeedbackFigure.setBounds(getFeedbackBounds());
195                }
196        }
197 
198        /**
199         * @generated
200         */
201        public void refreshFeedback() {
202                refreshSelectionFeedback();
203                refreshFocusFeedback();
204        }
205 
206        /**
207         * @generated
208         */
209        private FigureListener getHostPositionListener() {
210                if (hostPositionListener == null) {
211                        hostPositionListener = new FigureListener() {
212                                public void figureMoved(IFigure source) {
213                                        refreshFeedback();
214                                }
215                        };
216                }
217                return hostPositionListener;
218        }
219 
220        /**
221         * @generated
222         */
223        protected List createSelectionHandles() {
224                MoveHandle moveHandle = new MoveHandle((GraphicalEditPart) getHost());
225                moveHandle.setBorder(null);
226                moveHandle.setDragTracker(new DragEditPartsTrackerEx(getHost()));
227                return Collections.singletonList(moveHandle);
228        }
229}

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