EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.pcmbench.tabs.operations]

COVERAGE SUMMARY FOR SOURCE FILE [TypeDialogCellEditor.java]

nameclass, %method, %block, %line, %
TypeDialogCellEditor.java0%   (0/4)0%   (0/22)0%   (0/251)0%   (0/52)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TypeDialogCellEditor0%   (0/1)0%   (0/15)0%   (0/164)0%   (0/34)
TypeDialogCellEditor (Composite, SelectionListener): void 0%   (0/1)0%   (0/15)0%   (0/5)
access$0 (TypeDialogCellEditor): void 0%   (0/1)0%   (0/3)0%   (0/1)
access$1 (TypeDialogCellEditor): Button 0%   (0/1)0%   (0/3)0%   (0/1)
access$2 (TypeDialogCellEditor): FocusListener 0%   (0/1)0%   (0/3)0%   (0/1)
access$3 (TypeDialogCellEditor): Composite 0%   (0/1)0%   (0/3)0%   (0/1)
access$4 (TypeDialogCellEditor, Control): Object 0%   (0/1)0%   (0/4)0%   (0/1)
access$5 (TypeDialogCellEditor, Object): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
access$6 (TypeDialogCellEditor): void 0%   (0/1)0%   (0/3)0%   (0/1)
access$7 (TypeDialogCellEditor, String): void 0%   (0/1)0%   (0/4)0%   (0/1)
access$8 (TypeDialogCellEditor): void 0%   (0/1)0%   (0/3)0%   (0/1)
access$9 (TypeDialogCellEditor): void 0%   (0/1)0%   (0/3)0%   (0/1)
createControl (Composite): Control 0%   (0/1)0%   (0/95)0%   (0/18)
doSetFocus (): void 0%   (0/1)0%   (0/5)0%   (0/2)
doSetValue (Object): void 0%   (0/1)0%   (0/4)0%   (0/2)
getButtonFocusListener (): FocusListener 0%   (0/1)0%   (0/12)0%   (0/3)
     
