1 11 12 package org.eclipse.jdt.internal.ui.preferences; 13 14 import org.eclipse.core.runtime.IStatus; 15 16 import org.eclipse.swt.widgets.Composite; 17 import org.eclipse.swt.widgets.Control; 18 19 import org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor; 20 import org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock; 21 22 import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; 23 24 29 public class SpellingPreferenceBlock implements ISpellingPreferenceBlock { 30 31 private class NullStatusChangeListener implements IStatusChangeListener { 32 33 36 public void statusChanged(IStatus status) { 37 } 38 } 39 40 private class StatusChangeListenerAdapter implements IStatusChangeListener { 41 42 private IPreferenceStatusMonitor fMonitor; 43 44 private IStatus fStatus; 45 46 public StatusChangeListenerAdapter(IPreferenceStatusMonitor monitor) { 47 super(); 48 fMonitor= monitor; 49 } 50 51 54 public void statusChanged(IStatus status) { 55 fStatus= status; 56 fMonitor.statusChanged(status); 57 } 58 59 public IStatus getStatus() { 60 return fStatus; 61 } 62 } 63 64 private SpellingConfigurationBlock fBlock= new SpellingConfigurationBlock(new NullStatusChangeListener(), null, null); 65 66 private SpellingPreferenceBlock.StatusChangeListenerAdapter fStatusMonitor; 67 68 71 public Control createControl(Composite parent) { 72 return fBlock.createContents(parent); 73 } 74 75 78 public void initialize(IPreferenceStatusMonitor statusMonitor) { 79 fStatusMonitor= new StatusChangeListenerAdapter(statusMonitor); 80 fBlock.fContext= fStatusMonitor; 81 } 82 83 86 public boolean canPerformOk() { 87 return fStatusMonitor == null || fStatusMonitor.getStatus() == null || !fStatusMonitor.getStatus().matches(IStatus.ERROR); 88 } 89 90 93 public void performOk() { 94 fBlock.performOk(); 95 } 96 97 100 public void performDefaults() { 101 fBlock.performDefaults(); 102 } 103 104 107 public void performRevert() { 108 fBlock.performRevert(); 109 } 110 111 114 public void dispose() { 115 fBlock.dispose(); 116 } 117 118 121 public void setEnabled(boolean enabled) { 122 fBlock.setEnabled(enabled); 123 } 124 } 125 | Popular Tags |