|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH. |
2 |
* Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 16-23
Link Here
|
| 16 |
import org.eclipse.jface.dialogs.*; |
16 |
import org.eclipse.jface.dialogs.*; |
| 17 |
import org.eclipse.swt.SWT; |
17 |
import org.eclipse.swt.SWT; |
| 18 |
import org.eclipse.swt.custom.CTabFolder; |
18 |
import org.eclipse.swt.custom.CTabFolder; |
| 19 |
import org.eclipse.swt.events.SelectionAdapter; |
19 |
import org.eclipse.swt.events.*; |
| 20 |
import org.eclipse.swt.events.SelectionEvent; |
|
|
| 21 |
import org.eclipse.swt.layout.GridData; |
20 |
import org.eclipse.swt.layout.GridData; |
| 22 |
import org.eclipse.swt.layout.GridLayout; |
21 |
import org.eclipse.swt.layout.GridLayout; |
| 23 |
import org.eclipse.swt.widgets.*; |
22 |
import org.eclipse.swt.widgets.*; |
|
Lines 28-39
Link Here
|
| 28 |
private Label loginDlgResLabel; |
27 |
private Label loginDlgResLabel; |
| 29 |
private Label messageDlgResLabel; |
28 |
private Label messageDlgResLabel; |
| 30 |
private Label errorDlgResLabel; |
29 |
private Label errorDlgResLabel; |
|
|
30 |
private Label messageBoxDlgResLabel; |
| 31 |
|
| 32 |
private Button okButton, cancelButton; |
| 33 |
private Button yesButton, noButton; |
| 34 |
private Button retryButton; |
| 35 |
private Button abortButton, ignoreButton; |
| 36 |
private Button iconErrorButton, iconInformationButton, iconQuestionButton; |
| 37 |
private Button iconWarningButton, iconWorkingButton, noIconButton; |
| 38 |
|
| 39 |
private Button showMessageBoxDlgButton; |
| 31 |
|
40 |
|
| 32 |
public DialogsTab( final CTabFolder topFolder ) { |
41 |
public DialogsTab( final CTabFolder topFolder ) { |
| 33 |
super( topFolder, "Dialogs" ); |
42 |
super( topFolder, "Dialogs" ); |
| 34 |
} |
43 |
} |
| 35 |
|
44 |
|
| 36 |
protected void createStyleControls( final Composite parent ) { |
45 |
protected void createStyleControls( final Composite parent ) { |
|
|
46 |
parent.setLayout( new GridLayout( 1, true ) ); |
| 47 |
|
| 48 |
createMessageBoxStyleControls( parent ); |
| 37 |
} |
49 |
} |
| 38 |
|
50 |
|
| 39 |
protected void createExampleControls( final Composite parent ) { |
51 |
protected void createExampleControls( final Composite parent ) { |
|
Lines 42-78
Link Here
|
| 42 |
group1.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); |
54 |
group1.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); |
| 43 |
group1.setText( "JFace Dialogs" ); |
55 |
group1.setText( "JFace Dialogs" ); |
| 44 |
group1.setLayout( new GridLayout( 3, true ) ); |
56 |
group1.setLayout( new GridLayout( 3, true ) ); |
| 45 |
|
57 |
|
| 46 |
// JFace input dialog |
58 |
// JFace input dialog |
| 47 |
Button showInputDlgButton = new Button( group1, SWT.PUSH ); |
59 |
Button showInputDlgButton = new Button( group1, SWT.PUSH ); |
| 48 |
showInputDlgButton.setText( "Input Dialog" ); |
60 |
showInputDlgButton.setText( "Input Dialog" ); |
| 49 |
showInputDlgButton.addSelectionListener( new SelectionAdapter() { |
61 |
showInputDlgButton.addSelectionListener( new SelectionAdapter() { |
|
|
62 |
|
| 50 |
public void widgetSelected( final SelectionEvent event ) { |
63 |
public void widgetSelected( final SelectionEvent event ) { |
| 51 |
showInputDialog(); |
64 |
showInputDialog(); |
| 52 |
} |
65 |
} |
| 53 |
} ); |
66 |
} ); |
| 54 |
showInputDlgButton.setLayoutData( createGridDataFillBoth() ); |
67 |
showInputDlgButton.setLayoutData( createGridDataFillBoth() ); |
| 55 |
insertSpaceLabels( group1, 2 ); |
68 |
insertSpaceLabels( group1, 2 ); |
| 56 |
|
69 |
|
| 57 |
inputDlgResLabel = new Label( group1, SWT.WRAP ); |
70 |
inputDlgResLabel = new Label( group1, SWT.WRAP ); |
| 58 |
inputDlgResLabel.setText( "Result:" ); |
71 |
inputDlgResLabel.setText( "Result:" ); |
| 59 |
GridData gdInputDlgResLabel = new GridData(); |
72 |
GridData gdInputDlgResLabel = new GridData(); |
| 60 |
gdInputDlgResLabel.horizontalSpan = 3; |
73 |
gdInputDlgResLabel.horizontalSpan = 3; |
| 61 |
inputDlgResLabel.setLayoutData( gdInputDlgResLabel ); |
74 |
inputDlgResLabel.setLayoutData( gdInputDlgResLabel ); |
| 62 |
|
75 |
|
| 63 |
Button showMessageInfoDlgButton = new Button( group1, SWT.PUSH ); |
76 |
Button showMessageInfoDlgButton = new Button( group1, SWT.PUSH ); |
| 64 |
showMessageInfoDlgButton.setLayoutData( createGridDataFillBoth() ); |
77 |
showMessageInfoDlgButton.setLayoutData( createGridDataFillBoth() ); |
| 65 |
showMessageInfoDlgButton.setText( "Info Message" ); |
78 |
showMessageInfoDlgButton.setText( "Info Message" ); |
| 66 |
showMessageInfoDlgButton.addSelectionListener( new SelectionAdapter() { |
79 |
showMessageInfoDlgButton.addSelectionListener( new SelectionAdapter() { |
|
|
80 |
|
| 67 |
public void widgetSelected( final SelectionEvent event ) { |
81 |
public void widgetSelected( final SelectionEvent event ) { |
| 68 |
showMessageDialogInfo(); |
82 |
showMessageDialogInfo(); |
| 69 |
} |
83 |
} |
| 70 |
} ); |
84 |
} ); |
| 71 |
|
85 |
|
| 72 |
Button showMessageWarningDlgButton = new Button( group1, SWT.PUSH ); |
86 |
Button showMessageWarningDlgButton = new Button( group1, SWT.PUSH ); |
| 73 |
showMessageWarningDlgButton.setLayoutData( createGridDataFillBoth() ); |
87 |
showMessageWarningDlgButton.setLayoutData( createGridDataFillBoth() ); |
| 74 |
showMessageWarningDlgButton.setText( "Warning Dialog" ); |
88 |
showMessageWarningDlgButton.setText( "Warning Dialog" ); |
| 75 |
showMessageWarningDlgButton.addSelectionListener( new SelectionAdapter() { |
89 |
showMessageWarningDlgButton.addSelectionListener( new SelectionAdapter() { |
|
|
90 |
|
| 76 |
public void widgetSelected( final SelectionEvent event ) { |
91 |
public void widgetSelected( final SelectionEvent event ) { |
| 77 |
showMessageDialogWarning(); |
92 |
showMessageDialogWarning(); |
| 78 |
} |
93 |
} |
|
Lines 81-118
Link Here
|
| 81 |
showMessageErrorDlgButton.setLayoutData( createGridDataFillBoth() ); |
96 |
showMessageErrorDlgButton.setLayoutData( createGridDataFillBoth() ); |
| 82 |
showMessageErrorDlgButton.setText( "Error Message" ); |
97 |
showMessageErrorDlgButton.setText( "Error Message" ); |
| 83 |
showMessageErrorDlgButton.addSelectionListener( new SelectionAdapter() { |
98 |
showMessageErrorDlgButton.addSelectionListener( new SelectionAdapter() { |
|
|
99 |
|
| 84 |
public void widgetSelected( final SelectionEvent event ) { |
100 |
public void widgetSelected( final SelectionEvent event ) { |
| 85 |
showMessageDialogError(); |
101 |
showMessageDialogError(); |
| 86 |
} |
102 |
} |
| 87 |
} ); |
103 |
} ); |
| 88 |
|
104 |
|
| 89 |
Button showMessageQuestionDlgButton = new Button( group1, SWT.PUSH ); |
105 |
Button showMessageQuestionDlgButton = new Button( group1, SWT.PUSH ); |
| 90 |
showMessageQuestionDlgButton.setLayoutData( createGridDataFillBoth() ); |
106 |
showMessageQuestionDlgButton.setLayoutData( createGridDataFillBoth() ); |
| 91 |
showMessageQuestionDlgButton.setText( "Question Dialog" ); |
107 |
showMessageQuestionDlgButton.setText( "Question Dialog" ); |
| 92 |
showMessageQuestionDlgButton.addSelectionListener( new SelectionAdapter() { |
108 |
showMessageQuestionDlgButton.addSelectionListener( new SelectionAdapter() { |
|
|
109 |
|
| 93 |
public void widgetSelected( final SelectionEvent event ) { |
110 |
public void widgetSelected( final SelectionEvent event ) { |
| 94 |
showMessageDialogQuestion(); |
111 |
showMessageDialogQuestion(); |
| 95 |
} |
112 |
} |
| 96 |
} ); |
113 |
} ); |
| 97 |
|
114 |
|
| 98 |
Button showMessageConfirmDlgButton = new Button( group1, SWT.PUSH ); |
115 |
Button showMessageConfirmDlgButton = new Button( group1, SWT.PUSH ); |
| 99 |
showMessageConfirmDlgButton.setLayoutData( createGridDataFillBoth() ); |
116 |
showMessageConfirmDlgButton.setLayoutData( createGridDataFillBoth() ); |
| 100 |
showMessageConfirmDlgButton.setText( "Confirm Message" ); |
117 |
showMessageConfirmDlgButton.setText( "Confirm Message" ); |
| 101 |
showMessageConfirmDlgButton.addSelectionListener( new SelectionAdapter() { |
118 |
showMessageConfirmDlgButton.addSelectionListener( new SelectionAdapter() { |
|
|
119 |
|
| 102 |
public void widgetSelected( final SelectionEvent event ) { |
120 |
public void widgetSelected( final SelectionEvent event ) { |
| 103 |
showMessageDialogConfirm(); |
121 |
showMessageDialogConfirm(); |
| 104 |
} |
122 |
} |
| 105 |
} ); |
123 |
} ); |
| 106 |
insertSpaceLabels( group1, 1 ); |
124 |
insertSpaceLabels( group1, 1 ); |
| 107 |
|
125 |
|
| 108 |
messageDlgResLabel = new Label( group1, SWT.WRAP ); |
126 |
messageDlgResLabel = new Label( group1, SWT.WRAP ); |
| 109 |
messageDlgResLabel.setText( "Result:" ); |
127 |
messageDlgResLabel.setText( "Result:" ); |
| 110 |
insertSpaceLabels( group1, 2 ); |
128 |
insertSpaceLabels( group1, 2 ); |
| 111 |
|
129 |
|
| 112 |
Button showErrorDlgButton = new Button( group1, SWT.PUSH ); |
130 |
Button showErrorDlgButton = new Button( group1, SWT.PUSH ); |
| 113 |
showErrorDlgButton.setLayoutData( createGridDataFillBoth() ); |
131 |
showErrorDlgButton.setLayoutData( createGridDataFillBoth() ); |
| 114 |
showErrorDlgButton.setText( "Error Dialog" ); |
132 |
showErrorDlgButton.setText( "Error Dialog" ); |
| 115 |
showErrorDlgButton.addSelectionListener( new SelectionAdapter() { |
133 |
showErrorDlgButton.addSelectionListener( new SelectionAdapter() { |
|
|
134 |
|
| 116 |
public void widgetSelected( final SelectionEvent event ) { |
135 |
public void widgetSelected( final SelectionEvent event ) { |
| 117 |
showErrorDialog(); |
136 |
showErrorDialog(); |
| 118 |
} |
137 |
} |
|
Lines 122-129
Link Here
|
| 122 |
errorDlgResLabel = new Label( group1, SWT.WRAP ); |
141 |
errorDlgResLabel = new Label( group1, SWT.WRAP ); |
| 123 |
errorDlgResLabel.setText( "Result:" ); |
142 |
errorDlgResLabel.setText( "Result:" ); |
| 124 |
insertSpaceLabels( group1, 2 ); |
143 |
insertSpaceLabels( group1, 2 ); |
| 125 |
|
144 |
|
| 126 |
|
|
|
| 127 |
Group group2 = new Group( parent, SWT.NONE ); |
145 |
Group group2 = new Group( parent, SWT.NONE ); |
| 128 |
group2.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); |
146 |
group2.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); |
| 129 |
group2.setText( "Custom Dialogs" ); |
147 |
group2.setText( "Custom Dialogs" ); |
|
Lines 132-146
Link Here
|
| 132 |
Button showLoginDlgButton = new Button( group2, SWT.PUSH ); |
150 |
Button showLoginDlgButton = new Button( group2, SWT.PUSH ); |
| 133 |
showLoginDlgButton.setText( "Login Dialog" ); |
151 |
showLoginDlgButton.setText( "Login Dialog" ); |
| 134 |
showLoginDlgButton.addSelectionListener( new SelectionAdapter() { |
152 |
showLoginDlgButton.addSelectionListener( new SelectionAdapter() { |
|
|
153 |
|
| 135 |
public void widgetSelected( final SelectionEvent event ) { |
154 |
public void widgetSelected( final SelectionEvent event ) { |
| 136 |
showLoginDialog(); |
155 |
showLoginDialog(); |
| 137 |
} |
156 |
} |
| 138 |
} ); |
157 |
} ); |
| 139 |
showLoginDlgButton.setLayoutData( createGridDataFillBoth() ); |
158 |
showLoginDlgButton.setLayoutData( createGridDataFillBoth() ); |
| 140 |
insertSpaceLabels( group2, 2 ); |
159 |
insertSpaceLabels( group2, 2 ); |
| 141 |
|
160 |
|
| 142 |
loginDlgResLabel = new Label( group2, SWT.WRAP ); |
161 |
loginDlgResLabel = new Label( group2, SWT.WRAP ); |
| 143 |
loginDlgResLabel.setText( "Result:" ); |
162 |
loginDlgResLabel.setText( "Result:" ); |
|
|
163 |
|
| 164 |
Group group3 = new Group( parent, SWT.NONE ); |
| 165 |
group3.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); |
| 166 |
group3.setText( "SWT Dialogs" ); |
| 167 |
group3.setLayout( new GridLayout( 3, true ) ); |
| 168 |
|
| 169 |
showMessageBoxDlgButton = new Button( group3, SWT.PUSH ); |
| 170 |
showMessageBoxDlgButton.setText( "MessageBox Dialog" ); |
| 171 |
showMessageBoxDlgButton.addSelectionListener( new SelectionAdapter() { |
| 172 |
|
| 173 |
public void widgetSelected( final SelectionEvent event ) { |
| 174 |
showMessageBoxDialog(); |
| 175 |
} |
| 176 |
} ); |
| 177 |
showMessageBoxDlgButton.setLayoutData( createGridDataFillBoth() ); |
| 178 |
insertSpaceLabels( group3, 2 ); |
| 179 |
|
| 180 |
messageBoxDlgResLabel = new Label( group3, SWT.WRAP ); |
| 181 |
messageBoxDlgResLabel.setText( "Result:" ); |
| 144 |
} |
182 |
} |
| 145 |
|
183 |
|
| 146 |
private GridData createGridDataFillBoth() { |
184 |
private GridData createGridDataFillBoth() { |
|
Lines 155-160
Link Here
|
| 155 |
|
193 |
|
| 156 |
private void showInputDialog() { |
194 |
private void showInputDialog() { |
| 157 |
final IInputValidator val = new IInputValidator() { |
195 |
final IInputValidator val = new IInputValidator() { |
|
|
196 |
|
| 158 |
public String isValid( String newText ) { |
197 |
public String isValid( String newText ) { |
| 159 |
String result = null; |
198 |
String result = null; |
| 160 |
if( newText.length() < 5 ) { |
199 |
if( newText.length() < 5 ) { |
|
Lines 199-206
Link Here
|
| 199 |
+ "Your answer will not be recorded or evaluated " |
238 |
+ "Your answer will not be recorded or evaluated " |
| 200 |
+ "nor does this question have any purpose apart from " |
239 |
+ "nor does this question have any purpose apart from " |
| 201 |
+ "filling the empty space in this dialog window."; |
240 |
+ "filling the empty space in this dialog window."; |
| 202 |
boolean result |
241 |
boolean result = MessageDialog.openQuestion( getShell(), title, mesg ); |
| 203 |
= MessageDialog.openQuestion( getShell(), title, mesg ); |
|
|
| 204 |
messageDlgResLabel.setText( "Question closed (" + result + ")" ); |
242 |
messageDlgResLabel.setText( "Question closed (" + result + ")" ); |
| 205 |
messageDlgResLabel.pack(); |
243 |
messageDlgResLabel.pack(); |
| 206 |
} |
244 |
} |
|
Lines 208-215
Link Here
|
| 208 |
private void showMessageDialogConfirm() { |
246 |
private void showMessageDialogConfirm() { |
| 209 |
String title = "Confirmation"; |
247 |
String title = "Confirmation"; |
| 210 |
String mesg = "Nothing will be done. Ok?"; |
248 |
String mesg = "Nothing will be done. Ok?"; |
| 211 |
boolean result |
249 |
boolean result = MessageDialog.openConfirm( getShell(), title, mesg ); |
| 212 |
= MessageDialog.openConfirm( getShell(), title, mesg ); |
|
|
| 213 |
messageDlgResLabel.setText( "Confirm closed (" + result + ")" ); |
250 |
messageDlgResLabel.setText( "Confirm closed (" + result + ")" ); |
| 214 |
messageDlgResLabel.pack(); |
251 |
messageDlgResLabel.pack(); |
| 215 |
} |
252 |
} |
|
Lines 248-261
Link Here
|
| 248 |
int returnCode = loginDialog.open(); |
285 |
int returnCode = loginDialog.open(); |
| 249 |
String username = loginDialog.getUsername(); |
286 |
String username = loginDialog.getUsername(); |
| 250 |
String password = loginDialog.getPassword(); |
287 |
String password = loginDialog.getPassword(); |
| 251 |
String pwd = password == null ? "n/a" : password.length() + " chars."; |
288 |
String pwd = password == null |
| 252 |
loginDlgResLabel.setText( "Login Dialog User: " |
289 |
? "n/a" |
| 253 |
+ username |
290 |
: password.length() + " chars."; |
| 254 |
+ ", Password: " |
291 |
loginDlgResLabel.setText( "Login Dialog User: " |
| 255 |
+ pwd |
292 |
+ username |
| 256 |
+ " (" |
293 |
+ ", Password: " |
| 257 |
+ returnCode |
294 |
+ pwd |
| 258 |
+ ")" ); |
295 |
+ " (" |
|
|
296 |
+ returnCode |
| 297 |
+ ")" ); |
| 259 |
loginDlgResLabel.pack(); |
298 |
loginDlgResLabel.pack(); |
| 260 |
} |
299 |
} |
|
|
300 |
|
| 301 |
private void showMessageBoxDialog() { |
| 302 |
int style = getStyle(); |
| 303 |
if( okButton.getEnabled() && okButton.getSelection() ) { |
| 304 |
style |= SWT.OK; |
| 305 |
} |
| 306 |
if( cancelButton.getEnabled() && cancelButton.getSelection() ) { |
| 307 |
style |= SWT.CANCEL; |
| 308 |
} |
| 309 |
if( yesButton.getEnabled() && yesButton.getSelection() ) { |
| 310 |
style |= SWT.YES; |
| 311 |
} |
| 312 |
if( noButton.getEnabled() && noButton.getSelection() ) { |
| 313 |
style |= SWT.NO; |
| 314 |
} |
| 315 |
if( retryButton.getEnabled() && retryButton.getSelection() ) { |
| 316 |
style |= SWT.RETRY; |
| 317 |
} |
| 318 |
if( abortButton.getEnabled() && abortButton.getSelection() ) { |
| 319 |
style |= SWT.ABORT; |
| 320 |
} |
| 321 |
if( ignoreButton.getEnabled() && ignoreButton.getSelection() ) { |
| 322 |
style |= SWT.IGNORE; |
| 323 |
} |
| 324 |
if( iconErrorButton.getEnabled() && iconErrorButton.getSelection() ) { |
| 325 |
style |= SWT.ICON_ERROR; |
| 326 |
} |
| 327 |
if( iconInformationButton.getEnabled() |
| 328 |
&& iconInformationButton.getSelection() ) { |
| 329 |
style |= SWT.ICON_INFORMATION; |
| 330 |
} |
| 331 |
if( iconQuestionButton.getEnabled() && iconQuestionButton.getSelection() ) { |
| 332 |
style |= SWT.ICON_QUESTION; |
| 333 |
} |
| 334 |
if( iconWarningButton.getEnabled() && iconWarningButton.getSelection() ) { |
| 335 |
style |= SWT.ICON_WARNING; |
| 336 |
} |
| 337 |
if( iconWorkingButton.getEnabled() && iconWorkingButton.getSelection() ) { |
| 338 |
style |= SWT.ICON_WORKING; |
| 339 |
} |
| 340 |
|
| 341 |
String title = "MessageBox Title"; |
| 342 |
String mesg = "Lorem ipsum dolor sit amet consectetuer adipiscing elit."; |
| 343 |
MessageBox mb = new MessageBox( getShell(), style ); |
| 344 |
mb.setText( title ); |
| 345 |
mb.setMessage( mesg ); |
| 346 |
int result = mb.open(); |
| 347 |
String strResult = ""; |
| 348 |
switch( result ) { |
| 349 |
case SWT.OK: |
| 350 |
strResult = "SWT.OK"; |
| 351 |
break; |
| 352 |
case SWT.YES: |
| 353 |
strResult = "SWT.YES"; |
| 354 |
break; |
| 355 |
case SWT.NO: |
| 356 |
strResult = "SWT.NO"; |
| 357 |
break; |
| 358 |
case SWT.CANCEL: |
| 359 |
strResult = "SWT.CANCEL"; |
| 360 |
break; |
| 361 |
case SWT.ABORT: |
| 362 |
strResult = "SWT.ABORT"; |
| 363 |
break; |
| 364 |
case SWT.RETRY: |
| 365 |
strResult = "SWT.RETRY"; |
| 366 |
break; |
| 367 |
case SWT.IGNORE: |
| 368 |
strResult = "SWT.IGNORE"; |
| 369 |
break; |
| 370 |
default: |
| 371 |
strResult = "" + result; |
| 372 |
break; |
| 373 |
} |
| 374 |
messageBoxDlgResLabel.setText( "Result: " + strResult ); |
| 375 |
messageBoxDlgResLabel.pack(); |
| 376 |
} |
| 377 |
|
| 378 |
private void createMessageBoxStyleControls( final Composite parent ) { |
| 379 |
Group buttonStyleGroup = new Group( parent, SWT.NONE ); |
| 380 |
buttonStyleGroup.setLayout( new GridLayout() ); |
| 381 |
buttonStyleGroup.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_FILL |
| 382 |
| GridData.VERTICAL_ALIGN_FILL ) ); |
| 383 |
buttonStyleGroup.setText( "SWT MessageBox Styles" ); |
| 384 |
|
| 385 |
okButton = new Button( buttonStyleGroup, SWT.CHECK ); |
| 386 |
okButton.setText( "SWT.OK" ); |
| 387 |
cancelButton = new Button( buttonStyleGroup, SWT.CHECK ); |
| 388 |
cancelButton.setText( "SWT.CANCEL" ); |
| 389 |
yesButton = new Button( buttonStyleGroup, SWT.CHECK ); |
| 390 |
yesButton.setText( "SWT.YES" ); |
| 391 |
noButton = new Button( buttonStyleGroup, SWT.CHECK ); |
| 392 |
noButton.setText( "SWT.NO" ); |
| 393 |
retryButton = new Button( buttonStyleGroup, SWT.CHECK ); |
| 394 |
retryButton.setText( "SWT.RETRY" ); |
| 395 |
abortButton = new Button( buttonStyleGroup, SWT.CHECK ); |
| 396 |
abortButton.setText( "SWT.ABORT" ); |
| 397 |
ignoreButton = new Button( buttonStyleGroup, SWT.CHECK ); |
| 398 |
ignoreButton.setText( "SWT.IGNORE" ); |
| 399 |
|
| 400 |
Group iconStyleGroup = new Group( parent, SWT.NONE ); |
| 401 |
iconStyleGroup.setLayout( new GridLayout() ); |
| 402 |
iconStyleGroup.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_FILL |
| 403 |
| GridData.VERTICAL_ALIGN_FILL ) ); |
| 404 |
iconStyleGroup.setText( "SWT MessageBox Icon Styles" ); |
| 405 |
|
| 406 |
iconErrorButton = new Button( iconStyleGroup, SWT.RADIO ); |
| 407 |
iconErrorButton.setText( "SWT.ICON_ERROR" ); |
| 408 |
iconInformationButton = new Button( iconStyleGroup, SWT.RADIO ); |
| 409 |
iconInformationButton.setText( "SWT.ICON_INFORMATION" ); |
| 410 |
iconQuestionButton = new Button( iconStyleGroup, SWT.RADIO ); |
| 411 |
iconQuestionButton.setText( "SWT.ICON_QUESTION" ); |
| 412 |
iconWarningButton = new Button( iconStyleGroup, SWT.RADIO ); |
| 413 |
iconWarningButton.setText( "SWT.ICON_WARNING" ); |
| 414 |
iconWorkingButton = new Button( iconStyleGroup, SWT.RADIO ); |
| 415 |
iconWorkingButton.setText( "SWT.ICON_WORKING" ); |
| 416 |
noIconButton = new Button( iconStyleGroup, SWT.RADIO ); |
| 417 |
noIconButton.setText( "No Icon" ); |
| 418 |
|
| 419 |
SelectionListener buttonStyleListener = new SelectionAdapter() { |
| 420 |
|
| 421 |
public void widgetSelected( SelectionEvent event ) { |
| 422 |
buttonStyleSelected( event ); |
| 423 |
} |
| 424 |
}; |
| 425 |
|
| 426 |
okButton.addSelectionListener( buttonStyleListener ); |
| 427 |
cancelButton.addSelectionListener( buttonStyleListener ); |
| 428 |
yesButton.addSelectionListener( buttonStyleListener ); |
| 429 |
noButton.addSelectionListener( buttonStyleListener ); |
| 430 |
retryButton.addSelectionListener( buttonStyleListener ); |
| 431 |
abortButton.addSelectionListener( buttonStyleListener ); |
| 432 |
ignoreButton.addSelectionListener( buttonStyleListener ); |
| 433 |
|
| 434 |
noIconButton.setSelection( true ); |
| 435 |
} |
| 436 |
|
| 437 |
private void buttonStyleSelected( SelectionEvent event ) { |
| 438 |
boolean ok = okButton.getSelection(); |
| 439 |
boolean cancel = cancelButton.getSelection(); |
| 440 |
boolean yes = yesButton.getSelection(); |
| 441 |
boolean no = noButton.getSelection(); |
| 442 |
boolean abort = abortButton.getSelection(); |
| 443 |
boolean retry = retryButton.getSelection(); |
| 444 |
boolean ignore = ignoreButton.getSelection(); |
| 445 |
|
| 446 |
okButton.setEnabled( !( yes || no || retry || abort || ignore ) ); |
| 447 |
cancelButton.setEnabled( !( abort || ignore || ( yes != no ) ) ); |
| 448 |
yesButton.setEnabled( !( ok || retry || abort || ignore || ( cancel && !yes && !no ) ) ); |
| 449 |
noButton.setEnabled( !( ok || retry || abort || ignore || ( cancel && !yes && !no ) ) ); |
| 450 |
retryButton.setEnabled( !( ok || yes || no ) ); |
| 451 |
abortButton.setEnabled( !( ok || cancel || yes || no ) ); |
| 452 |
ignoreButton.setEnabled( !( ok || cancel || yes || no ) ); |
| 453 |
|
| 454 |
showMessageBoxDlgButton.setEnabled( !( ok |
| 455 |
|| cancel |
| 456 |
|| yes |
| 457 |
|| no |
| 458 |
|| retry |
| 459 |
|| abort || ignore ) |
| 460 |
|| ok |
| 461 |
|| ( ok && cancel ) |
| 462 |
|| ( yes && no ) |
| 463 |
|| ( yes && no && cancel ) |
| 464 |
|| ( retry && cancel ) |
| 465 |
|| ( abort && retry && ignore ) ); |
| 466 |
|
| 467 |
} |
| 261 |
} |
468 |
} |