class TypeDialogCellEditor$10%   (0/1)0%   (0/2)0%   (0/14)0%   (0/5)
TypeDialogCellEditor$1 (TypeDialogCellEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
keyReleased (KeyEvent): void 0%   (0/1)0%   (0/8)0%   (0/3)
     
class TypeDialogCellEditor$20%   (0/1)0%   (0/2)0%   (0/62)0%   (0/14)
TypeDialogCellEditor$2 (TypeDialogCellEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/56)0%   (0/12)
     
class TypeDialogCellEditor$30%   (0/1)0%   (0/3)0%   (0/11)0%   (0/5)
TypeDialogCellEditor$3 (TypeDialogCellEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
focusGained (FocusEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
focusLost (FocusEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)

1package de.uka.ipd.sdq.pcmbench.tabs.operations;
2 
3import java.text.MessageFormat;
4 
5import org.eclipse.jface.viewers.DialogCellEditor;
6import org.eclipse.swt.SWT;
7import org.eclipse.swt.events.FocusEvent;
8import org.eclipse.swt.events.FocusListener;
9import org.eclipse.swt.events.KeyAdapter;
10import org.eclipse.swt.events.KeyEvent;
11import org.eclipse.swt.events.SelectionAdapter;
12import org.eclipse.swt.events.SelectionEvent;
13import org.eclipse.swt.events.SelectionListener;
14import org.eclipse.swt.graphics.Color;
15import org.eclipse.swt.graphics.Font;
16import org.eclipse.swt.widgets.Button;
17import org.eclipse.swt.widgets.Composite;
18import org.eclipse.swt.widgets.Control;
19 
20 
21/**
22 * @author Roman Andrej
23 * 
24 */
25public abstract class TypeDialogCellEditor extends DialogCellEditor {
26 
27         /** The editor control. */
28    private Composite editor;
29 
30    /** The current contents. */
31    private Control contents;
32 
33    /** The button. */
34    private Button selButton;
35    private Button delButton;
36    
37    /**
38         * Listens for 'focusLost' events and  fires the 'apply' event as long
39         * as the focus wasn't lost because the dialog was opened.
40         */
41        private FocusListener buttonFocusListener;
42        
43        /**
44     * The value of this cell editor; initially <code>null</code>.
45     */
46    private Object value = null;
47    
48 
49        /* @See org.eclipse.jface.viewers.DialogCellEditor#DialogCellEditor(org.eclipse.swt.widgets.Control
50         *      parent)
51         */
52        public TypeDialogCellEditor(Composite composite,
53                        SelectionListener cellValueListener) {
54                super(composite, SWT.DEL);
55                
56                if (delButton != null) {
57                        delButton.addSelectionListener(cellValueListener);
58                }
59        }
60        
61        /* (non-Javadoc)
62         * @see org.eclipse.jface.viewers.DialogCellEditor#createControl(org.eclipse.swt.widgets.Composite)
63         */
64        @Override
65        protected Control createControl(Composite parent) {
66 
67                Font font = parent.getFont();
68                Color bg = parent.getBackground();
69 
70                editor = new Composite(parent, getStyle());
71                editor.setFont(font);
72                editor.setBackground(bg);
73 
74                contents = createContents(editor);
75                updateContents(value);
76 
77                delButton = new Button(editor, SWT.DOWN);
78                delButton.setText("X");
79                delButton.setFont(font);
80 
81                selButton = createButton(editor);
82                selButton.setFont(font);
83                editor.setLayout(new DialogCellLayout(contents, selButton, delButton));
84                selButton.addKeyListener(new KeyAdapter() {
85 
86                        /* (non-Javadoc)
87                         * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
88                         */
89                        @Override
90                        public void keyReleased(KeyEvent e) {
91                                if (e.character == '\u001b') { // Escape
92                                        fireCancelEditor();
93                                }
94                        }
95                });
96 
97                selButton.addFocusListener(getButtonFocusListener());
98                selButton.addSelectionListener(new SelectionAdapter() {
99        
100                        /* (non-Javadoc)
101                         * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
102                         */
103                        @Override
104                        public void widgetSelected(SelectionEvent event) {
105                                // Remove the button's focus listener since it's guaranteed
106                                // to lose focus when the dialog opens
107                                selButton.removeFocusListener(getButtonFocusListener());
108 
109                                Object newValue = openDialogBox(editor);
110 
111                                // Re-add the listener once the dialog closes
112                                selButton.addFocusListener(getButtonFocusListener());
113 
114                                if (newValue != null) {
115                                        boolean newValidState = isCorrect(newValue);
116                                        if (newValidState) {
117                                                markDirty();
118                                                doSetValue(newValue);
119                                        } else {
120                                                // try to insert the current value into the error
121                                                // message.
122                                                setErrorMessage(MessageFormat.format(getErrorMessage(),
123                                                                new Object[] { newValue.toString() }));
124                                        }
125                                        fireApplyEditorValue();
126                                }
127                        }
128                });
129 
130                setValueValid(true);
131 
132                return editor;
133        }
134        
135 
136         /**
137         * Return a listener for button focus.
138         * 
139         * @return FocusListener
140         */
141        private FocusListener getButtonFocusListener() {
142                if (buttonFocusListener == null) {
143                        buttonFocusListener = new FocusListener() {
144 
145                                /* (non-Javadoc)
146                                 * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
147                                 */
148                                public void focusGained(FocusEvent e) {
149                                        // Do nothing
150                                }
151 
152                                /* (non-Javadoc)
153                                 * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
154                                 */
155                                public void focusLost(FocusEvent e) {
156                                        TypeDialogCellEditor.this.focusLost();
157                                }
158                        };
159                }
160 
161                return buttonFocusListener;
162        }
163 
164        /* (non-Javadoc)
165         * @see org.eclipse.jface.viewers.DialogCellEditor#doSetFocus()
166         */
167        @Override
168        protected void doSetFocus() {
169                 selButton.setFocus();
170        }
171 
172        @Override
173        protected void doSetValue(Object value) {
174                super.doSetValue(value);
175        }
176}

[all classes][de.uka.ipd.sdq.pcmbench.tabs.operations]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov