|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2001, 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 |
*******************************************************************************/ |
| 11 |
package org.eclipse.pde.internal.ds.ui.parts; |
| 12 |
|
| 13 |
import java.text.MessageFormat; |
| 14 |
import java.util.ArrayList; |
| 15 |
import java.util.Iterator; |
| 16 |
import java.util.List; |
| 17 |
|
| 18 |
import org.eclipse.jface.dialogs.IDialogConstants; |
| 19 |
import org.eclipse.swt.SWT; |
| 20 |
import org.eclipse.swt.graphics.Image; |
| 21 |
import org.eclipse.swt.layout.GridData; |
| 22 |
import org.eclipse.swt.layout.GridLayout; |
| 23 |
import org.eclipse.swt.layout.RowLayout; |
| 24 |
import org.eclipse.swt.widgets.Button; |
| 25 |
import org.eclipse.swt.widgets.Composite; |
| 26 |
import org.eclipse.swt.widgets.Group; |
| 27 |
import org.eclipse.swt.widgets.Label; |
| 28 |
import org.eclipse.swt.widgets.Shell; |
| 29 |
|
| 30 |
/** |
| 31 |
* A handy Yes/No/Cancel dialog. |
| 32 |
*/ |
| 33 |
public class HandyPromptDialog extends HandyDialog implements IHandyPromptDialog { |
| 34 |
// |
| 35 |
// Nested Classes |
| 36 |
// |
| 37 |
|
| 38 |
private static class ButtonDetails extends Object { |
| 39 |
private Button button; |
| 40 |
private boolean selected; |
| 41 |
private String text; |
| 42 |
} |
| 43 |
|
| 44 |
// Static Fields |
| 45 |
// |
| 46 |
|
| 47 |
// Externalized Strings |
| 48 |
private static final String PROMPT_KEY = "HandyPromptDialog.Prompt"; //$NON-NLS-1$ |
| 49 |
private static final String UNKNOWN_BUTTON_ID_KEY = "HandyPromptDialog.UnknownButtonId"; //$NON-NLS-1$ |
| 50 |
|
| 51 |
// Misc |
| 52 |
private static final int NO_DEFAULT_BUTTON_ID = -1; |
| 53 |
|
| 54 |
// |
| 55 |
// Instance Fields |
| 56 |
// |
| 57 |
|
| 58 |
private String cancelButtonText; |
| 59 |
private List/*<ButtonDetails>*/ checkboxButtons; |
| 60 |
private String checkboxGroupText; |
| 61 |
private int defaultButtonId; |
| 62 |
private Image image; |
| 63 |
private String noButtonText; |
| 64 |
private String prompt; |
| 65 |
private List/*<ButtonDetails>*/ radioButtons; |
| 66 |
private String radioButtonGroupText; |
| 67 |
private String yesButtonText; |
| 68 |
|
| 69 |
// |
| 70 |
// Constructors |
| 71 |
// |
| 72 |
|
| 73 |
public HandyPromptDialog(Shell parentShell, String prompt) { |
| 74 |
super(parentShell); |
| 75 |
setTitle(Messages.getString(HandyPromptDialog.PROMPT_KEY)); |
| 76 |
setPrompt(prompt); |
| 77 |
initializeCheckboxButtons(); |
| 78 |
initializeRadioButtons(); |
| 79 |
initializePushButtons(); |
| 80 |
setDefaultButtonId(HandyPromptDialog.NO_DEFAULT_BUTTON_ID); |
| 81 |
} |
| 82 |
|
| 83 |
// |
| 84 |
// Instance Methods |
| 85 |
// |
| 86 |
|
| 87 |
private int addButton(List/*<ButtonDetails>*/ list, String text, boolean selected) { |
| 88 |
synchronized (list) { |
| 89 |
int size = list.size(); |
| 90 |
ButtonDetails details = new ButtonDetails(); |
| 91 |
details.text = text; |
| 92 |
details.selected = selected; |
| 93 |
list.add(details); |
| 94 |
return size; |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#addCheckbox(java.lang.String, boolean) |
| 100 |
*/ |
| 101 |
public int addCheckbox(String text, boolean selected) { |
| 102 |
List/*<ButtonDetails>*/ list = getCheckboxButtons(); |
| 103 |
int id = addButton(list, text, selected); |
| 104 |
return id; |
| 105 |
} |
| 106 |
|
| 107 |
/** |
| 108 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#addRadioButton(java.lang.String, boolean) |
| 109 |
*/ |
| 110 |
public int addRadioButton(String text, boolean selected) { |
| 111 |
List/*<ButtonDetails>*/ list = getRadioButtons(); |
| 112 |
int id = addButton(list, text, selected); |
| 113 |
return id; |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) |
| 118 |
*/ |
| 119 |
protected void buttonPressed(int buttonId) { |
| 120 |
if (IHandyDialog.HELP_ID == buttonId) { |
| 121 |
helpPressed(); |
| 122 |
} else { |
| 123 |
try { |
| 124 |
updateButtonSelections(); |
| 125 |
setReturnCode(buttonId); |
| 126 |
} finally { |
| 127 |
close(); |
| 128 |
} |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
private void checkButtonId(List/*<ButtonDetails>*/ list, int id) { |
| 133 |
int size = list.size(); |
| 134 |
if (id < size) |
| 135 |
return; // Early return. |
| 136 |
|
| 137 |
String pattern = Messages.getString(HandyPromptDialog.UNKNOWN_BUTTON_ID_KEY); |
| 138 |
Object[] values = new Object[] { |
| 139 |
new Integer(id) |
| 140 |
}; |
| 141 |
String message = MessageFormat.format(pattern, values); |
| 142 |
throw new IllegalArgumentException(message); |
| 143 |
} |
| 144 |
|
| 145 |
/** |
| 146 |
* @see org.eclipse.soda.sat.plugin.ui.internal.HandyDialog#createArea(org.eclipse.swt.widgets.Composite) |
| 147 |
*/ |
| 148 |
protected void createArea(Composite composite) { |
| 149 |
createPromptControls(composite); |
| 150 |
} |
| 151 |
|
| 152 |
private Button createButton(Composite parent, int id, String label) { |
| 153 |
int defaultButtonId = getDefaultButtonId(); |
| 154 |
boolean defaultButton = defaultButtonId == id; |
| 155 |
Button button = createButton(parent, id, label, defaultButton); |
| 156 |
return button; |
| 157 |
} |
| 158 |
|
| 159 |
/** |
| 160 |
* @see org.eclipse.jface.dialogs.Dialog#createButton(org.eclipse.swt.widgets.Composite, int, java.lang.String, boolean) |
| 161 |
*/ |
| 162 |
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { |
| 163 |
Button button = super.createButton(parent, id, label, defaultButton); |
| 164 |
|
| 165 |
// Force the default button to take focus. This fixes an apparent |
| 166 |
// bug in SWT where the default button does not always take focus. |
| 167 |
// Strangely enough, the default button seems to take focus when the |
| 168 |
// HandyPromptDialog has at least one radio button or checkbox. |
| 169 |
|
| 170 |
if (defaultButton == true) { |
| 171 |
button.setFocus(); |
| 172 |
} |
| 173 |
|
| 174 |
return button; |
| 175 |
} |
| 176 |
|
| 177 |
private void createButtons(List/* <ButtonDetails> */list, |
| 178 |
Composite parent, boolean grabExcessSpace, String groupText, |
| 179 |
int style) { |
| 180 |
synchronized (list) { |
| 181 |
boolean empty = list.isEmpty(); |
| 182 |
if (empty == true) |
| 183 |
return; // Early return. |
| 184 |
|
| 185 |
Composite composite; |
| 186 |
RowLayout layout = new RowLayout(SWT.VERTICAL); |
| 187 |
|
| 188 |
if (groupText == null) { |
| 189 |
composite = new Composite(parent, SWT.NONE); |
| 190 |
layout.marginLeft = 0; |
| 191 |
layout.marginRight = 0; |
| 192 |
layout.marginTop = 0; |
| 193 |
layout.marginBottom = 0; |
| 194 |
} else { |
| 195 |
Group group = new Group(parent, SWT.NONE); |
| 196 |
group.setText(groupText); |
| 197 |
composite = group; |
| 198 |
} |
| 199 |
|
| 200 |
composite.setLayout(layout); |
| 201 |
|
| 202 |
int alignment = grabExcessSpace == true ? SWT.FILL : SWT.BEGINNING; |
| 203 |
Object data = new GridData(alignment, alignment, grabExcessSpace, grabExcessSpace); |
| 204 |
composite.setLayoutData(data); |
| 205 |
|
| 206 |
Iterator/*<ButtonDetails>*/ iterator = list.iterator(); |
| 207 |
while (iterator.hasNext() == true) { |
| 208 |
ButtonDetails details = (ButtonDetails) iterator.next(); |
| 209 |
Button button = new Button(composite, style); |
| 210 |
button.setText(details.text); |
| 211 |
button.setSelection(details.selected); |
| 212 |
details.button = button; |
| 213 |
} |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
/** |
| 218 |
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) |
| 219 |
*/ |
| 220 |
protected void createButtonsForButtonBar(Composite parent) { |
| 221 |
createYesButtonForButtonBar(parent); |
| 222 |
createNoButtonForButtonBar(parent); |
| 223 |
// createCancelButtonForButtonBar(parent); |
| 224 |
createHelpButtonForButtonBar(parent); |
| 225 |
} |
| 226 |
|
| 227 |
private Button createCancelButtonForButtonBar(Composite parent) { |
| 228 |
String label = getCancelButtonText(); |
| 229 |
if (label == null) |
| 230 |
return null; // Early return. |
| 231 |
int id = IHandyDialog.CANCEL_ID; |
| 232 |
Button button = createButton(parent, id, label); |
| 233 |
return button; |
| 234 |
} |
| 235 |
|
| 236 |
private Button createNoButtonForButtonBar(Composite parent) { |
| 237 |
String label = getNoButtonText(); |
| 238 |
if (label == null) |
| 239 |
return null; // Early return. |
| 240 |
int id = IHandyDialog.NO_ID; |
| 241 |
Button button = createButton(parent, id, label); |
| 242 |
return button; |
| 243 |
} |
| 244 |
|
| 245 |
private void createPromptButtonControls(Composite parent) { |
| 246 |
int columns = 0; |
| 247 |
|
| 248 |
List/*<ButtonDetails>*/ checkboxButtons = getCheckboxButtons(); |
| 249 |
boolean hasCheckboxButtons = checkboxButtons.isEmpty() == false; |
| 250 |
|
| 251 |
if (hasCheckboxButtons == true) { |
| 252 |
columns++; |
| 253 |
} |
| 254 |
|
| 255 |
List/*<ButtonDetails>*/ radioButtons = getRadioButtons(); |
| 256 |
boolean hasRadioButtons = radioButtons.isEmpty() == false; |
| 257 |
|
| 258 |
if (hasRadioButtons == true) { |
| 259 |
columns++; |
| 260 |
} |
| 261 |
|
| 262 |
if (columns == 0) |
| 263 |
return; // Early return. |
| 264 |
|
| 265 |
Composite composite = createPromptButtonControlsComposite(parent, columns); |
| 266 |
|
| 267 |
if (hasCheckboxButtons == true) { |
| 268 |
String groupText = getCheckboxGroupText(); |
| 269 |
createButtons(checkboxButtons, composite, hasRadioButtons, groupText, SWT.CHECK); |
| 270 |
} |
| 271 |
|
| 272 |
if (hasRadioButtons == true) { |
| 273 |
String groupText = getRadioButtonGroupText(); |
| 274 |
createButtons(radioButtons, composite, hasCheckboxButtons, groupText, SWT.RADIO); |
| 275 |
} |
| 276 |
} |
| 277 |
|
| 278 |
private Composite createPromptButtonControlsComposite(Composite parent, int columns) { |
| 279 |
GridLayout layout = new GridLayout(columns, false); |
| 280 |
layout.marginWidth = 0; |
| 281 |
layout.marginHeight = 0; |
| 282 |
layout.marginTop = 20; |
| 283 |
layout.marginHeight = 0; |
| 284 |
|
| 285 |
if (columns > 1) { |
| 286 |
layout.horizontalSpacing = 10; |
| 287 |
} |
| 288 |
|
| 289 |
Composite composite = new Composite(parent, SWT.NONE); |
| 290 |
composite.setLayout(layout); |
| 291 |
|
| 292 |
Object data = new GridData(SWT.FILL, SWT.FILL, true, false); |
| 293 |
composite.setLayoutData(data); |
| 294 |
|
| 295 |
return composite; |
| 296 |
} |
| 297 |
|
| 298 |
private void createPromptControls(Composite parent) { |
| 299 |
createPromptLabelControls(parent); |
| 300 |
createPromptButtonControls(parent); |
| 301 |
} |
| 302 |
|
| 303 |
private void createPromptLabelControls(Composite parent) { |
| 304 |
GridData data; |
| 305 |
|
| 306 |
Composite composite = new Composite(parent, SWT.NONE); |
| 307 |
GridLayout layout = new GridLayout(2, false); |
| 308 |
layout.marginWidth = 0; |
| 309 |
layout.marginHeight = 0; |
| 310 |
composite.setLayout(layout); |
| 311 |
data = new GridData(SWT.FILL, SWT.FILL, true, true); |
| 312 |
composite.setLayoutData(data); |
| 313 |
|
| 314 |
Label icon = new Label(composite, SWT.LEFT | SWT.NONE); |
| 315 |
Image image = getImage(); |
| 316 |
icon.setImage(image); |
| 317 |
|
| 318 |
Label label = new Label(composite, SWT.WRAP); |
| 319 |
String prompt = getPrompt(); |
| 320 |
label.setText(prompt); |
| 321 |
data = new GridData(SWT.FILL, SWT.CENTER, true, true); |
| 322 |
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); |
| 323 |
label.setLayoutData(data); |
| 324 |
} |
| 325 |
|
| 326 |
private Button createYesButtonForButtonBar(Composite parent) { |
| 327 |
String label = getYesButtonText(); |
| 328 |
if (label == null) |
| 329 |
return null; // Early return. |
| 330 |
int id = IHandyDialog.YES_ID; |
| 331 |
Button button = createButton(parent, id, label); |
| 332 |
return button; |
| 333 |
} |
| 334 |
|
| 335 |
/** |
| 336 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#defaultButtonIsCancel() |
| 337 |
*/ |
| 338 |
public void defaultButtonIsCancel() { |
| 339 |
setDefaultButtonId(IHandyDialog.CANCEL_ID); |
| 340 |
} |
| 341 |
|
| 342 |
/** |
| 343 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#defaultButtonIsNo() |
| 344 |
*/ |
| 345 |
public void defaultButtonIsNo() { |
| 346 |
setDefaultButtonId(IHandyDialog.NO_ID); |
| 347 |
} |
| 348 |
|
| 349 |
/** |
| 350 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#defaultButtonIsYes() |
| 351 |
*/ |
| 352 |
public void defaultButtonIsYes() { |
| 353 |
setDefaultButtonId(IHandyDialog.YES_ID); |
| 354 |
} |
| 355 |
|
| 356 |
private ButtonDetails getButtonDetails(List/*<ButtonDetails>*/ list, int id) { |
| 357 |
checkButtonId(list, id); |
| 358 |
ButtonDetails details = (ButtonDetails) list.get(id); |
| 359 |
return details; |
| 360 |
} |
| 361 |
|
| 362 |
private String getCancelButtonText() { |
| 363 |
return cancelButtonText; |
| 364 |
} |
| 365 |
|
| 366 |
private ButtonDetails getCheckboxButtonDetails(int id) { |
| 367 |
List/*<ButtonDetails>*/ list = getCheckboxButtons(); |
| 368 |
ButtonDetails details = getButtonDetails(list, id); |
| 369 |
return details; |
| 370 |
} |
| 371 |
|
| 372 |
private List/*<ButtonDetails>*/ getCheckboxButtons() { |
| 373 |
return checkboxButtons; |
| 374 |
} |
| 375 |
|
| 376 |
private String getCheckboxGroupText() { |
| 377 |
return checkboxGroupText; |
| 378 |
} |
| 379 |
|
| 380 |
private int getDefaultButtonId() { |
| 381 |
synchronized (this) { |
| 382 |
if (defaultButtonId == -1) { |
| 383 |
int id = guessDefaultButtonId(); |
| 384 |
setDefaultButtonId(id); |
| 385 |
} |
| 386 |
} |
| 387 |
|
| 388 |
return defaultButtonId; |
| 389 |
} |
| 390 |
|
| 391 |
private Image getImage() { |
| 392 |
synchronized (this) { |
| 393 |
if (image == null) { |
| 394 |
useInformationIcon(); |
| 395 |
} |
| 396 |
} |
| 397 |
return image; |
| 398 |
} |
| 399 |
|
| 400 |
private String getNoButtonText() { |
| 401 |
return noButtonText; |
| 402 |
} |
| 403 |
|
| 404 |
private String getPrompt() { |
| 405 |
return prompt; |
| 406 |
} |
| 407 |
|
| 408 |
private ButtonDetails getRadioButtonDetails(int id) { |
| 409 |
List/*<ButtonDetails>*/ list = getRadioButtons(); |
| 410 |
ButtonDetails details = getButtonDetails(list, id); |
| 411 |
return details; |
| 412 |
} |
| 413 |
|
| 414 |
private String getRadioButtonGroupText() { |
| 415 |
return radioButtonGroupText; |
| 416 |
} |
| 417 |
|
| 418 |
private List/*<ButtonDetails>*/ getRadioButtons() { |
| 419 |
return radioButtons; |
| 420 |
} |
| 421 |
|
| 422 |
/** |
| 423 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#getSelectedRadioButtonId() |
| 424 |
*/ |
| 425 |
public int getSelectedRadioButtonId() { |
| 426 |
List/*<ButtonDetails>*/ list = getRadioButtons(); |
| 427 |
int size = list.size(); |
| 428 |
|
| 429 |
for (int id = 0; id < size; id++) { |
| 430 |
ButtonDetails details = (ButtonDetails) list.get(id); |
| 431 |
if (details.selected == true) |
| 432 |
return id; // Early return. |
| 433 |
} |
| 434 |
|
| 435 |
return -1; |
| 436 |
} |
| 437 |
|
| 438 |
private String getYesButtonText() { |
| 439 |
return yesButtonText; |
| 440 |
} |
| 441 |
|
| 442 |
private int guessDefaultButtonId() { |
| 443 |
Object text; |
| 444 |
|
| 445 |
text = getCancelButtonText(); |
| 446 |
if (text != null) return IHandyDialog.CANCEL_ID; |
| 447 |
|
| 448 |
text = getNoButtonText(); |
| 449 |
if (text != null) return IHandyDialog.NO_ID; |
| 450 |
|
| 451 |
text = getYesButtonText(); |
| 452 |
if (text != null) return IHandyDialog.YES_ID; |
| 453 |
|
| 454 |
boolean helpButtonRequired = isHelpButtonRequired(); |
| 455 |
if (helpButtonRequired == true) return IHandyDialog.HELP_ID; |
| 456 |
|
| 457 |
return HandyPromptDialog.NO_DEFAULT_BUTTON_ID; |
| 458 |
} |
| 459 |
|
| 460 |
private void initializeCheckboxButtons() { |
| 461 |
setCheckboxButtons(new ArrayList/*<ButtonDetails>*/(3)); |
| 462 |
} |
| 463 |
|
| 464 |
private void initializePushButtons() { |
| 465 |
setYesButtonText(IDialogConstants.YES_LABEL); |
| 466 |
setNoButtonText(IDialogConstants.NO_LABEL); |
| 467 |
setCancelButtonText('&' + IDialogConstants.CANCEL_LABEL); |
| 468 |
} |
| 469 |
|
| 470 |
private void initializeRadioButtons() { |
| 471 |
setRadioButtons(new ArrayList/*<ButtonDetails>*/(3)); |
| 472 |
} |
| 473 |
|
| 474 |
/** |
| 475 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#isCheckboxSelected(int) |
| 476 |
*/ |
| 477 |
public boolean isCheckboxSelected(int id) { |
| 478 |
ButtonDetails details = getCheckboxButtonDetails(id); |
| 479 |
return details.selected; |
| 480 |
} |
| 481 |
|
| 482 |
/** |
| 483 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#removeAllCheckboxes() |
| 484 |
*/ |
| 485 |
public void removeAllCheckboxes() { |
| 486 |
initializeCheckboxButtons(); |
| 487 |
} |
| 488 |
|
| 489 |
/** |
| 490 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#removeAllRadioButtons() |
| 491 |
*/ |
| 492 |
public void removeAllRadioButtons() { |
| 493 |
initializeRadioButtons(); |
| 494 |
} |
| 495 |
|
| 496 |
/** |
| 497 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#setCancelButtonText(java.lang.String) |
| 498 |
*/ |
| 499 |
public void setCancelButtonText(String cancelButtonText) { |
| 500 |
this.cancelButtonText = cancelButtonText; |
| 501 |
} |
| 502 |
|
| 503 |
private void setCheckboxButtons(List/*<ButtonDetails>*/ checkboxButtons) { |
| 504 |
this.checkboxButtons = checkboxButtons; |
| 505 |
} |
| 506 |
|
| 507 |
/** |
| 508 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#setCheckboxGroupText(java.lang.String) |
| 509 |
*/ |
| 510 |
public void setCheckboxGroupText(String checkboxGroupText) { |
| 511 |
this.checkboxGroupText = checkboxGroupText; |
| 512 |
} |
| 513 |
|
| 514 |
/** |
| 515 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#setCheckboxSelected(int, boolean) |
| 516 |
*/ |
| 517 |
public void setCheckboxSelected(int id, boolean selected) { |
| 518 |
ButtonDetails details = getCheckboxButtonDetails(id); |
| 519 |
details.selected = selected; |
| 520 |
} |
| 521 |
|
| 522 |
private void setDefaultButtonId(int defaultButtonId) { |
| 523 |
this.defaultButtonId = defaultButtonId; |
| 524 |
} |
| 525 |
|
| 526 |
/** |
| 527 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#setImage(org.eclipse.swt.graphics.Image) |
| 528 |
*/ |
| 529 |
public void setImage(Image image) { |
| 530 |
this.image = image; |
| 531 |
} |
| 532 |
|
| 533 |
private void setImage(int id) { |
| 534 |
Image image = getSystemImage(id); |
| 535 |
setImage(image); |
| 536 |
} |
| 537 |
|
| 538 |
/** |
| 539 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#setNoButtonText(java.lang.String) |
| 540 |
*/ |
| 541 |
public void setNoButtonText(String noButtonText) { |
| 542 |
this.noButtonText = noButtonText; |
| 543 |
} |
| 544 |
|
| 545 |
private void setPrompt(String prompt) { |
| 546 |
this.prompt = prompt; |
| 547 |
} |
| 548 |
|
| 549 |
/** |
| 550 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#setRadioButtonGroupText(java.lang.String) |
| 551 |
*/ |
| 552 |
public void setRadioButtonGroupText(String radioButtonGroupText) { |
| 553 |
this.radioButtonGroupText = radioButtonGroupText; |
| 554 |
} |
| 555 |
|
| 556 |
private void setRadioButtons(List/*<ButtonDetails>*/ radioButtons) { |
| 557 |
this.radioButtons = radioButtons; |
| 558 |
} |
| 559 |
|
| 560 |
/** |
| 561 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#setRadioButtonSelected(int, boolean) |
| 562 |
*/ |
| 563 |
public void setRadioButtonSelected(int id, boolean selected) { |
| 564 |
ButtonDetails details = getRadioButtonDetails(id); |
| 565 |
details.selected = selected; |
| 566 |
} |
| 567 |
|
| 568 |
/** |
| 569 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#setYesButtonText(java.lang.String) |
| 570 |
*/ |
| 571 |
public void setYesButtonText(String yesButtonText) { |
| 572 |
this.yesButtonText = yesButtonText; |
| 573 |
} |
| 574 |
|
| 575 |
private void updateButtonSelections() { |
| 576 |
updateCheckboxButtonSelections(); |
| 577 |
updateRadioButtonSelections(); |
| 578 |
} |
| 579 |
|
| 580 |
private void updateButtonSelections(List/*<ButtonDetails>*/ list) { |
| 581 |
synchronized (list) { |
| 582 |
Iterator/*<ButtonDetails>*/ iterator = list.iterator(); |
| 583 |
while (iterator.hasNext() == true) { |
| 584 |
ButtonDetails details = (ButtonDetails) iterator.next(); |
| 585 |
details.selected = details.button.getSelection(); |
| 586 |
} |
| 587 |
} |
| 588 |
} |
| 589 |
|
| 590 |
private void updateCheckboxButtonSelections() { |
| 591 |
List/*<ButtonDetails>*/ list = getCheckboxButtons(); |
| 592 |
updateButtonSelections(list); |
| 593 |
} |
| 594 |
|
| 595 |
private void updateRadioButtonSelections() { |
| 596 |
List/*<ButtonDetails>*/ list = getRadioButtons(); |
| 597 |
updateButtonSelections(list); |
| 598 |
} |
| 599 |
|
| 600 |
/** |
| 601 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#useErrorIcon() |
| 602 |
*/ |
| 603 |
public void useErrorIcon() { |
| 604 |
setImage(SWT.ICON_ERROR); |
| 605 |
} |
| 606 |
|
| 607 |
/** |
| 608 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#useInformationIcon() |
| 609 |
*/ |
| 610 |
public void useInformationIcon() { |
| 611 |
setImage(SWT.ICON_INFORMATION); |
| 612 |
} |
| 613 |
|
| 614 |
/** |
| 615 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#useQuestionIcon() |
| 616 |
*/ |
| 617 |
public void useQuestionIcon() { |
| 618 |
setImage(SWT.ICON_QUESTION); |
| 619 |
} |
| 620 |
|
| 621 |
/** |
| 622 |
* @see org.eclipse.soda.sat.plugin.ui.util.IHandyPromptDialog#useWarningIcon() |
| 623 |
*/ |
| 624 |
public void useWarningIcon() { |
| 625 |
setImage(SWT.ICON_WARNING); |
| 626 |
} |
| 627 |
} |