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

COVERAGE SUMMARY FOR SOURCE FILE [DataTypeDialog.java]

nameclass, %method, %block, %line, %
DataTypeDialog.java0%   (0/8)0%   (0/31)0%   (0/721)0%   (0/166)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DataTypeDialog0%   (0/1)0%   (0/16)0%   (0/601)0%   (0/140)
DataTypeDialog (Shell): void 0%   (0/1)0%   (0/4)0%   (0/2)
access$0 (DataTypeDialog): Combo 0%   (0/1)0%   (0/3)0%   (0/1)
access$1 (DataTypeDialog): Text 0%   (0/1)0%   (0/3)0%   (0/1)
access$2 (DataTypeDialog): DataTypeEnum 0%   (0/1)0%   (0/3)0%   (0/1)
configureShell (Shell): void 0%   (0/1)0%   (0/10)0%   (0/4)
createButtonsForButtonBar (Composite): void 0%   (0/1)0%   (0/25)0%   (0/7)
createDialogArea (Composite): Control 0%   (0/1)0%   (0/368)0%   (0/68)
getEntityName (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getInitialSize (): Point 0%   (0/1)0%   (0/6)0%   (0/1)
init (DataTypeEnum, String, String, String): void 0%   (0/1)0%   (0/47)0%   (0/16)
setEnabled (boolean): void 0%   (0/1)0%   (0/29)0%   (0/8)
setOKButtonDisabled (): void 0%   (0/1)0%   (0/6)0%   (0/2)
setOKButtonEnabled (): void 0%   (0/1)0%   (0/6)0%   (0/2)
setTopCollectionLayout (): void 0%   (0/1)0%   (0/20)0%   (0/6)
setTopCompositeLayout (): void 0%   (0/1)0%   (0/20)0%   (0/6)
validateInput (): void 0%   (0/1)0%   (0/48)0%   (0/14)
     
class DataTypeDialog$10%   (0/1)0%   (0/3)0%   (0/36)0%   (0/10)
DataTypeDialog$1 (DataTypeDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetDefaultSelected (SelectionEvent): void 0%   (0/1)0%   (0/15)0%   (0/4)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/15)0%   (0/4)
     
class DataTypeDialog$20%   (0/1)0%   (0/2)0%   (0/13)0%   (0/5)
DataTypeDialog$2 (DataTypeDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/7)0%   (0/3)
     
class DataTypeDialog$30%   (0/1)0%   (0/2)0%   (0/13)0%   (0/5)
DataTypeDialog$3 (DataTypeDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/7)0%   (0/3)
     
class DataTypeDialog$40%   (0/1)0%   (0/2)0%   (0/10)0%   (0/4)
DataTypeDialog$4 (DataTypeDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
modifyText (ModifyEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class DataTypeDialog$50%   (0/1)0%   (0/2)0%   (0/10)0%   (0/4)
DataTypeDialog$5 (DataTypeDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
modifyText (ModifyEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class DataTypeDialog$60%   (0/1)0%   (0/2)0%   (0/15)0%   (0/4)
DataTypeDialog$6 (DataTypeDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/9)0%   (0/2)
     
class DataTypeDialog$70%   (0/1)0%   (0/2)0%   (0/23)0%   (0/7)
DataTypeDialog$7 (DataTypeDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/17)0%   (0/5)

1package de.uka.ipd.sdq.pcm.dialogs.datatype;
2 
3import org.eclipse.jface.dialogs.IDialogConstants;
4import org.eclipse.jface.dialogs.TitleAreaDialog;
5import org.eclipse.swt.SWT;
6import org.eclipse.swt.custom.StackLayout;
7import org.eclipse.swt.events.ModifyEvent;
8import org.eclipse.swt.events.ModifyListener;
9import org.eclipse.swt.events.SelectionAdapter;
10import org.eclipse.swt.events.SelectionEvent;
11import org.eclipse.swt.graphics.Point;
12import org.eclipse.swt.layout.FormLayout;
13import org.eclipse.swt.layout.GridData;
14import org.eclipse.swt.layout.GridLayout;
15import org.eclipse.swt.widgets.Button;
16import org.eclipse.swt.widgets.Combo;
17import org.eclipse.swt.widgets.Composite;
18import org.eclipse.swt.widgets.Control;
19import org.eclipse.swt.widgets.Group;
20import org.eclipse.swt.widgets.Label;
21import org.eclipse.swt.widgets.Shell;
22import org.eclipse.swt.widgets.Text;
23 
24import de.uka.ipd.sdq.pcm.dialogs.Messages;
25 
26/**
27 * The dialogue is used in the PCM Bench for the production by Collection or
28 * Composite data types.
29 * 
30 * @author Roman Andrej
31 */
32public abstract class DataTypeDialog extends TitleAreaDialog {
33        
34        /** Edited entity properties */
35        private String entityName;
36        
37        /**
38         *  help value define edit DataType (collectionSignator ,compositeSignator)
39         */
40        private DataTypeEnum editeDataType;
41 
42        private Composite composite;
43        private Group compositeGroup, collectionGroup;
44        private Button compositeButton;
45        private Button collectionButton;
46        private Label nameLabelField;
47        private Label typeLabelField;
48        private Text nameField, typeField;
49        private Button typeButton;
50        private StackLayout stackLayout;
51        private Combo combo;
52        private Shell shell;
53        
54        public DataTypeDialog(Shell parentShell) {
55                super(parentShell);
56        }
57 
58        /**
59         * The method is called with the editing of the type of DataType.
60         * 
61         * @param repositoryName -
62         *            the repository name of editing DataType
63         * @param entityName -
64         *            the name of the editing DataType
65         * @param entityInnerType -
66         *            the inner type of the editing DataType
67         */
68        protected void init(DataTypeEnum dataTyp, String repositoryName,
69                        String entityName, String entityInnerType) {
70                this.entityName = entityName;
71                this.editeDataType = dataTyp;
72 
73                setTitle(Messages.DataTypeDialog_EditTitle);
74                shell.setText(Messages.DataTypeDialog_ShellEditTitle);
75 
76                if (dataTyp == DataTypeEnum.COLLECTION)
77                        setTopCollectionLayout();
78                if (dataTyp == DataTypeEnum.COMPOSITE)
79                        setTopCompositeLayout();
80                
81                // Initialization the SWT elements with edit DataType attributes
82                combo.setText(repositoryName);
83                combo.setEnabled(false);
84                nameField.setText(entityName);
85                if (entityInnerType != null)
86                        typeField.setText(entityInnerType);
87                
88                setEnabled(true);
89                setOKButtonDisabled();
90        }
91 
92        /* (non-Javadoc)
93         * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
94         */
95        @Override
96        protected void configureShell(Shell newShell) {
97                super.configureShell(newShell);
98                shell = newShell;
99                newShell.setText(Messages.DataTypeDialog_ShellNewTitle);
100        }
101        
102        /* (non-Javadoc)
103         * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
104         */
105        @Override
106        protected Control createDialogArea(Composite parent) {
107 
108                Composite area = (Composite) super.createDialogArea(parent);
109                final Composite container = new Composite(area, SWT.NONE);
110                container.setLayout(new GridLayout());
111                container.setLayoutData(new GridData(GridData.FILL_BOTH));
112 
113                // Reposetory section
114                final Group reposetoryGroup = new Group(container, SWT.NONE);
115                reposetoryGroup.setText("Repository");
116                reposetoryGroup.setLayoutData(new GridData(478, 30));
117                reposetoryGroup.setLayout(new GridLayout());
118 
119                combo = new Combo(reposetoryGroup, SWT.DROP_DOWN|SWT.READ_ONLY);
120                combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
121                combo.addSelectionListener(new SelectionAdapter() {
122 
123                        /* (non-Javadoc)
124                         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
125                         */
126                        @Override
127                        public void widgetSelected(SelectionEvent e) {
128                                setEditedResource(combo.getText());
129                                setEnabled(true);
130                                validateInput();
131                        }
132 
133                        /* (non-Javadoc)
134                         * @see org.eclipse.swt.events.SelectionAdapter#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
135                         */
136                        @Override
137                        public void widgetDefaultSelected(SelectionEvent e) {
138                                setEditedResource(combo.getText());
139                                setEnabled(true);
140                                validateInput();
141                        }
142                });
143                combo.setItems(getLoadedRepositories());
144 
145                // RadioButtons section
146                final Group choiceTypeGroup = new Group(container, SWT.SHADOW_ETCHED_IN);
147                choiceTypeGroup.setText("Choose DataType");
148                final GridLayout gridLayout = new GridLayout();
149                gridLayout.numColumns = 2;
150                choiceTypeGroup.setLayout(gridLayout);
151                choiceTypeGroup.setLayoutData(new GridData(478, 74));
152 
153                // Create new Composite
154                composite = new Composite(container, SWT.NONE);
155                stackLayout = new StackLayout();
156                composite.setLayout(stackLayout);
157                composite.setLayoutData(new GridData(484, 139));
158 
159                // Create CollyectionDataType button
160                collectionButton = new Button(choiceTypeGroup, SWT.RADIO);
161                collectionButton.setLayoutData(new GridData(129, SWT.DEFAULT));
162                collectionButton.setText("CollectionDataType");
163                collectionButton.addSelectionListener(new SelectionAdapter() {
164                        @Override
165                        public void widgetSelected(SelectionEvent e) {
166                                setTopCollectionLayout();
167                                validateInput();
168                        }
169                });
170                new Label(choiceTypeGroup, SWT.NONE);
171 
172                // Create CompositeDataType button
173                compositeButton = new Button(choiceTypeGroup, SWT.RADIO);
174                compositeButton.setText("CompositeDataType");
175                compositeButton.addSelectionListener(new SelectionAdapter() {
176                        @Override
177                        public void widgetSelected(SelectionEvent e) {
178                                setTopCompositeLayout();
179                                validateInput();
180                        }
181                });
182                new Label(choiceTypeGroup, SWT.NONE);
183 
184                nameLabelField = new Label(choiceTypeGroup, SWT.NONE);
185                final GridData gridData = new GridData(SWT.RIGHT, SWT.CENTER, false,
186                                false);
187                gridData.widthHint = 107;
188                nameLabelField.setLayoutData(gridData);
189                nameLabelField.setText("Name:");
190 
191                nameField = new Text(choiceTypeGroup, SWT.BORDER);
192                final GridData gdNameField = new GridData(SWT.LEFT, SWT.CENTER, true,
193                                false);
194                gdNameField.widthHint = 334;
195                nameField.setLayoutData(gdNameField);
196                nameField.addModifyListener(new ModifyListener() {
197                        
198                        /* (non-Javadoc)
199                         * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
200                         */
201                        public void modifyText(ModifyEvent e) {
202                                validateInput();
203                        }
204                });
205 
206                // Create CompositeDataType Group with FormLayout
207                compositeGroup = new Group(composite, SWT.NONE);
208                compositeGroup.setLayout(new FormLayout());
209                compositeGroup.setText("innerDeclaration CompositeDataType");
210                
211                // Create inner section for CompositeDataType group
212                createInnerSectionCompositeGroup(compositeGroup);
213 
214                // Create CollectionDataType Group
215                collectionGroup = new Group(composite, SWT.NONE);
216                final GridLayout gridLayoutCollGroup = new GridLayout();
217                gridLayoutCollGroup.numColumns = 3;
218                collectionGroup.setLayout(gridLayoutCollGroup);
219                collectionGroup.setText("innerType CollectionDataType");
220 
221                // Create inner section for CollectionDataType group
222                typeLabelField = new Label(collectionGroup, SWT.NONE);
223                typeLabelField.setLayoutData(new GridData(40, SWT.DEFAULT));
224                typeLabelField.setText("Type: ");
225 
226                typeField = new Text(collectionGroup, SWT.BORDER | SWT.SINGLE
227                                | SWT.READ_ONLY);
228                typeField.setLayoutData(new GridData(200, 15));
229                typeField.addModifyListener(new ModifyListener() {
230                        public void modifyText(ModifyEvent e) {
231                                validateInput();
232                        }
233                });
234 
235                typeButton = new Button(collectionGroup, SWT.NONE);
236                typeButton.setLayoutData(new GridData(SWT.DEFAULT, 20));
237                typeButton.setText("Select...");
238                typeButton.addSelectionListener(new SelectionAdapter() {
239                        @Override
240                        public void widgetSelected(SelectionEvent e) {
241                                typeField.setText(getSelectedInnerType(e));
242                        }
243                });
244 
245                // Create Separator
246                final Label label = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
247                label.setLayoutData(new GridData(482, SWT.DEFAULT));
248 
249                // set dialog default preferences
250                setTitle(Messages.DataTypeDialog_NewTitle);
251                setTopCollectionLayout();
252                setEnabled(false);
253 
254                return container;
255        }
256 
257        /**
258         * Enables the receiver all component if the argument is true, and disables
259         * it otherwise.
260         * 
261         * @param enabled
262         *            the new enabled state
263         */
264        public void setEnabled(boolean enabled) {
265                compositeButton.setEnabled(enabled);
266                collectionButton.setEnabled(enabled);
267                typeLabelField.setEnabled(enabled);
268                typeField.setEnabled(enabled);
269                typeButton.setEnabled(enabled);
270                nameLabelField.setEnabled(enabled);
271                nameField.setEnabled(enabled);
272        }
273 
274        /* (non-Javadoc)
275         * @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
276         */
277        @Override
278        protected Point getInitialSize() {
279                return new Point(500, 446);
280        }
281 
282        /* (non-Javadoc)
283         * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
284         */
285        @Override
286        protected void createButtonsForButtonBar(Composite parent) {
287                createButton(parent, IDialogConstants.CANCEL_ID,
288                                IDialogConstants.CANCEL_LABEL, false);
289                createButton(parent, IDialogConstants.OK_ID,
290                                IDialogConstants.OK_LABEL, false);
291                getButton(IDialogConstants.OK_ID).addSelectionListener(new SelectionAdapter() {
292 
293                        /* (non-Javadoc)
294                         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
295                         */
296                        @Override
297                        public void widgetSelected(SelectionEvent e) {
298                                if (editeDataType == DataTypeEnum.COLLECTION)
299                                        createCollectionDataType();
300                                if (editeDataType == DataTypeEnum.COMPOSITE)
301                                        createCompositeDataType();
302                        }
303                });
304                setOKButtonDisabled();
305        }
306 
307        protected void setOKButtonEnabled() {
308                getButton(IDialogConstants.OK_ID).setEnabled(true);
309        }
310        
311        protected void setOKButtonDisabled() {
312                getButton(IDialogConstants.OK_ID).setEnabled(false);
313        }
314 
315        /** The method define the list with a loaded repository */
316        public abstract String[] getLoadedRepositories();
317 
318        /**The method create the editing area for CompositeDataType*/
319        public abstract void createInnerSectionCompositeGroup(Composite group);
320 
321        public abstract String getSelectedInnerType(SelectionEvent event);
322 
323        public abstract void setEditedResource(String resource);
324 
325        /** The method create a new CollectionDataType */
326        public abstract void createCollectionDataType();
327 
328        /** The method create a new CompositeDataType */
329        public abstract void createCompositeDataType();
330        
331        public abstract boolean validateCompositeDataType();
332 
333        protected String getEntityName() {
334                return entityName;
335        }
336 
337        /**
338         * The method specified in topControl is visible and all other controls are
339         * not visible.
340         */
341        protected void setTopCompositeLayout() {
342                collectionButton.setSelection(false);
343                compositeButton.setSelection(true);
344                stackLayout.topControl = compositeGroup;
345                composite.layout();
346                editeDataType = DataTypeEnum.COMPOSITE;
347        }
348 
349        protected void setTopCollectionLayout() {
350                compositeButton.setSelection(false);
351                collectionButton.setSelection(true);
352                stackLayout.topControl = collectionGroup;
353                composite.layout();
354                editeDataType = DataTypeEnum.COLLECTION;
355        }
356        
357        /**
358         * The method examines whether the straight editing DataTYpe type has all parameters.
359         */
360        public void validateInput() {
361                entityName = nameField.getText();
362 
363                if (entityName.equals("")) {
364                        setOKButtonDisabled();
365                        setErrorMessage(Messages.DataTypeDialog_ErrorMsgName);
366                        return;
367                }
368 
369                if (collectionButton.getSelection() && typeField.getText().equals("")) {
370                        setOKButtonDisabled();
371                        setErrorMessage(Messages.DataTypeDialog_ErrorMsgInner);
372                } else if (compositeButton.getSelection()
373                                && !validateCompositeDataType()) {
374                        setOKButtonDisabled();
375                } else {
376                        setErrorMessage(null);
377                        setOKButtonEnabled();
378                }
379        }
380}

[all classes][de.uka.ipd.sdq.pcm.dialogs.datatype]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov