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

COVERAGE SUMMARY FOR SOURCE FILE [CompleteParentStereotypeLabel2EditPart.java]

nameclass, %method, %block, %line, %
CompleteParentStereotypeLabel2EditPart.java0%   (0/6)0%   (0/50)0%   (0/745)0%   (0/213)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CompleteParentStereotypeLabel2EditPart0%   (0/1)0%   (0/40)0%   (0/576)0%   (0/177)
<static initializer> 0%   (0/1)0%   (0/9)0%   (0/4)
CompleteParentStereotypeLabel2EditPart (View): void 0%   (0/1)0%   (0/4)0%   (0/2)
access$0 (CompleteParentStereotypeLabel2EditPart, char): void 0%   (0/1)0%   (0/4)0%   (0/1)
addSemanticListeners (): void 0%   (0/1)0%   (0/42)0%   (0/9)
createDefaultEditPolicies (): void 0%   (0/1)0%   (0/9)0%   (0/4)
createFigure (): IFigure 0%   (0/1)0%   (0/2)0%   (0/1)
getAccessibleEditPart (): AccessibleEditPart 0%   (0/1)0%   (0/13)0%   (0/3)
getChildBySemanticHint (String): IGraphicalEditPart 0%   (0/1)0%   (0/2)0%   (0/1)
getCompletionProcessor (): IContentAssistProcessor 0%   (0/1)0%   (0/14)0%   (0/4)
getEditText (): String 0%   (0/1)0%   (0/17)0%   (0/5)
getEditTextValidator (): ICellEditorValidator 0%   (0/1)0%   (0/5)0%   (0/1)
getFontStyleOwnerView (): View 0%   (0/1)0%   (0/3)0%   (0/1)
getKeyPoint (): int 0%   (0/1)0%   (0/2)0%   (0/1)
getLabelIcon (): Image 0%   (0/1)0%   (0/2)0%   (0/1)
getLabelIconHelper (IFigure): Image 0%   (0/1)0%   (0/11)0%   (0/3)
getLabelText (): String 0%   (0/1)0%   (0/27)0%   (0/8)
getLabelTextHelper (IFigure): String 0%   (0/1)0%   (0/11)0%   (0/3)
getManager (): DirectEditManager 0%   (0/1)0%   (0/16)0%   (0/5)
getModelChildren (): List 0%   (0/1)0%   (0/2)0%   (0/1)
getParser (): IParser 0%   (0/1)0%   (0/24)0%   (0/6)
getParserElement (): EObject 0%   (0/1)0%   (0/11)0%   (0/2)
getParserOptions (): ParserOptions 0%   (0/1)0%   (0/2)0%   (0/1)
handleNotificationEvent (Notification): void 0%   (0/1)0%   (0/96)0%   (0/32)
isEditable (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
performDirectEdit (): void 0%   (0/1)0%   (0/4)0%   (0/2)
performDirectEdit (Point): void 0%   (0/1)0%   (0/12)0%   (0/4)
performDirectEdit (char): void 0%   (0/1)0%   (0/13)0%   (0/4)
performDirectEditRequest (Request): void 0%   (0/1)0%   (0/16)0%   (0/5)
refreshFont (): void 0%   (0/1)0%   (0/34)0%   (0/8)
refreshLabel (): void 0%   (0/1)0%   (0/23)0%   (0/7)
refreshStrikeThrough (): void 0%   (0/1)0%   (0/20)0%   (0/6)
refreshUnderline (): void 0%   (0/1)0%   (0/20)0%   (0/5)
refreshVisuals (): void 0%   (0/1)0%   (0/13)0%   (0/7)
removeSemanticListeners (): void 0%   (0/1)0%   (0/25)0%   (0/5)
setFontColor (Color): void 0%   (0/1)0%   (0/5)0%   (0/2)
setLabel (WrapLabel): void 0%   (0/1)0%   (0/15)0%   (0/6)
setLabelIconHelper (IFigure, Image): void 0%   (0/1)0%   (0/13)0%   (0/4)
setLabelText (String): void 0%   (0/1)0%   (0/16)0%   (0/6)
setLabelTextHelper (IFigure, String): void 0%   (0/1)0%   (0/13)0%   (0/4)
setManager (DirectEditManager): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class CompleteParentStereotypeLabel2EditPart$10%   (0/1)0%   (0/2)0%   (0/43)0%   (0/12)
CompleteParentStereotypeLabel2EditPart$1 (CompleteParentStereotypeLabel2EditP... 0%   (0/1)0%   (0/6)0%   (0/2)
isValid (Object): String 0%   (0/1)0%   (0/37)0%   (0/10)
     
class CompleteParentStereotypeLabel2EditPart$1$10%   (0/1)0%   (0/2)0%   (0/29)0%   (0/6)
CompleteParentStereotypeLabel2EditPart$1$1 (CompleteParentStereotypeLabel2Edi... 0%   (0/1)0%   (0/15)0%   (0/2)
run (): void 0%   (0/1)0%   (0/14)0%   (0/4)
     
class CompleteParentStereotypeLabel2EditPart$20%   (0/1)0%   (0/2)0%   (0/18)0%   (0/5)
CompleteParentStereotypeLabel2EditPart$2 (CompleteParentStereotypeLabel2EditP... 0%   (0/1)0%   (0/8)0%   (0/2)
getAdapter (Class): Object 0%   (0/1)0%   (0/10)0%   (0/3)
     
class CompleteParentStereotypeLabel2EditPart$30%   (0/1)0%   (0/2)0%   (0/63)0%   (0/18)
CompleteParentStereotypeLabel2EditPart$3 (CompleteParentStereotypeLabel2EditP... 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/54)0%   (0/16)
     
class CompleteParentStereotypeLabel2EditPart$40%   (0/1)0%   (0/2)0%   (0/16)0%   (0/4)
CompleteParentStereotypeLabel2EditPart$4 (CompleteParentStereotypeLabel2EditP... 0%   (0/1)0%   (0/7)0%   (0/2)
getName (AccessibleEvent): void 0%   (0/1)0%   (0/9)0%   (0/2)

1/*
2 * Copyright 2007, IPD, SDQ, University of Karlsruhe
3 */
4package de.uka.ipd.sdq.pcm.gmf.repository.edit.parts;
5 
6import java.util.Collections;
7import java.util.List;
8 
9import org.eclipse.draw2d.ConnectionLocator;
10import org.eclipse.draw2d.IFigure;
11import org.eclipse.draw2d.Label;
12import org.eclipse.draw2d.geometry.Point;
13import org.eclipse.emf.common.notify.Notification;
14import org.eclipse.emf.ecore.EObject;
15import org.eclipse.emf.transaction.RunnableWithResult;
16import org.eclipse.gef.AccessibleEditPart;
17import org.eclipse.gef.EditPolicy;
18import org.eclipse.gef.Request;
19import org.eclipse.gef.requests.DirectEditRequest;
20import org.eclipse.gef.tools.DirectEditManager;
21import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
22import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
23import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
24import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
25import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService;
26import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
27import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
28import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
29import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
30import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
31import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
32import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
33import org.eclipse.gmf.runtime.draw2d.ui.figures.WrapLabel;
34import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
35import org.eclipse.gmf.runtime.emf.type.core.IElementType;
36import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
37import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
38import org.eclipse.gmf.runtime.notation.FontStyle;
39import org.eclipse.gmf.runtime.notation.NotationPackage;
40import org.eclipse.gmf.runtime.notation.View;
41import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
42import org.eclipse.jface.viewers.ICellEditorValidator;
43import org.eclipse.swt.SWT;
44import org.eclipse.swt.accessibility.AccessibleEvent;
45import org.eclipse.swt.graphics.Color;
46import org.eclipse.swt.graphics.FontData;
47import org.eclipse.swt.graphics.Image;
48 
49import de.uka.ipd.sdq.pcm.gmf.repository.edit.policies.PalladioComponentModelTextSelectionEditPolicy;
50import de.uka.ipd.sdq.pcm.gmf.repository.part.PalladioComponentModelVisualIDRegistry;
51import de.uka.ipd.sdq.pcm.gmf.repository.providers.PalladioComponentModelElementTypes;
52 
53/**
54 * @generated
55 */
56public class CompleteParentStereotypeLabel2EditPart extends LabelEditPart
57                implements ITextAwareEditPart {
58 
59        /**
60         * @generated
61         */
62        public static final int VISUAL_ID = 6104;
63 
64        /**
65         * @generated
66         */
67        private DirectEditManager manager;
68 
69        /**
70         * @generated
71         */
72        private IParser parser;
73 
74        /**
75         * @generated
76         */
77        private List parserElements;
78 
79        /**
80         * @generated
81         */
82        private String defaultText;
83 
84        /**
85         * @generated
86         */
87        static {
88                registerSnapBackPosition(PalladioComponentModelVisualIDRegistry
89                                .getType(CompleteParentStereotypeLabel2EditPart.VISUAL_ID),
90                                new Point(0, 40));
91        }
92 
93        /**
94         * @generated
95         */
96        public CompleteParentStereotypeLabel2EditPart(View view) {
97                super(view);
98        }
99 
100        /**
101         * @generated
102         */
103        protected void createDefaultEditPolicies() {
104                super.createDefaultEditPolicies();
105                installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE,
106                                new LabelDirectEditPolicy());
107        }
108 
109        /**
110         * @generated
111         */
112        public int getKeyPoint() {
113                return ConnectionLocator.MIDDLE;
114        }
115 
116        /**
117         * @generated
118         */
119        protected String getLabelTextHelper(IFigure figure) {
120                if (figure instanceof WrapLabel) {
121                        return ((WrapLabel) figure).getText();
122                } else {
123                        return ((Label) figure).getText();
124                }
125        }
126 
127        /**
128         * @generated
129         */
130        protected void setLabelTextHelper(IFigure figure, String text) {
131                if (figure instanceof WrapLabel) {
132                        ((WrapLabel) figure).setText(text);
133                } else {
134                        ((Label) figure).setText(text);
135                }
136        }
137 
138        /**
139         * @generated
140         */
141        protected Image getLabelIconHelper(IFigure figure) {
142                if (figure instanceof WrapLabel) {
143                        return ((WrapLabel) figure).getIcon();
144                } else {
145                        return ((Label) figure).getIcon();
146                }
147        }
148 
149        /**
150         * @generated
151         */
152        protected void setLabelIconHelper(IFigure figure, Image icon) {
153                if (figure instanceof WrapLabel) {
154                        ((WrapLabel) figure).setIcon(icon);
155                } else {
156                        ((Label) figure).setIcon(icon);
157                }
158        }
159 
160        /**
161         * @generated
162         */
163        public void setLabel(WrapLabel figure) {
164                unregisterVisuals();
165                setFigure(figure);
166                defaultText = getLabelTextHelper(figure);
167                registerVisuals();
168                refreshVisuals();
169        }
170 
171        /**
172         * @generated
173         */
174        protected List getModelChildren() {
175                return Collections.EMPTY_LIST;
176        }
177 
178        /**
179         * @generated
180         */
181        public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
182                return null;
183        }
184 
185        /**
186         * @generated
187         */
188        protected EObject getParserElement() {
189                EObject element = resolveSemanticElement();
190                return element != null ? element : (View) getModel();
191        }
192 
193        /**
194         * @generated
195         */
196        protected Image getLabelIcon() {
197                return null;
198        }
199 
200        /**
201         * @generated
202         */
203        protected String getLabelText() {
204                String text = null;
205                if (getParser() != null) {
206                        text = getParser().getPrintString(
207                                        new EObjectAdapter(getParserElement()),
208                                        getParserOptions().intValue());
209                }
210                if (text == null || text.length() == 0) {
211                        text = defaultText;
212                }
213                return text;
214        }
215 
216        /**
217         * @generated
218         */
219        public void setLabelText(String text) {
220                setLabelTextHelper(getFigure(), text);
221                Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
222                if (pdEditPolicy instanceof PalladioComponentModelTextSelectionEditPolicy) {
223                        ((PalladioComponentModelTextSelectionEditPolicy) pdEditPolicy)
224                                        .refreshFeedback();
225                }
226        }
227 
228        /**
229         * @generated
230         */
231        public String getEditText() {
232                if (getParser() == null) {
233                        return ""; //$NON-NLS-1$
234                }
235                return getParser().getEditString(
236                                new EObjectAdapter(getParserElement()),
237                                getParserOptions().intValue());
238        }
239 
240        /**
241         * @generated
242         */
243        protected boolean isEditable() {
244                return false;
245        }
246 
247        /**
248         * @generated
249         */
250        public ICellEditorValidator getEditTextValidator() {
251                return new ICellEditorValidator() {
252 
253                        public String isValid(final Object value) {
254                                if (value instanceof String) {
255                                        final EObject element = getParserElement();
256                                        final IParser parser = getParser();
257                                        try {
258                                                IParserEditStatus valid = (IParserEditStatus) getEditingDomain()
259                                                                .runExclusive(new RunnableWithResult.Impl() {
260 
261                                                                        public void run() {
262                                                                                setResult(parser.isValidEditString(
263                                                                                                new EObjectAdapter(element),
264                                                                                                (String) value));
265                                                                        }
266                                                                });
267                                                return valid.getCode() == ParserEditStatus.EDITABLE ? null
268                                                                : valid.getMessage();
269                                        } catch (InterruptedException ie) {
270                                                ie.printStackTrace();
271                                        }
272                                }
273 
274                                // shouldn't get here
275                                return null;
276                        }
277                };
278        }
279 
280        /**
281         * @generated
282         */
283        public IContentAssistProcessor getCompletionProcessor() {
284                if (getParser() == null) {
285                        return null;
286                }
287                return getParser().getCompletionProcessor(
288                                new EObjectAdapter(getParserElement()));
289        }
290 
291        /**
292         * @generated
293         */
294        public ParserOptions getParserOptions() {
295                return ParserOptions.NONE;
296        }
297 
298        /**
299         * @generated
300         */
301        public IParser getParser() {
302                if (parser == null) {
303                        String parserHint = ((View) getModel()).getType();
304                        ParserHintAdapter hintAdapter = new ParserHintAdapter(
305                                        getParserElement(), parserHint) {
306 
307                                public Object getAdapter(Class adapter) {
308                                        if (IElementType.class.equals(adapter)) {
309                                                return PalladioComponentModelElementTypes.CompleteComponentTypeParentProvidesComponentTypes_4104;
310                                        }
311                                        return super.getAdapter(adapter);
312                                }
313                        };
314                        parser = ParserService.getInstance().getParser(hintAdapter);
315                }
316                return parser;
317        }
318 
319        /**
320         * @generated
321         */
322        protected DirectEditManager getManager() {
323                if (manager == null) {
324                        setManager(new TextDirectEditManager(this, TextDirectEditManager
325                                        .getTextCellEditorClass(this),
326                                        PalladioComponentModelEditPartFactory
327                                                        .getTextCellEditorLocator(this)));
328                }
329                return manager;
330        }
331 
332        /**
333         * @generated
334         */
335        protected void setManager(DirectEditManager manager) {
336                this.manager = manager;
337        }
338 
339        /**
340         * @generated
341         */
342        protected void performDirectEdit() {
343                getManager().show();
344        }
345 
346        /**
347         * @generated
348         */
349        protected void performDirectEdit(Point eventLocation) {
350                if (getManager().getClass() == TextDirectEditManager.class) {
351                        ((TextDirectEditManager) getManager()).show(eventLocation
352                                        .getSWTPoint());
353                }
354        }
355 
356        /**
357         * @generated
358         */
359        private void performDirectEdit(char initialCharacter) {
360                if (getManager() instanceof TextDirectEditManager) {
361                        ((TextDirectEditManager) getManager()).show(initialCharacter);
362                } else {
363                        performDirectEdit();
364                }
365        }
366 
367        /**
368         * @generated
369         */
370        protected void performDirectEditRequest(Request request) {
371                final Request theRequest = request;
372                try {
373                        getEditingDomain().runExclusive(new Runnable() {
374 
375                                public void run() {
376                                        if (isActive() && isEditable()) {
377                                                if (theRequest
378                                                                .getExtendedData()
379                                                                .get(
380                                                                                RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
381                                                        Character initialChar = (Character) theRequest
382                                                                        .getExtendedData()
383                                                                        .get(
384                                                                                        RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
385                                                        performDirectEdit(initialChar.charValue());
386                                                } else if ((theRequest instanceof DirectEditRequest)
387                                                                && (getEditText().equals(getLabelText()))) {
388                                                        DirectEditRequest editRequest = (DirectEditRequest) theRequest;
389                                                        performDirectEdit(editRequest.getLocation());
390                                                } else {
391                                                        performDirectEdit();
392                                                }
393                                        }
394                                }
395                        });
396                } catch (InterruptedException e) {
397                        e.printStackTrace();
398                }
399        }
400 
401        /**
402         * @generated
403         */
404        protected void refreshVisuals() {
405                super.refreshVisuals();
406                refreshLabel();
407                refreshFont();
408                refreshFontColor();
409                refreshUnderline();
410                refreshStrikeThrough();
411        }
412 
413        /**
414         * @generated
415         */
416        protected void refreshLabel() {
417                setLabelTextHelper(getFigure(), getLabelText());
418                setLabelIconHelper(getFigure(), getLabelIcon());
419                Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
420                if (pdEditPolicy instanceof PalladioComponentModelTextSelectionEditPolicy) {
421                        ((PalladioComponentModelTextSelectionEditPolicy) pdEditPolicy)
422                                        .refreshFeedback();
423                }
424        }
425 
426        /**
427         * @generated
428         */
429        protected void refreshUnderline() {
430                FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(
431                                NotationPackage.eINSTANCE.getFontStyle());
432                if (style != null && getFigure() instanceof WrapLabel) {
433                        ((WrapLabel) getFigure()).setTextUnderline(style.isUnderline());
434                }
435        }
436 
437        /**
438         * @generated
439         */
440        protected void refreshStrikeThrough() {
441                FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(
442                                NotationPackage.eINSTANCE.getFontStyle());
443                if (style != null && getFigure() instanceof WrapLabel) {
444                        ((WrapLabel) getFigure()).setTextStrikeThrough(style
445                                        .isStrikeThrough());
446                }
447        }
448 
449        /**
450         * @generated
451         */
452        protected void refreshFont() {
453                FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(
454                                NotationPackage.eINSTANCE.getFontStyle());
455                if (style != null) {
456                        FontData fontData = new FontData(style.getFontName(), style
457                                        .getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL)
458                                        | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
459                        setFont(fontData);
460                }
461        }
462 
463        /**
464         * @generated
465         */
466        protected void setFontColor(Color color) {
467                getFigure().setForegroundColor(color);
468        }
469 
470        /**
471         * @generated
472         */
473        protected void addSemanticListeners() {
474                if (getParser() instanceof ISemanticParser) {
475                        EObject element = resolveSemanticElement();
476                        parserElements = ((ISemanticParser) getParser())
477                                        .getSemanticElementsBeingParsed(element);
478                        for (int i = 0; i < parserElements.size(); i++) {
479                                addListenerFilter(
480                                                "SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$
481                        }
482                } else {
483                        super.addSemanticListeners();
484                }
485        }
486 
487        /**
488         * @generated
489         */
490        protected void removeSemanticListeners() {
491                if (parserElements != null) {
492                        for (int i = 0; i < parserElements.size(); i++) {
493                                removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
494                        }
495                } else {
496                        super.removeSemanticListeners();
497                }
498        }
499 
500        /**
501         * @generated
502         */
503        protected AccessibleEditPart getAccessibleEditPart() {
504                if (accessibleEP == null) {
505                        accessibleEP = new AccessibleGraphicalEditPart() {
506 
507                                public void getName(AccessibleEvent e) {
508                                        e.result = getLabelTextHelper(getFigure());
509                                }
510                        };
511                }
512                return accessibleEP;
513        }
514 
515        /**
516         * @generated
517         */
518        private View getFontStyleOwnerView() {
519                return getPrimaryView();
520        }
521 
522        /**
523         * @generated
524         */
525        protected void handleNotificationEvent(Notification event) {
526                Object feature = event.getFeature();
527                if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
528                        Integer c = (Integer) event.getNewValue();
529                        setFontColor(DiagramColorRegistry.getInstance().getColor(c));
530                } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(
531                                feature)) {
532                        refreshUnderline();
533                } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough()
534                                .equals(feature)) {
535                        refreshStrikeThrough();
536                } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(
537                                feature)
538                                || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(
539                                                feature)
540                                || NotationPackage.eINSTANCE.getFontStyle_Bold()
541                                                .equals(feature)
542                                || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(
543                                                feature)) {
544                        refreshFont();
545                } else {
546                        if (getParser() != null
547                                        && getParser().isAffectingEvent(event,
548                                                        getParserOptions().intValue())) {
549                                refreshLabel();
550                        }
551                        if (getParser() instanceof ISemanticParser) {
552                                ISemanticParser modelParser = (ISemanticParser) getParser();
553                                if (modelParser.areSemanticElementsAffected(null, event)) {
554                                        removeSemanticListeners();
555                                        if (resolveSemanticElement() != null) {
556                                                addSemanticListeners();
557                                        }
558                                        refreshLabel();
559                                }
560                        }
561                }
562                super.handleNotificationEvent(event);
563        }
564 
565        /**
566         * @generated
567         */
568        protected IFigure createFigure() {
569                // Parent should assign one using setLabel() method
570                return null;
571        }
572}

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