1 11 12 package org.eclipse.jdt.internal.ui.preferences; 13 14 import java.io.File ; 15 import java.util.ArrayList ; 16 import java.util.Iterator ; 17 import java.util.List ; 18 import java.util.Locale ; 19 import java.util.Set ; 20 21 import org.eclipse.core.runtime.IStatus; 22 23 import org.eclipse.core.resources.IProject; 24 import org.eclipse.core.resources.ResourcesPlugin; 25 26 import org.eclipse.swt.SWT; 27 import org.eclipse.swt.events.SelectionAdapter; 28 import org.eclipse.swt.events.SelectionEvent; 29 import org.eclipse.swt.events.SelectionListener; 30 import org.eclipse.swt.layout.GridData; 31 import org.eclipse.swt.layout.GridLayout; 32 import org.eclipse.swt.widgets.Button; 33 import org.eclipse.swt.widgets.Combo; 34 import org.eclipse.swt.widgets.Composite; 35 import org.eclipse.swt.widgets.Control; 36 import org.eclipse.swt.widgets.Event; 37 import org.eclipse.swt.widgets.FileDialog; 38 import org.eclipse.swt.widgets.Group; 39 import org.eclipse.swt.widgets.Label; 40 import org.eclipse.swt.widgets.Text; 41 42 import org.eclipse.jface.dialogs.DialogPage; 43 import org.eclipse.jface.preference.IPreferenceStore; 44 import org.eclipse.jface.preference.PreferenceStore; 45 46 import org.eclipse.ui.PlatformUI; 47 import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; 48 49 import org.eclipse.ui.ide.dialogs.EncodingFieldEditor; 50 51 import org.eclipse.jdt.internal.corext.util.Messages; 52 53 import org.eclipse.jdt.ui.PreferenceConstants; 54 55 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 56 import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; 57 import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; 58 import org.eclipse.jdt.internal.ui.text.spelling.JavaSpellingEngine; 59 import org.eclipse.jdt.internal.ui.text.spelling.SpellCheckEngine; 60 import org.eclipse.jdt.internal.ui.text.spelling.SpellingEngine; 61 import org.eclipse.jdt.internal.ui.util.PixelConverter; 62 import org.eclipse.jdt.internal.ui.util.SWTUtil; 63 import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; 64 65 70 public class SpellingConfigurationBlock extends OptionsConfigurationBlock { 71 72 79 private static final boolean SUPPORT_CONTENT_ASSIST_PROPOSALS= false; 80 81 82 83 private static final Key PREF_SPELLING_IGNORE_DIGITS= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_DIGITS); 84 private static final Key PREF_SPELLING_IGNORE_MIXED= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_MIXED); 85 private static final Key PREF_SPELLING_IGNORE_SENTENCE= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_SENTENCE); 86 private static final Key PREF_SPELLING_IGNORE_UPPER= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_UPPER); 87 private static final Key PREF_SPELLING_IGNORE_JAVA_STRINGS= getJDTUIKey(JavaSpellingEngine.SPELLING_IGNORE_JAVA_STRINGS); 88 private static final Key PREF_SPELLING_IGNORE_SINGLE_LETTERS= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_SINGLE_LETTERS); 89 private static final Key PREF_SPELLING_IGNORE_NON_LETTERS= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_NON_LETTERS); 90 private static final Key PREF_SPELLING_IGNORE_URLS= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_URLS); 91 private static final Key PREF_SPELLING_IGNORE_AMPERSAND_IN_PROPERTIES= getJDTUIKey(PreferenceConstants.SPELLING_IGNORE_AMPERSAND_IN_PROPERTIES); 92 private static final Key PREF_SPELLING_LOCALE= getJDTUIKey(PreferenceConstants.SPELLING_LOCALE); 93 private static final Key PREF_SPELLING_PROPOSAL_THRESHOLD= getJDTUIKey(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD); 94 private static final Key PREF_SPELLING_PROBLEMS_THRESHOLD= getJDTUIKey(SpellingEngine.SPELLING_PROBLEMS_THRESHOLD); 95 private static final Key PREF_SPELLING_USER_DICTIONARY= getJDTUIKey(PreferenceConstants.SPELLING_USER_DICTIONARY); 96 private static final Key PREF_SPELLING_USER_DICTIONARY_ENCODING= getJDTUIKey(PreferenceConstants.SPELLING_USER_DICTIONARY_ENCODING); 97 private static final Key PREF_SPELLING_ENABLE_CONTENTASSIST= getJDTUIKey(PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST); 98 99 103 private static final String PREF_VALUE_NO_LOCALE= ""; 105 106 115 protected static void createSelectionDependency(final Button master, final Control slave) { 116 117 master.addSelectionListener(new SelectionListener() { 118 119 public void widgetDefaultSelected(SelectionEvent event) { 120 } 122 123 public void widgetSelected(SelectionEvent event) { 124 slave.setEnabled(master.getSelection()); 125 } 126 }); 127 slave.setEnabled(master.getSelection()); 128 } 129 130 137 protected static String [] getDictionaryCodes(final Set locales) { 138 139 int index= 0; 140 Locale locale= null; 141 142 final String [] codes= new String [locales.size() + 1]; 143 for (final Iterator iterator= locales.iterator(); iterator.hasNext();) { 144 locale= (Locale )iterator.next(); 145 codes[index++]= locale.toString(); 146 } 147 codes[index++]= PREF_VALUE_NO_LOCALE; 148 return codes; 149 } 150 151 158 protected static String [] getDictionaryLabels(final Set locales) { 159 160 int index= 0; 161 Locale locale= null; 162 163 final String [] labels= new String [locales.size() + 1]; 164 for (final Iterator iterator= locales.iterator(); iterator.hasNext();) { 165 166 locale= (Locale )iterator.next(); 167 labels[index++]= locale.getDisplayName(); 168 } 169 labels[index++]= PreferencesMessages.SpellingPreferencePage_dictionary_none; 170 return labels; 171 } 172 173 182 protected static IStatus validateAbsoluteFilePath(final String path) { 183 184 final StatusInfo status= new StatusInfo(); 185 if (path.length() > 0) { 186 187 final File file= new File (path); 188 if (!file.exists() && (!file.isAbsolute() || !file.getParentFile().canWrite())) 189 status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error); 190 else if (file.exists() && (!file.isFile() || !file.isAbsolute() || !file.canRead() || !file.canWrite())) 191 status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error); 192 193 } 194 return status; 195 } 196 197 203 private static IStatus validateLocale(final String localeString) { 204 if (PREF_VALUE_NO_LOCALE.equals(localeString)) 205 return new StatusInfo(); 206 207 Locale locale= SpellCheckEngine.convertToLocale(localeString); 208 209 if (SpellCheckEngine.findClosestLocale(locale) != null) 210 return new StatusInfo(); 211 212 return new StatusInfo(IStatus.ERROR, PreferencesMessages.SpellingPreferencePage_locale_error); 213 } 214 215 221 protected static IStatus validatePositiveNumber(final String number) { 222 final StatusInfo status= new StatusInfo(); 223 if (number.length() == 0) { 224 status.setError(PreferencesMessages.SpellingPreferencePage_empty_threshold); 225 } else { 226 try { 227 final int value= Integer.parseInt(number); 228 if (value < 0) { 229 status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); 230 } 231 } catch (NumberFormatException exception) { 232 status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); 233 } 234 } 235 return status; 236 } 237 238 239 private Text fDictionaryPath= null; 240 241 242 private IStatus fFileStatus= new StatusInfo(); 243 244 245 private IStatus fProposalsThresholdStatus= new StatusInfo(); 246 247 248 private IStatus fProblemsThresholdStatus= new StatusInfo(); 249 250 251 private IStatus fEncodingFieldEditorStatus= new StatusInfo(); 252 253 254 private EncodingFieldEditor fEncodingEditor; 255 256 private Composite fEncodingEditorParent; 257 258 262 private Control[] fAllControls; 263 264 268 private Control[] fEnabledControls; 269 270 277 public SpellingConfigurationBlock(final IStatusChangeListener context, final IProject project, IWorkbenchPreferenceContainer container) { 278 super(context, project, getAllKeys(), container); 279 280 IStatus status= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY)); 281 if (status.getSeverity() != IStatus.OK) 282 setValue(PREF_SPELLING_USER_DICTIONARY, ""); 284 status= validateLocale(getValue(PREF_SPELLING_LOCALE)); 285 if (status.getSeverity() != IStatus.OK) 286 setValue(PREF_SPELLING_LOCALE, SpellCheckEngine.getDefaultLocale().toString()); 287 } 288 289 protected Combo addComboBox(Composite parent, String label, Key key, String [] values, String [] valueLabels, int indent) { 290 ControlData data= new ControlData(key, values); 291 292 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); 293 gd.horizontalIndent= indent; 294 295 Label labelControl= new Label(parent, SWT.LEFT | SWT.WRAP); 296 labelControl.setText(label); 297 labelControl.setLayoutData(gd); 298 299 Combo comboBox= new Combo(parent, SWT.READ_ONLY); 300 comboBox.setItems(valueLabels); 301 comboBox.setData(data); 302 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); 303 gd.horizontalSpan= 2; 304 comboBox.setLayoutData(gd); 305 comboBox.addSelectionListener(getSelectionListener()); 306 307 fLabels.put(comboBox, labelControl); 308 309 String currValue= getValue(key); 310 311 Locale locale= SpellCheckEngine.convertToLocale(currValue); 312 locale= SpellCheckEngine.findClosestLocale(locale); 313 if (locale != null) 314 currValue= locale.toString(); 315 316 comboBox.select(data.getSelection(currValue)); 317 318 fComboBoxes.add(comboBox); 319 return comboBox; 320 } 321 322 325 protected Control createContents(final Composite parent) { 326 327 Composite composite= new Composite(parent, SWT.NONE); 328 composite.setLayout(new GridLayout()); 329 330 List allControls= new ArrayList (); 331 final PixelConverter converter= new PixelConverter(parent); 332 333 final String [] trueFalse= new String [] { IPreferenceStore.TRUE, IPreferenceStore.FALSE }; 334 335 Group user= new Group(composite, SWT.NONE); 336 user.setText(PreferencesMessages.SpellingPreferencePage_group_user); 337 user.setLayout(new GridLayout()); 338 user.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 339 allControls.add(user); 340 341 String label= PreferencesMessages.SpellingPreferencePage_ignore_digits_label; 342 Control slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_DIGITS, trueFalse, 0); 343 allControls.add(slave); 344 345 label= PreferencesMessages.SpellingPreferencePage_ignore_mixed_label; 346 slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_MIXED, trueFalse, 0); 347 allControls.add(slave); 348 349 label= PreferencesMessages.SpellingPreferencePage_ignore_sentence_label; 350 slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_SENTENCE, trueFalse, 0); 351 allControls.add(slave); 352 353 label= PreferencesMessages.SpellingPreferencePage_ignore_upper_label; 354 slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_UPPER, trueFalse, 0); 355 allControls.add(slave); 356 357 label= PreferencesMessages.SpellingPreferencePage_ignore_url_label; 358 slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_URLS, trueFalse, 0); 359 allControls.add(slave); 360 361 label= PreferencesMessages.SpellingPreferencePage_ignore_non_letters_label; 362 slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_NON_LETTERS, trueFalse, 0); 363 allControls.add(slave); 364 365 label= PreferencesMessages.SpellingPreferencePage_ignore_single_letters_label; 366 slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_SINGLE_LETTERS, trueFalse, 0); 367 allControls.add(slave); 368 369 label= PreferencesMessages.SpellingPreferencePage_ignore_java_strings_label; 370 slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_JAVA_STRINGS, trueFalse, 0); 371 allControls.add(slave); 372 373 label= PreferencesMessages.SpellingPreferencePage_ignore_ampersand_in_properties_label; 374 slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_AMPERSAND_IN_PROPERTIES, trueFalse, 0); 375 allControls.add(slave); 376 377 final Set locales= SpellCheckEngine.getLocalesWithInstalledDictionaries(); 378 boolean hasPlaformDictionaries= locales.size() > 0; 379 380 final Group engine= new Group(composite, SWT.NONE); 381 if (hasPlaformDictionaries) 382 engine.setText(PreferencesMessages.SpellingPreferencePage_group_dictionaries); 383 else 384 engine.setText(PreferencesMessages.SpellingPreferencePage_group_dictionary); 385 engine.setLayout(new GridLayout(4, false)); 386 engine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 387 allControls.add(engine); 388 389 if (hasPlaformDictionaries) { 390 label= PreferencesMessages.SpellingPreferencePage_dictionary_label; 391 Combo combo= addComboBox(engine, label, PREF_SPELLING_LOCALE, getDictionaryCodes(locales), getDictionaryLabels(locales), 0); 392 combo.setEnabled(locales.size() > 0); 393 allControls.add(combo); 394 allControls.add(fLabels.get(combo)); 395 396 new Label(engine, SWT.NONE); } 398 399 label= PreferencesMessages.SpellingPreferencePage_workspace_dictionary_label; 400 fDictionaryPath= addTextField(engine, label, PREF_SPELLING_USER_DICTIONARY, 0, 0); 401 GridData gd= (GridData) fDictionaryPath.getLayoutData(); 402 gd.grabExcessHorizontalSpace= true; 403 gd.widthHint= converter.convertWidthInCharsToPixels(40); 404 allControls.add(fDictionaryPath); 405 allControls.add(fLabels.get(fDictionaryPath)); 406 407 408 Button button= new Button(engine, SWT.PUSH); 409 button.setText(PreferencesMessages.SpellingPreferencePage_browse_label); 410 button.addSelectionListener(new SelectionAdapter() { 411 412 public void widgetSelected(final SelectionEvent event) { 413 handleBrowseButtonSelected(); 414 } 415 }); 416 button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); 417 SWTUtil.setButtonDimensionHint(button); 418 allControls.add(button); 419 420 new Label(engine, SWT.NONE); Label description= new Label(engine, SWT.NONE); 423 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); 424 gd.horizontalSpan= 3; 425 description.setLayoutData(gd); 426 description.setText(PreferencesMessages.SpellingPreferencePage_user_dictionary_description); 427 allControls.add(description); 428 429 createEncodingFieldEditor(engine, allControls); 430 431 Group advanced= new Group(composite, SWT.NONE); 432 advanced.setText(PreferencesMessages.SpellingPreferencePage_group_advanced); 433 advanced.setLayout(new GridLayout(3, false)); 434 advanced.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 435 allControls.add(advanced); 436 437 label= PreferencesMessages.SpellingPreferencePage_problems_threshold; 438 int digits= 4; 439 Text text= addTextField(advanced, label, PREF_SPELLING_PROBLEMS_THRESHOLD, 0, converter.convertWidthInCharsToPixels(digits+1)); 440 text.setTextLimit(digits); 441 allControls.add(text); 442 allControls.add(fLabels.get(text)); 443 444 label= PreferencesMessages.SpellingPreferencePage_proposals_threshold; 445 digits= 3; 446 text= addTextField(advanced, label, PREF_SPELLING_PROPOSAL_THRESHOLD, 0, converter.convertWidthInCharsToPixels(digits+1)); 447 text.setTextLimit(digits); 448 allControls.add(text); 449 allControls.add(fLabels.get(text)); 450 451 if (SUPPORT_CONTENT_ASSIST_PROPOSALS) { 452 label= PreferencesMessages.SpellingPreferencePage_enable_contentassist_label; 453 button= addCheckBox(advanced, label, PREF_SPELLING_ENABLE_CONTENTASSIST, trueFalse, 0); 454 allControls.add(button); 455 } 456 457 fAllControls= (Control[]) allControls.toArray(new Control[allControls.size()]); 458 459 PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.SPELLING_CONFIGURATION_BLOCK); 460 return composite; 461 } 462 463 470 private void createEncodingFieldEditor(Composite composite, List allControls) { 471 Label filler= new Label(composite, SWT.NONE); 472 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); 473 gd.horizontalSpan= 4; 474 filler.setLayoutData(gd); 475 476 Label label= new Label(composite, SWT.NONE); 477 label.setText(PreferencesMessages.SpellingPreferencePage_encoding_label); 478 label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); 479 allControls.add(label); 480 481 fEncodingEditorParent= new Composite(composite, SWT.NONE); 482 GridLayout layout= new GridLayout(2, false); 483 layout.marginWidth= 0; 484 layout.marginHeight= 0; 485 fEncodingEditorParent.setLayout(layout); 486 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); 487 gd.horizontalSpan= 3; 488 fEncodingEditorParent.setLayoutData(gd); 489 490 fEncodingEditor= new EncodingFieldEditor(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), "", null, fEncodingEditorParent); 492 PreferenceStore store= new PreferenceStore(); 493 String defaultEncoding= ResourcesPlugin.getEncoding(); 494 store.setDefault(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), defaultEncoding); 495 String encoding= getValue(PREF_SPELLING_USER_DICTIONARY_ENCODING); 496 if (encoding != null && encoding.length() > 0) 497 store.setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), encoding); 498 499 fEncodingEditor.setPreferenceStore(store); 500 501 DialogPage fakePage= new DialogPage() { 503 public void createControl(Composite c) { 504 } 505 public void setErrorMessage(String newMessage) { 506 StatusInfo status= new StatusInfo(); 507 if (newMessage != null) 508 status.setError(newMessage); 509 fEncodingFieldEditorStatus= status; 510 fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fProblemsThresholdStatus, fProposalsThresholdStatus, fFileStatus, fEncodingFieldEditorStatus })); 511 } 512 }; 513 fEncodingEditor.setPage(fakePage); 514 515 fEncodingEditor.load(); 516 517 if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0) 518 fEncodingEditor.loadDefault(); 519 520 } 521 522 private static Key[] getAllKeys() { 523 if (SUPPORT_CONTENT_ASSIST_PROPOSALS) 524 return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_AMPERSAND_IN_PROPERTIES, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST, PREF_SPELLING_IGNORE_JAVA_STRINGS }; 525 else 526 return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_AMPERSAND_IN_PROPERTIES, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_IGNORE_JAVA_STRINGS }; 527 } 528 529 532 protected final String [] getFullBuildDialogStrings(final boolean workspace) { 533 return null; 534 } 535 536 540 public boolean performOk() { 541 fEncodingEditor.store(); 542 if (fEncodingEditor.presentsDefaultValue()) 543 setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); else 545 setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, fEncodingEditor.getPreferenceStore().getString(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName())); 546 return super.performOk(); 547 } 548 549 553 public boolean performApply() { 554 fEncodingEditor.store(); 555 if (fEncodingEditor.presentsDefaultValue()) 556 setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); else 558 setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, fEncodingEditor.getPreferenceStore().getString(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName())); 559 return super.performApply(); 560 } 561 562 566 public void performDefaults() { 567 super.performDefaults(); 568 569 setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); 571 fEncodingEditor.getPreferenceStore().setValue(fEncodingEditor.getPreferenceName(), ResourcesPlugin.getEncoding()); 572 fEncodingEditor.load(); 573 574 fEncodingEditor.loadDefault(); 575 } 576 577 580 protected void handleBrowseButtonSelected() { 581 final FileDialog dialog= new FileDialog(fDictionaryPath.getShell(), SWT.OPEN); 582 dialog.setText(PreferencesMessages.SpellingPreferencePage_filedialog_title); 583 dialog.setFilterPath(fDictionaryPath.getText()); 584 585 final String path= dialog.open(); 586 if (path != null) 587 fDictionaryPath.setText(path); 588 } 589 590 593 protected void validateSettings(final Key key, final String oldValue, final String newValue) { 594 if (key == null || PREF_SPELLING_PROPOSAL_THRESHOLD.equals(key)) 595 fProposalsThresholdStatus= validatePositiveNumber(getValue(PREF_SPELLING_PROPOSAL_THRESHOLD)); 596 597 if (key == null || PREF_SPELLING_PROBLEMS_THRESHOLD.equals(key)) 598 fProblemsThresholdStatus= validatePositiveNumber(getValue(PREF_SPELLING_PROBLEMS_THRESHOLD)); 599 600 if (key == null || PREF_SPELLING_USER_DICTIONARY.equals(key)) 601 fFileStatus= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY)); 602 603 fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fProblemsThresholdStatus, fProposalsThresholdStatus, fFileStatus, fEncodingFieldEditorStatus })); 604 } 605 606 610 protected void updateCheckBox(Button curr) { 611 super.updateCheckBox(curr); 612 Event event= new Event(); 613 event.type= SWT.Selection; 614 event.display= curr.getDisplay(); 615 event.widget= curr; 616 curr.notifyListeners(SWT.Selection, event); 617 } 618 619 625 protected void setEnabled(boolean enabled) { 626 fEncodingEditor.setEnabled(enabled, fEncodingEditorParent); 627 628 if (enabled && fEnabledControls != null) { 629 for (int i= fEnabledControls.length - 1; i >= 0; i--) 630 fEnabledControls[i].setEnabled(true); 631 fEnabledControls= null; 632 } 633 if (!enabled && fEnabledControls == null) { 634 List enabledControls= new ArrayList (); 635 for (int i= fAllControls.length - 1; i >= 0; i--) { 636 Control control= fAllControls[i]; 637 if (control.isEnabled()) { 638 enabledControls.add(control); 639 control.setEnabled(false); 640 } 641 } 642 fEnabledControls= (Control[]) enabledControls.toArray(new Control[enabledControls.size()]); 643 } 644 } 645 646 647 } 648 | Popular Tags |