1 11 package org.eclipse.ui.editors.text; 12 13 import java.nio.charset.UnmappableCharacterException ; 14 15 import org.eclipse.core.runtime.Preferences; 16 17 import org.eclipse.core.resources.IResource; 18 19 import org.eclipse.core.filebuffers.IFileBuffer; 20 import org.eclipse.core.filebuffers.IFileBufferStatusCodes; 21 22 import org.eclipse.jface.preference.IPreferenceStore; 23 24 import org.eclipse.jface.text.source.ISharedTextColors; 25 26 import org.eclipse.ui.PlatformUI; 27 import org.eclipse.ui.internal.editors.text.EditorsPlugin; 28 import org.eclipse.ui.internal.editors.text.NLSUtility; 29 import org.eclipse.ui.keys.IBindingService; 30 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; 31 import org.eclipse.ui.texteditor.AnnotationPreferenceLookup; 32 import org.eclipse.ui.texteditor.AnnotationTypeLookup; 33 import org.eclipse.ui.texteditor.HyperlinkDetectorRegistry; 34 import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; 35 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; 36 import org.eclipse.ui.texteditor.spelling.SpellingService; 37 38 45 public final class EditorsUI { 46 47 50 public static final String PLUGIN_ID= "org.eclipse.ui.editors"; 52 55 public static final String DEFAULT_TEXT_EDITOR_ID = "org.eclipse.ui.DefaultTextEditor"; 57 58 63 public static AnnotationTypeLookup getAnnotationTypeLookup() { 64 return EditorsPlugin.getDefault().getAnnotationTypeLookup(); 65 } 66 67 72 public static AnnotationPreferenceLookup getAnnotationPreferenceLookup() { 73 return EditorsPlugin.getDefault().getAnnotationPreferenceLookup(); 74 } 75 76 81 public static IPreferenceStore getPreferenceStore() { 82 return EditorsPlugin.getDefault().getPreferenceStore(); 83 } 84 85 108 public static void useAnnotationsPreferencePage(IPreferenceStore store) { 109 MarkerAnnotationPreferences.useAnnotationsPreferencePage(store); 110 } 111 112 135 public static void useQuickDiffPreferencePage(IPreferenceStore store) { 136 MarkerAnnotationPreferences.useQuickDiffPreferencePage(store); 137 138 store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON); 139 store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE); 140 store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER); 141 } 142 143 private EditorsUI() { 144 } 146 147 153 public static Preferences getPluginPreferences() { 154 return EditorsPlugin.getDefault().getPluginPreferences(); 155 } 156 157 163 public static SpellingService getSpellingService() { 164 return EditorsPlugin.getDefault().getSpellingService(); 165 } 166 167 173 public static ISharedTextColors getSharedTextColors() { 174 return EditorsPlugin.getDefault().getSharedTextColors(); 175 } 176 177 185 public static HyperlinkDetectorRegistry getHyperlinkDetectorRegistry() { 186 return EditorsPlugin.getDefault().getHyperlinkDetectorRegistry(); 187 } 188 189 191 193 203 public static final int CHARSET_MAPPING_FAILED= 1; 204 205 214 public static final int STATE_VALIDATION_FAILED= IFileBufferStatusCodes.STATE_VALIDATION_FAILED; 215 216 225 public static final int DERIVED_FILE= IFileBufferStatusCodes.DERIVED_FILE; 226 227 235 public static final String getTooltipAffordanceString() { 236 if (!getPreferenceStore().getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE)) 237 return null; 238 239 IBindingService bindingService= (IBindingService)PlatformUI.getWorkbench().getAdapter(IBindingService.class); 240 if (bindingService == null) 241 return null; 242 243 String keySequence= bindingService.getBestActiveBindingFormattedFor(ITextEditorActionDefinitionIds.SHOW_INFORMATION); 244 if (keySequence == null) 245 return ""; 247 return NLSUtility.format(TextEditorMessages.Editor_toolTip_affordance, keySequence); 248 } 249 250 } 251 | Popular Tags |