78
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2007 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module examples.controlexample.DialogTab;
|
|
14
|
|
15
|
|
16
|
|
17 import dwt.DWT;
|
|
18 import dwt.events.SelectionAdapter;
|
|
19 import dwt.events.SelectionEvent;
|
|
20 import dwt.events.SelectionListener;
|
|
21 import dwt.graphics.FontData;
|
|
22 import dwt.graphics.RGB;
|
|
23 import dwt.layout.GridData;
|
|
24 import dwt.layout.GridLayout;
|
|
25 import dwt.printing.PrintDialog;
|
|
26 import dwt.printing.PrinterData;
|
|
27 import dwt.widgets.Button;
|
|
28 import dwt.widgets.ColorDialog;
|
|
29 import dwt.widgets.Combo;
|
|
30 import dwt.widgets.DirectoryDialog;
|
|
31 import dwt.widgets.FileDialog;
|
|
32 import dwt.widgets.FontDialog;
|
|
33 import dwt.widgets.Group;
|
|
34 import dwt.widgets.MessageBox;
|
|
35 import dwt.widgets.Text;
|
|
36 import dwt.widgets.Widget;
|
|
37
|
|
38 import examples.controlexample.Tab;
|
|
39 import examples.controlexample.ControlExample;
|
|
40 import tango.text.convert.Format;
|
|
41
|
|
42 class DialogTab : Tab {
|
|
43 /* Example widgets and groups that contain them */
|
|
44 Group dialogStyleGroup, resultGroup;
|
|
45 Text textWidget;
|
|
46
|
|
47 /* Style widgets added to the "Style" group */
|
|
48 Combo dialogCombo;
|
|
49 Button createButton;
|
|
50 Button okButton, cancelButton;
|
|
51 Button yesButton, noButton;
|
|
52 Button retryButton;
|
|
53 Button abortButton, ignoreButton;
|
|
54 Button iconErrorButton, iconInformationButton, iconQuestionButton;
|
|
55 Button iconWarningButton, iconWorkingButton, noIconButton;
|
|
56 Button primaryModalButton, applicationModalButton, systemModalButton;
|
|
57 Button saveButton, openButton, multiButton;
|
|
58
|
|
59 static const char[] [] FilterExtensions = ["*.txt", "*.bat", "*.doc", "*"];
|
|
60 static char[] [] FilterNames;
|
|
61
|
|
62 /**
|
|
63 * Creates the Tab within a given instance of ControlExample.
|
|
64 */
|
|
65 this(ControlExample instance) {
|
|
66 super(instance);
|
|
67 if( FilterNames.length is 0 ){
|
|
68 FilterNames = [ ControlExample.getResourceString("FilterName_0"),
|
|
69 ControlExample.getResourceString("FilterName_1"),
|
|
70 ControlExample.getResourceString("FilterName_2"),
|
|
71 ControlExample.getResourceString("FilterName_3")];
|
|
72 }
|
|
73 }
|
|
74
|
|
75 /**
|
|
76 * Handle a button style selection event.
|
|
77 *
|
|
78 * @param event the selection event
|
|
79 */
|
|
80 void buttonStyleSelected(SelectionEvent event) {
|
|
81 /*
|
|
82 * Only certain combinations of button styles are
|
|
83 * supported for various dialogs. Make sure the
|
|
84 * control widget reflects only valid combinations.
|
|
85 */
|
|
86 bool ok = okButton.getSelection ();
|
|
87 bool cancel = cancelButton.getSelection ();
|
|
88 bool yes = yesButton.getSelection ();
|
|
89 bool no = noButton.getSelection ();
|
|
90 bool abort = abortButton.getSelection ();
|
|
91 bool retry = retryButton.getSelection ();
|
|
92 bool ignore = ignoreButton.getSelection ();
|
|
93
|
|
94 okButton.setEnabled (!(yes || no || retry || abort || ignore));
|
|
95 cancelButton.setEnabled (!(abort || ignore || (yes !is no)));
|
|
96 yesButton.setEnabled (!(ok || retry || abort || ignore || (cancel && !yes && !no)));
|
|
97 noButton.setEnabled (!(ok || retry || abort || ignore || (cancel && !yes && !no)));
|
|
98 retryButton.setEnabled (!(ok || yes || no));
|
|
99 abortButton.setEnabled (!(ok || cancel || yes || no));
|
|
100 ignoreButton.setEnabled (!(ok || cancel || yes || no));
|
|
101
|
|
102 createButton.setEnabled (
|
|
103 !(ok || cancel || yes || no || retry || abort || ignore) ||
|
|
104 ok ||
|
|
105 (ok && cancel) ||
|
|
106 (yes && no) ||
|
|
107 (yes && no && cancel) ||
|
|
108 (retry && cancel) ||
|
|
109 (abort && retry && ignore));
|
|
110
|
|
111
|
|
112 }
|
|
113
|
|
114 /**
|
|
115 * Handle the create button selection event.
|
|
116 *
|
|
117 * @param event org.eclipse.swt.events.SelectionEvent
|
|
118 */
|
|
119 void createButtonSelected(SelectionEvent event) {
|
|
120
|
|
121 /* Compute the appropriate dialog style */
|
|
122 int style = getDefaultStyle();
|
|
123 if (okButton.getEnabled () && okButton.getSelection ()) style |= DWT.OK;
|
|
124 if (cancelButton.getEnabled () && cancelButton.getSelection ()) style |= DWT.CANCEL;
|
|
125 if (yesButton.getEnabled () && yesButton.getSelection ()) style |= DWT.YES;
|
|
126 if (noButton.getEnabled () && noButton.getSelection ()) style |= DWT.NO;
|
|
127 if (retryButton.getEnabled () && retryButton.getSelection ()) style |= DWT.RETRY;
|
|
128 if (abortButton.getEnabled () && abortButton.getSelection ()) style |= DWT.ABORT;
|
|
129 if (ignoreButton.getEnabled () && ignoreButton.getSelection ()) style |= DWT.IGNORE;
|
|
130 if (iconErrorButton.getEnabled () && iconErrorButton.getSelection ()) style |= DWT.ICON_ERROR;
|
|
131 if (iconInformationButton.getEnabled () && iconInformationButton.getSelection ()) style |= DWT.ICON_INFORMATION;
|
|
132 if (iconQuestionButton.getEnabled () && iconQuestionButton.getSelection ()) style |= DWT.ICON_QUESTION;
|
|
133 if (iconWarningButton.getEnabled () && iconWarningButton.getSelection ()) style |= DWT.ICON_WARNING;
|
|
134 if (iconWorkingButton.getEnabled () && iconWorkingButton.getSelection ()) style |= DWT.ICON_WORKING;
|
|
135 if (primaryModalButton.getEnabled () && primaryModalButton.getSelection ()) style |= DWT.PRIMARY_MODAL;
|
|
136 if (applicationModalButton.getEnabled () && applicationModalButton.getSelection ()) style |= DWT.APPLICATION_MODAL;
|
|
137 if (systemModalButton.getEnabled () && systemModalButton.getSelection ()) style |= DWT.SYSTEM_MODAL;
|
|
138 if (saveButton.getEnabled () && saveButton.getSelection ()) style |= DWT.SAVE;
|
|
139 if (openButton.getEnabled () && openButton.getSelection ()) style |= DWT.OPEN;
|
|
140 if (multiButton.getEnabled () && multiButton.getSelection ()) style |= DWT.MULTI;
|
|
141
|
|
142 /* Open the appropriate dialog type */
|
|
143 char[] name = dialogCombo.getText ();
|
|
144
|
|
145 if (name == ControlExample.getResourceString("ColorDialog")) {
|
|
146 ColorDialog dialog = new ColorDialog (shell ,style);
|
|
147 dialog.setRGB (new RGB (100, 100, 100));
|
|
148 dialog.setText (ControlExample.getResourceString("Title"));
|
|
149 RGB result = dialog.open ();
|
|
150 textWidget.append (Format( ControlExample.getResourceString("ColorDialog")~"{}", Text.DELIMITER));
|
|
151 textWidget.append (Format( ControlExample.getResourceString("Result")~"{}{}", result, Text.DELIMITER, Text.DELIMITER));
|
|
152 return;
|
|
153 }
|
|
154
|
|
155 if (name == ControlExample.getResourceString("DirectoryDialog")) {
|
|
156 DirectoryDialog dialog = new DirectoryDialog (shell, style);
|
|
157 dialog.setMessage (ControlExample.getResourceString("Example_string"));
|
|
158 dialog.setText (ControlExample.getResourceString("Title"));
|
|
159 char[] result = dialog.open ();
|
|
160 textWidget.append (ControlExample.getResourceString("DirectoryDialog") ~ Text.DELIMITER);
|
|
161 textWidget.append (Format( ControlExample.getResourceString("Result"), result ) ~ Text.DELIMITER ~ Text.DELIMITER);
|
|
162 return;
|
|
163 }
|
|
164
|
|
165 if (name== ControlExample.getResourceString("FileDialog")) {
|
|
166 FileDialog dialog = new FileDialog (shell, style);
|
|
167 dialog.setFileName (ControlExample.getResourceString("readme_txt"));
|
|
168 dialog.setFilterNames (FilterNames);
|
|
169 dialog.setFilterExtensions (FilterExtensions);
|
|
170 dialog.setText (ControlExample.getResourceString("Title"));
|
|
171 char[] result = dialog.open();
|
|
172 textWidget.append (ControlExample.getResourceString("FileDialog") ~ Text.DELIMITER);
|
|
173 textWidget.append (Format( ControlExample.getResourceString("Result"), result ) ~ Text.DELIMITER);
|
|
174 if ((dialog.getStyle () & DWT.MULTI) !is 0) {
|
|
175 char[] [] files = dialog.getFileNames ();
|
|
176 for (int i=0; i<files.length; i++) {
|
|
177 textWidget.append ("\t" ~ files [i] ~ Text.DELIMITER);
|
|
178 }
|
|
179 }
|
|
180 textWidget.append (Text.DELIMITER);
|
|
181 return;
|
|
182 }
|
|
183
|
|
184 if (name == ControlExample.getResourceString("FontDialog")) {
|
|
185 FontDialog dialog = new FontDialog (shell, style);
|
|
186 dialog.setText (ControlExample.getResourceString("Title"));
|
|
187 FontData result = dialog.open ();
|
|
188 textWidget.append (ControlExample.getResourceString("FontDialog") ~ Text.DELIMITER);
|
|
189 textWidget.append (Format( ControlExample.getResourceString("Result"), result ) ~ Text.DELIMITER ~ Text.DELIMITER);
|
|
190 return;
|
|
191 }
|
|
192
|
|
193 if (name == ControlExample.getResourceString("PrintDialog")) {
|
|
194 PrintDialog dialog = new PrintDialog (shell, style);
|
|
195 dialog.setText(ControlExample.getResourceString("Title"));
|
|
196 PrinterData result = dialog.open ();
|
|
197 textWidget.append (ControlExample.getResourceString("PrintDialog") ~ Text.DELIMITER);
|
|
198 textWidget.append (Format( ControlExample.getResourceString("Result"), result ) ~ Text.DELIMITER ~ Text.DELIMITER);
|
|
199 return;
|
|
200 }
|
|
201
|
|
202 if (name == ControlExample.getResourceString("MessageBox")) {
|
|
203 MessageBox dialog = new MessageBox (shell, style);
|
|
204 dialog.setMessage (ControlExample.getResourceString("Example_string"));
|
|
205 dialog.setText (ControlExample.getResourceString("Title"));
|
|
206 int result = dialog.open ();
|
|
207 textWidget.append (ControlExample.getResourceString("MessageBox") ~ Text.DELIMITER);
|
|
208 /*
|
|
209 * The resulting integer depends on the original
|
|
210 * dialog style. Decode the result and display it.
|
|
211 */
|
|
212 switch (result) {
|
|
213 case DWT.OK:
|
|
214 textWidget.append (Format( ControlExample.getResourceString("Result"), "DWT.OK"));
|
|
215 break;
|
|
216 case DWT.YES:
|
|
217 textWidget.append (Format( ControlExample.getResourceString("Result"), "DWT.YES"));
|
|
218 break;
|
|
219 case DWT.NO:
|
|
220 textWidget.append (Format( ControlExample.getResourceString("Result"), "DWT.NO"));
|
|
221 break;
|
|
222 case DWT.CANCEL:
|
|
223 textWidget.append (Format( ControlExample.getResourceString("Result"), "DWT.CANCEL"));
|
|
224 break;
|
|
225 case DWT.ABORT:
|
|
226 textWidget.append (Format( ControlExample.getResourceString("Result"), "DWT.ABORT"));
|
|
227 break;
|
|
228 case DWT.RETRY:
|
|
229 textWidget.append (Format( ControlExample.getResourceString("Result"), "DWT.RETRY"));
|
|
230 break;
|
|
231 case DWT.IGNORE:
|
|
232 textWidget.append (Format( ControlExample.getResourceString("Result"), "DWT.IGNORE"));
|
|
233 break;
|
|
234 default:
|
|
235 textWidget.append(Format( ControlExample.getResourceString("Result"), result));
|
|
236 break;
|
|
237 }
|
|
238 textWidget.append (Text.DELIMITER ~ Text.DELIMITER);
|
|
239 }
|
|
240 }
|
|
241
|
|
242 /**
|
|
243 * Creates the "Control" group.
|
|
244 */
|
|
245 void createControlGroup () {
|
|
246 /*
|
|
247 * Create the "Control" group. This is the group on the
|
|
248 * right half of each example tab. It consists of the
|
|
249 * style group, the display group and the size group.
|
|
250 */
|
|
251 controlGroup = new Group (tabFolderPage, DWT.NONE);
|
|
252 GridLayout gridLayout= new GridLayout ();
|
|
253 controlGroup.setLayout(gridLayout);
|
|
254 gridLayout.numColumns = 2;
|
|
255 gridLayout.makeColumnsEqualWidth = true;
|
|
256 controlGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
|
|
257 controlGroup.setText (ControlExample.getResourceString("Parameters"));
|
|
258
|
|
259 /*
|
|
260 * Create a group to hold the dialog style combo box and
|
|
261 * create dialog button.
|
|
262 */
|
|
263 dialogStyleGroup = new Group (controlGroup, DWT.NONE);
|
|
264 dialogStyleGroup.setLayout (new GridLayout ());
|
|
265 GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_CENTER);
|
|
266 gridData.horizontalSpan = 2;
|
|
267 dialogStyleGroup.setLayoutData (gridData);
|
|
268 dialogStyleGroup.setText (ControlExample.getResourceString("Dialog_Type"));
|
|
269 }
|
|
270
|
|
271 /**
|
|
272 * Creates the "Control" widget children.
|
|
273 */
|
|
274 void createControlWidgets () {
|
|
275
|
|
276 /* Create the combo */
|
|
277 char[] [] strings = [
|
|
278 ControlExample.getResourceString("ColorDialog"),
|
|
279 ControlExample.getResourceString("DirectoryDialog"),
|
|
280 ControlExample.getResourceString("FileDialog"),
|
|
281 ControlExample.getResourceString("FontDialog"),
|
|
282 ControlExample.getResourceString("PrintDialog"),
|
|
283 ControlExample.getResourceString("MessageBox"),
|
|
284 ];
|
|
285 dialogCombo = new Combo (dialogStyleGroup, DWT.READ_ONLY);
|
|
286 dialogCombo.setItems (strings);
|
|
287 dialogCombo.setText (strings [0]);
|
|
288 dialogCombo.setVisibleItemCount(strings.length);
|
|
289
|
|
290 /* Create the create dialog button */
|
|
291 createButton = new Button(dialogStyleGroup, DWT.NONE);
|
|
292 createButton.setText (ControlExample.getResourceString("Create_Dialog"));
|
|
293 createButton.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
|
|
294
|
|
295 /* Create a group for the various dialog button style controls */
|
|
296 Group buttonStyleGroup = new Group (controlGroup, DWT.NONE);
|
|
297 buttonStyleGroup.setLayout (new GridLayout ());
|
|
298 buttonStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
|
|
299 buttonStyleGroup.setText (ControlExample.getResourceString("Button_Styles"));
|
|
300
|
|
301 /* Create the button style buttons */
|
|
302 okButton = new Button (buttonStyleGroup, DWT.CHECK);
|
|
303 okButton.setText ("DWT.OK");
|
|
304 cancelButton = new Button (buttonStyleGroup, DWT.CHECK);
|
|
305 cancelButton.setText ("DWT.CANCEL");
|
|
306 yesButton = new Button (buttonStyleGroup, DWT.CHECK);
|
|
307 yesButton.setText ("DWT.YES");
|
|
308 noButton = new Button (buttonStyleGroup, DWT.CHECK);
|
|
309 noButton.setText ("DWT.NO");
|
|
310 retryButton = new Button (buttonStyleGroup, DWT.CHECK);
|
|
311 retryButton.setText ("DWT.RETRY");
|
|
312 abortButton = new Button (buttonStyleGroup, DWT.CHECK);
|
|
313 abortButton.setText ("DWT.ABORT");
|
|
314 ignoreButton = new Button (buttonStyleGroup, DWT.CHECK);
|
|
315 ignoreButton.setText ("DWT.IGNORE");
|
|
316
|
|
317 /* Create a group for the icon style controls */
|
|
318 Group iconStyleGroup = new Group (controlGroup, DWT.NONE);
|
|
319 iconStyleGroup.setLayout (new GridLayout ());
|
|
320 iconStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
|
|
321 iconStyleGroup.setText (ControlExample.getResourceString("Icon_Styles"));
|
|
322
|
|
323 /* Create the icon style buttons */
|
|
324 iconErrorButton = new Button (iconStyleGroup, DWT.RADIO);
|
|
325 iconErrorButton.setText ("DWT.ICON_ERROR");
|
|
326 iconInformationButton = new Button (iconStyleGroup, DWT.RADIO);
|
|
327 iconInformationButton.setText ("DWT.ICON_INFORMATION");
|
|
328 iconQuestionButton = new Button (iconStyleGroup, DWT.RADIO);
|
|
329 iconQuestionButton.setText ("DWT.ICON_QUESTION");
|
|
330 iconWarningButton = new Button (iconStyleGroup, DWT.RADIO);
|
|
331 iconWarningButton.setText ("DWT.ICON_WARNING");
|
|
332 iconWorkingButton = new Button (iconStyleGroup, DWT.RADIO);
|
|
333 iconWorkingButton.setText ("DWT.ICON_WORKING");
|
|
334 noIconButton = new Button (iconStyleGroup, DWT.RADIO);
|
|
335 noIconButton.setText (ControlExample.getResourceString("No_Icon"));
|
|
336
|
|
337 /* Create a group for the modal style controls */
|
|
338 Group modalStyleGroup = new Group (controlGroup, DWT.NONE);
|
|
339 modalStyleGroup.setLayout (new GridLayout ());
|
|
340 modalStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
|
|
341 modalStyleGroup.setText (ControlExample.getResourceString("Modal_Styles"));
|
|
342
|
|
343 /* Create the modal style buttons */
|
|
344 primaryModalButton = new Button (modalStyleGroup, DWT.RADIO);
|
|
345 primaryModalButton.setText ("DWT.PRIMARY_MODAL");
|
|
346 applicationModalButton = new Button (modalStyleGroup, DWT.RADIO);
|
|
347 applicationModalButton.setText ("DWT.APPLICATION_MODAL");
|
|
348 systemModalButton = new Button (modalStyleGroup, DWT.RADIO);
|
|
349 systemModalButton.setText ("DWT.SYSTEM_MODAL");
|
|
350
|
|
351 /* Create a group for the file dialog style controls */
|
|
352 Group fileDialogStyleGroup = new Group (controlGroup, DWT.NONE);
|
|
353 fileDialogStyleGroup.setLayout (new GridLayout ());
|
|
354 fileDialogStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
|
|
355 fileDialogStyleGroup.setText (ControlExample.getResourceString("File_Dialog_Styles"));
|
|
356
|
|
357 /* Create the file dialog style buttons */
|
|
358 openButton = new Button(fileDialogStyleGroup, DWT.RADIO);
|
|
359 openButton.setText("DWT.OPEN");
|
|
360 saveButton = new Button (fileDialogStyleGroup, DWT.RADIO);
|
|
361 saveButton.setText ("DWT.SAVE");
|
|
362 multiButton = new Button(fileDialogStyleGroup, DWT.CHECK);
|
|
363 multiButton.setText("DWT.MULTI");
|
|
364
|
|
365 /* Create the orientation group */
|
|
366 if (RTL_SUPPORT_ENABLE) {
|
|
367 createOrientationGroup();
|
|
368 }
|
|
369
|
|
370 /* Add the listeners */
|
|
371 dialogCombo.addSelectionListener (new class() SelectionAdapter {
|
|
372 public void widgetSelected (SelectionEvent event) {
|
|
373 dialogSelected (event);
|
|
374 }
|
|
375 });
|
|
376 createButton.addSelectionListener (new class() SelectionAdapter {
|
|
377 public void widgetSelected (SelectionEvent event) {
|
|
378 createButtonSelected (event);
|
|
379 }
|
|
380 });
|
|
381 SelectionListener buttonStyleListener = new class() SelectionAdapter {
|
|
382 public void widgetSelected (SelectionEvent event) {
|
|
383 buttonStyleSelected (event);
|
|
384 }
|
|
385 };
|
|
386 okButton.addSelectionListener (buttonStyleListener);
|
|
387 cancelButton.addSelectionListener (buttonStyleListener);
|
|
388 yesButton.addSelectionListener (buttonStyleListener);
|
|
389 noButton.addSelectionListener (buttonStyleListener);
|
|
390 retryButton.addSelectionListener (buttonStyleListener);
|
|
391 abortButton.addSelectionListener (buttonStyleListener);
|
|
392 ignoreButton.addSelectionListener (buttonStyleListener);
|
|
393
|
|
394 /* Set default values for style buttons */
|
|
395 okButton.setEnabled (false);
|
|
396 cancelButton.setEnabled (false);
|
|
397 yesButton.setEnabled (false);
|
|
398 noButton.setEnabled (false);
|
|
399 retryButton.setEnabled (false);
|
|
400 abortButton.setEnabled (false);
|
|
401 ignoreButton.setEnabled (false);
|
|
402 iconErrorButton.setEnabled (false);
|
|
403 iconInformationButton.setEnabled (false);
|
|
404 iconQuestionButton.setEnabled (false);
|
|
405 iconWarningButton.setEnabled (false);
|
|
406 iconWorkingButton.setEnabled (false);
|
|
407 noIconButton.setEnabled (false);
|
|
408 saveButton.setEnabled (false);
|
|
409 openButton.setEnabled (false);
|
|
410 openButton.setSelection (true);
|
|
411 multiButton.setEnabled (false);
|
|
412 noIconButton.setSelection (true);
|
|
413 }
|
|
414
|
|
415 /**
|
|
416 * Creates the "Example" group.
|
|
417 */
|
|
418 void createExampleGroup () {
|
|
419 super.createExampleGroup ();
|
|
420 exampleGroup.setLayoutData (new GridData (DWT.FILL, DWT.FILL, true, true));
|
|
421
|
|
422 /*
|
|
423 * Create a group for the text widget to display
|
|
424 * the results returned by the example dialogs.
|
|
425 */
|
|
426 resultGroup = new Group (exampleGroup, DWT.NONE);
|
|
427 resultGroup.setLayout (new GridLayout ());
|
|
428 resultGroup.setLayoutData (new GridData (DWT.FILL, DWT.FILL, true, true));
|
|
429 resultGroup.setText (ControlExample.getResourceString("Dialog_Result"));
|
|
430 }
|
|
431
|
|
432 /**
|
|
433 * Creates the "Example" widgets.
|
|
434 */
|
|
435 void createExampleWidgets () {
|
|
436 /*
|
|
437 * Create a multi lined, scrolled text widget for output.
|
|
438 */
|
|
439 textWidget = new Text(resultGroup, DWT.H_SCROLL | DWT.V_SCROLL | DWT.BORDER);
|
|
440 GridData gridData = new GridData (GridData.FILL_BOTH);
|
|
441 textWidget.setLayoutData (gridData);
|
|
442 }
|
|
443
|
|
444 /**
|
|
445 * The platform dialogs do not have DWT listeners.
|
|
446 */
|
|
447 void createListenersGroup () {
|
|
448 }
|
|
449
|
|
450 /**
|
|
451 * Handle a dialog type combo selection event.
|
|
452 *
|
|
453 * @param event the selection event
|
|
454 */
|
|
455 void dialogSelected (SelectionEvent event) {
|
|
456
|
|
457 /* Enable/Disable the buttons */
|
|
458 char[] name = dialogCombo.getText ();
|
|
459 bool isMessageBox = ( name == ControlExample.getResourceString("MessageBox"));
|
|
460 bool isFileDialog = ( name == ControlExample.getResourceString("FileDialog"));
|
|
461 okButton.setEnabled (isMessageBox);
|
|
462 cancelButton.setEnabled (isMessageBox);
|
|
463 yesButton.setEnabled (isMessageBox);
|
|
464 noButton.setEnabled (isMessageBox);
|
|
465 retryButton.setEnabled (isMessageBox);
|
|
466 abortButton.setEnabled (isMessageBox);
|
|
467 ignoreButton.setEnabled (isMessageBox);
|
|
468 iconErrorButton.setEnabled (isMessageBox);
|
|
469 iconInformationButton.setEnabled (isMessageBox);
|
|
470 iconQuestionButton.setEnabled (isMessageBox);
|
|
471 iconWarningButton.setEnabled (isMessageBox);
|
|
472 iconWorkingButton.setEnabled (isMessageBox);
|
|
473 noIconButton.setEnabled (isMessageBox);
|
|
474 saveButton.setEnabled (isFileDialog);
|
|
475 openButton.setEnabled (isFileDialog);
|
|
476 multiButton.setEnabled (isFileDialog);
|
|
477
|
|
478 /* Unselect the buttons */
|
|
479 if (!isMessageBox) {
|
|
480 okButton.setSelection (false);
|
|
481 cancelButton.setSelection (false);
|
|
482 yesButton.setSelection (false);
|
|
483 noButton.setSelection (false);
|
|
484 retryButton.setSelection (false);
|
|
485 abortButton.setSelection (false);
|
|
486 ignoreButton.setSelection (false);
|
|
487 }
|
|
488 }
|
|
489
|
|
490 /**
|
|
491 * Gets the "Example" widget children.
|
|
492 */
|
|
493 Widget [] getExampleWidgets () {
|
|
494 return null;
|
|
495 }
|
|
496
|
|
497 /**
|
|
498 * Gets the text for the tab folder item.
|
|
499 */
|
|
500 char[] getTabText () {
|
|
501 return "Dialog";
|
|
502 }
|
|
503
|
|
504 /**
|
|
505 * Recreates the "Example" widgets.
|
|
506 */
|
|
507 void recreateExampleWidgets () {
|
|
508 if (textWidget is null) {
|
|
509 super.recreateExampleWidgets ();
|
|
510 }
|
|
511 }
|
|
512 }
|