|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2013 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2014 IBM Corporation and others. |
| 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 73-84
Link Here
|
| 73 |
private Control body; |
73 |
private Control body; |
| 74 |
|
74 |
|
| 75 |
/** |
75 |
/** |
| 76 |
* Whether this page has the standard Apply and Defaults buttons; |
76 |
* Whether this page has the standard Apply button; <code>true</code> by |
| 77 |
* <code>true</code> by default. |
77 |
* default. |
| 78 |
* |
78 |
* |
| 79 |
* @see #noDefaultAndApplyButton |
79 |
* @see #noDefaultAndApplyButton |
| 80 |
*/ |
80 |
*/ |
| 81 |
private boolean createDefaultAndApplyButton = true; |
81 |
private boolean createApplyButton = true; |
|
|
82 |
|
| 83 |
/** |
| 84 |
* Whether this page has the standard Default button; <code>true</code> by |
| 85 |
* default. |
| 86 |
* |
| 87 |
* @see #noDefaultButton |
| 88 |
*/ |
| 89 |
private boolean createDefaultButton = true; |
| 82 |
|
90 |
|
| 83 |
/** |
91 |
/** |
| 84 |
* Standard Defaults button, or <code>null</code> if none. |
92 |
* Standard Defaults button, or <code>null</code> if none. |
|
Lines 249-260
Link Here
|
| 249 |
buttonBar.setLayoutData(gd); |
257 |
buttonBar.setLayoutData(gd); |
| 250 |
|
258 |
|
| 251 |
contributeButtons(buttonBar); |
259 |
contributeButtons(buttonBar); |
| 252 |
|
260 |
int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); |
| 253 |
if (createDefaultAndApplyButton) { |
261 |
if (createApplyButton && createDefaultButton) { |
| 254 |
layout.numColumns = layout.numColumns + 2; |
262 |
layout.numColumns = layout.numColumns + 2; |
| 255 |
String[] labels = JFaceResources.getStrings(new String[] { |
263 |
String[] labels = JFaceResources.getStrings(new String[] { |
| 256 |
"defaults", "apply" }); //$NON-NLS-2$//$NON-NLS-1$ |
264 |
"defaults", "apply" }); //$NON-NLS-2$//$NON-NLS-1$ |
| 257 |
int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); |
265 |
|
| 258 |
defaultsButton = new Button(buttonBar, SWT.PUSH); |
266 |
defaultsButton = new Button(buttonBar, SWT.PUSH); |
| 259 |
defaultsButton.setText(labels[0]); |
267 |
defaultsButton.setText(labels[0]); |
| 260 |
Dialog.applyDialogFont(defaultsButton); |
268 |
Dialog.applyDialogFont(defaultsButton); |
|
Lines 269-292
Link Here
|
| 269 |
performDefaults(); |
277 |
performDefaults(); |
| 270 |
} |
278 |
} |
| 271 |
}); |
279 |
}); |
| 272 |
|
280 |
createApplyButton(buttonBar, labels[1], widthHint); |
| 273 |
applyButton = new Button(buttonBar, SWT.PUSH); |
281 |
} else if (createApplyButton) { |
| 274 |
applyButton.setText(labels[1]); |
282 |
layout.numColumns = layout.numColumns + 1; |
| 275 |
Dialog.applyDialogFont(applyButton); |
283 |
String label = JFaceResources.getString("apply"); //$NON-NLS-1$ |
| 276 |
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
284 |
createApplyButton(buttonBar, label, widthHint); |
| 277 |
minButtonSize = applyButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, |
285 |
} else { |
| 278 |
true); |
|
|
| 279 |
data.widthHint = Math.max(widthHint, minButtonSize.x); |
| 280 |
applyButton.setLayoutData(data); |
| 281 |
applyButton.addSelectionListener(new SelectionAdapter() { |
| 282 |
@Override |
| 283 |
public void widgetSelected(SelectionEvent e) { |
| 284 |
performApply(); |
| 285 |
} |
| 286 |
}); |
| 287 |
applyButton.setEnabled(isValid()); |
| 288 |
applyDialogFont(buttonBar); |
| 289 |
} else { |
| 290 |
/* Check if there are any other buttons on the button bar. |
286 |
/* Check if there are any other buttons on the button bar. |
| 291 |
* If not, throw away the button bar composite. Otherwise |
287 |
* If not, throw away the button bar composite. Otherwise |
| 292 |
* there is an unusually large button bar. |
288 |
* there is an unusually large button bar. |
|
Lines 297-303
Link Here
|
| 297 |
} |
293 |
} |
| 298 |
} |
294 |
} |
| 299 |
|
295 |
|
| 300 |
|
296 |
private void createApplyButton(Composite buttonBar, String label, int widthHint) { |
|
|
297 |
applyButton = new Button(buttonBar, SWT.PUSH); |
| 298 |
applyButton.setText(label); |
| 299 |
Dialog.applyDialogFont(applyButton); |
| 300 |
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
| 301 |
Point minButtonSize = applyButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); |
| 302 |
data.widthHint = Math.max(widthHint, minButtonSize.x); |
| 303 |
applyButton.setLayoutData(data); |
| 304 |
applyButton.addSelectionListener(new SelectionAdapter() { |
| 305 |
@Override |
| 306 |
public void widgetSelected(SelectionEvent e) { |
| 307 |
performApply(); |
| 308 |
} |
| 309 |
}); |
| 310 |
applyButton.setEnabled(isValid()); |
| 311 |
applyDialogFont(buttonBar); |
| 312 |
} |
| 301 |
|
313 |
|
| 302 |
/** |
314 |
/** |
| 303 |
* Apply the dialog font to the composite and it's children |
315 |
* Apply the dialog font to the composite and it's children |
|
Lines 408-422
Link Here
|
| 408 |
* </p> |
420 |
* </p> |
| 409 |
*/ |
421 |
*/ |
| 410 |
protected void noDefaultAndApplyButton() { |
422 |
protected void noDefaultAndApplyButton() { |
| 411 |
createDefaultAndApplyButton = false; |
423 |
createApplyButton = false; |
|
|
424 |
createDefaultButton = false; |
| 412 |
} |
425 |
} |
| 413 |
|
426 |
|
| 414 |
/** |
427 |
/** |
| 415 |
* The <code>PreferencePage</code> implementation of this |
428 |
* Suppress creation of the standard Default button for this page. |
| 416 |
* <code>IPreferencePage</code> method returns <code>true</code> |
429 |
* <p> |
| 417 |
* if the page is valid. |
430 |
* Subclasses wishing a preference page with this button should call this |
| 418 |
* @see IPreferencePage#okToLeave() |
431 |
* framework method before the page's control has been created. |
| 419 |
*/ |
432 |
* </p> |
|
|
433 |
* |
| 434 |
* @since 3.11 |
| 435 |
*/ |
| 436 |
protected void noDefaultButton() { |
| 437 |
createDefaultButton = false; |
| 438 |
} |
| 439 |
|
| 440 |
/** |
| 441 |
* The <code>PreferencePage</code> implementation of this |
| 442 |
* <code>IPreferencePage</code> method returns <code>true</code> if the page |
| 443 |
* is valid. |
| 444 |
* |
| 445 |
* @see IPreferencePage#okToLeave() |
| 446 |
*/ |
| 420 |
@Override |
447 |
@Override |
| 421 |
public boolean okToLeave() { |
448 |
public boolean okToLeave() { |
| 422 |
return isValid(); |
449 |
return isValid(); |