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 [PalladioComponentModelTextSelectionEditPolicy.java]

nameclass, %method, %block, %line, %
PalladioComponentModelTextSelectionEditPolicy.java0%   (0/3)0%   (0/18)0%   (0/292)0%   (0/82)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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