KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > texteditor > AbstractDecoratedTextEditorPreferenceConstants


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.ui.texteditor;
12
13 import java.util.StringTokenizer JavaDoc;
14
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.jface.preference.IPreferenceStore;
17 import org.eclipse.jface.preference.PreferenceConverter;
18 import org.eclipse.jface.resource.ColorRegistry;
19 import org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter;
20 import org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.graphics.RGB;
23 import org.eclipse.ui.PlatformUI;
24 import org.eclipse.ui.editors.text.EditorsUI;
25 import org.eclipse.ui.internal.editors.text.EditorsPlugin;
26 import org.eclipse.ui.internal.texteditor.ITextEditorThemeConstants;
27 import org.eclipse.ui.texteditor.spelling.SpellingService;
28
29 /**
30  * Preference constants used in the extended text editor preference store.
31  *
32  * @since 3.0
33  */

34 public class AbstractDecoratedTextEditorPreferenceConstants {
35
36
37     /**
38      * Prevent initialization.
39      */

40     private AbstractDecoratedTextEditorPreferenceConstants() {
41     }
42
43     /**
44      * A named preference that controls whether the current line highlighting is turned on or off
45      * (value <code>"currentLine"</code>).
46      * <p>
47      * The preference value is of type <code>Boolean</code>.
48      * </p>
49      */

50     public final static String JavaDoc EDITOR_CURRENT_LINE= "currentLine"; //$NON-NLS-1$
51

52     /**
53      * A named preference that holds the color used to highlight the current line
54      * (value <code>"currentLineColor"</code>).
55      * <p>
56      * The preference value is of type <code>String</code>. A RGB color value encoded as a string
57      * using class <code>PreferenceConverter</code>.
58      * </p>
59      * @see org.eclipse.jface.resource.StringConverter
60      * @see PreferenceConverter
61      */

62     public final static String JavaDoc EDITOR_CURRENT_LINE_COLOR= "currentLineColor"; //$NON-NLS-1$
63

64     /**
65      * A named preference that holds the number of spaces used per tab in the text editor.
66      * <p>
67      * Value is of type <code>int</code>: positive int value specifying the number of
68      * spaces per tab.
69      * </p>
70      */

71     public final static String JavaDoc EDITOR_TAB_WIDTH= "tabWidth"; //$NON-NLS-1$
72

73     /**
74      * A named preference that specifies if the editor uses spaces for tabs.
75      * <p>
76      * Value is of type <code>Boolean</code>. If <code>true</code>spaces instead of tabs are used
77      * in the editor. If <code>false</code> the editor inserts a tab character when pressing the tab
78      * key.
79      * </p>
80      */

81     public final static String JavaDoc EDITOR_SPACES_FOR_TABS= "spacesForTabs"; //$NON-NLS-1$
82

83     /**
84      * A named preference that holds the size of the editor's undo history.
85      * <p>
86      * Value is of type <code>int</code>: 0 or positive int value specifying the size of
87      * the editor's undo history.
88      * </p>
89      * @since 3.1
90      */

91     public final static String JavaDoc EDITOR_UNDO_HISTORY_SIZE= "undoHistorySize"; //$NON-NLS-1$
92

93     /**
94      * A named preference that controls whether the print margin is turned on or off
95      * (value <code>"printMargin"</code>).
96      * <p>
97      * The preference value is of type <code>Boolean</code>.
98      * </p>
99      */

100     public final static String JavaDoc EDITOR_PRINT_MARGIN= "printMargin"; //$NON-NLS-1$
101

102     /**
103      * A named preference that holds the color used to render the print margin
104      * (value <code>"printMarginColor"</code>).
105      * <p>
106      * The preference value is of type <code>String</code>. A RGB color value encoded as a string
107      * using class <code>PreferenceConverter</code>.
108      * </p>
109      * @see org.eclipse.jface.resource.StringConverter
110      * @see PreferenceConverter
111      */

112     public final static String JavaDoc EDITOR_PRINT_MARGIN_COLOR= "printMarginColor"; //$NON-NLS-1$
113

114     /**
115      * Print margin column
116      * (value <code>"printMarginColumn"</code>).
117      * <p>
118      * The preference value is of type <code>int</code>.
119      * </p>
120      */

121     public final static String JavaDoc EDITOR_PRINT_MARGIN_COLUMN= "printMarginColumn"; //$NON-NLS-1$
122

123     /**
124      * A named preference that controls whether the editor shows unknown
125      * indicators in text (squiggly lines).
126      * (value <code>"othersIndication"</code>).
127      * <p>
128      * The preference value is of type <code>Boolean</code>.
129      * </p>
130      * @deprecated as of 3.0 there are no UNKNOWN annotations any more
131      */

132     public final static String JavaDoc EDITOR_UNKNOWN_INDICATION= "othersIndication"; //$NON-NLS-1$
133

134     /**
135      * A named preference that holds the color used to render unknown indicators
136      * (value <code>"othersIndicationColor"</code>).
137      * <p>
138      * The preference value is of type <code>String</code>. A RGB color value encoded as a string
139      * using class <code>PreferenceConverter</code>.
140      * </p>
141      * @see #EDITOR_UNKNOWN_INDICATION
142      * @see org.eclipse.jface.resource.StringConverter
143      * @see PreferenceConverter
144      * @deprecated As of 3.0, there are no UNKNOWN annotations any more
145      */

146     public final static String JavaDoc EDITOR_UNKNOWN_INDICATION_COLOR= "othersIndicationColor"; //$NON-NLS-1$
147

148     /**
149      * A named preference that controls whether the overview ruler shows unknown indicators
150      * (value <code>"othersIndicationInOverviewRuler"</code>).
151      * <p>
152      * The preference value is of type <code>Boolean</code>.
153      * </p>
154      * @deprecated As of 3.0, there are no UNKNOWN annotations any more
155      */

156     public final static String JavaDoc EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER= "othersIndicationInOverviewRuler"; //$NON-NLS-1$
157

158     /**
159      * A named preference that controls if the overview ruler is shown in the UI
160      * (value <code>"overviewRuler"</code>).
161      * <p>
162      * The preference value is of type <code>Boolean</code>.
163      * </p>
164      */

165     public final static String JavaDoc EDITOR_OVERVIEW_RULER= "overviewRuler"; //$NON-NLS-1$
166

167     /**
168      * A named preference that controls if the line number ruler is shown in the UI
169      * (value <code>"lineNumberRuler"</code>).
170      * <p>
171      * The preference value is of type <code>Boolean</code>.
172      * </p>
173      */

174     public final static String JavaDoc EDITOR_LINE_NUMBER_RULER= "lineNumberRuler"; //$NON-NLS-1$
175

176     /**
177      * A named preference that holds the color used to render line numbers inside the line number ruler
178      * (value <code>"lineNumberColor"</code>).
179      * <p>
180      * The preference value is of type <code>String</code>. A RGB color value encoded as a string
181      * using class <code>PreferenceConverter</code>.
182      * </p>
183      * @see org.eclipse.jface.resource.StringConverter
184      * @see PreferenceConverter
185      * @see #EDITOR_LINE_NUMBER_RULER
186      */

187     public final static String JavaDoc EDITOR_LINE_NUMBER_RULER_COLOR= "lineNumberColor"; //$NON-NLS-1$
188

189     /**
190      * A named preference that controls whether this plug-in's
191      * Annotations preference page is used to configure annotations.
192      * <p>
193      * Value is of type <code>boolean</code>.
194      * </p>
195      */

196     public static final String JavaDoc USE_ANNOTATIONS_PREFERENCE_PAGE= "useAnnotationsPrefPage"; //$NON-NLS-1$
197

198     /**
199      * A named preference that controls whether this plug-in's
200      * Quick Diff preference page is used to configure Quick Diff.
201      * <p>
202      * Value is of type <code>boolean</code>.
203      * </p>
204      */

205     public static final String JavaDoc USE_QUICK_DIFF_PREFERENCE_PAGE= "useQuickDiffPrefPage"; //$NON-NLS-1$
206

207     /**
208      * A named preference that controls whether quick diff colors are shown on the line number bar.
209      * <p>
210      * Value is of type <code>boolean</code>.
211      * </p>
212      */

213     public static final String JavaDoc QUICK_DIFF_ALWAYS_ON= "quickdiff.quickDiff"; //$NON-NLS-1$
214

215     /**
216      * A named preference that controls the default quick diff reference provider.
217      * <p>
218      * Value is of type <code>String</code>.
219      * </p>
220      */

221     public static final String JavaDoc QUICK_DIFF_DEFAULT_PROVIDER= "quickdiff.defaultProvider"; //$NON-NLS-1$
222

223     /**
224      * A named preference that controls the default quick diff reference provider.
225      * <p>
226      * Value is of type <code>String</code>.
227      * </p>
228      */

229     public static final String JavaDoc QUICK_DIFF_CHARACTER_MODE= "quickdiff.characterMode"; //$NON-NLS-1$
230

231     /**
232      * A named preference that controls whether custom carets are used in the
233      * editor or not.
234      * <p>
235      * Value is of type <code>Boolean</code>. If <code>false</code>, only
236      * the default caret is used in the editor.
237      * </p>
238      */

239     public static final String JavaDoc EDITOR_USE_CUSTOM_CARETS= AbstractTextEditor.PREFERENCE_USE_CUSTOM_CARETS;
240
241     /**
242      * A named preference that controls whether carets are drawn wide or not.
243      * <p>
244      * Value is of type <code>Boolean</code>. If <code>true</code>, the caret is
245      * twice as wide as the default caret.
246      * </p>
247      */

248     public static final String JavaDoc EDITOR_WIDE_CARET= AbstractTextEditor.PREFERENCE_WIDE_CARET;
249
250     /**
251      * A named preference that holds the color used as the text selection foreground.
252      * This value has no effect if the system default color is used.
253      * <p>
254      * Value is of type <code>String</code>. A RGB color value encoded as a string
255      * using class <code>PreferenceConverter</code>
256      * </p>
257      *
258      * @see org.eclipse.jface.resource.StringConverter
259      * @see PreferenceConverter
260      */

261     public final static String JavaDoc EDITOR_SELECTION_FOREGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND;
262
263     /**
264      * A named preference that describes if the system default selection foreground color
265      * is used as the text selection foreground.
266      * <p>
267      * Value is of type <code>Boolean</code>.
268      * </p>
269      */

270     public final static String JavaDoc EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT;
271
272     /**
273      * A named preference that holds the color used as the text selection background.
274      * This value has no effect if the system default color is used.
275      * <p>
276      * Value is of type <code>String</code>. A RGB color value encoded as a string
277      * using class <code>PreferenceConverter</code>
278      * </p>
279      *
280      * @see org.eclipse.jface.resource.StringConverter
281      * @see PreferenceConverter
282      */

283     public final static String JavaDoc EDITOR_SELECTION_BACKGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND;
284
285     /**
286      * A named preference that describes if the system default selection background color
287      * is used as the text selection background.
288      * <p>
289      * Value is of type <code>Boolean</code>.
290      * </p>
291      */

292     public final static String JavaDoc EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT;
293
294     /**
295      * A named preference that controls if hyperlinks are turned on or off.
296      * <p>
297      * Value is of type <code>Boolean</code>.
298      * </p>
299      *
300      * @since 3.1
301      */

302     public static final String JavaDoc EDITOR_HYPERLINKS_ENABLED= AbstractTextEditor.PREFERENCE_HYPERLINKS_ENABLED;
303
304     /**
305      * A named preference that controls the key modifier for hyperlinks.
306      * <p>
307      * Value is of type <code>String</code>.
308      * </p>
309      *
310      * @since 3.1
311      */

312     public static final String JavaDoc EDITOR_HYPERLINK_KEY_MODIFIER= AbstractTextEditor.PREFERENCE_HYPERLINK_KEY_MODIFIER;
313
314     /**
315      * A named preference that controls the key modifier mask for hyperlinks.
316      * The value is only used if the value of <code>EDITOR_HYPERLINK_KEY_MODIFIER</code>
317      * cannot be resolved to valid SWT modifier bits.
318      * <p>
319      * Value is of type <code>String</code>.
320      * </p>
321      *
322      * @see #EDITOR_HYPERLINK_KEY_MODIFIER
323      * @since 3.1
324      */

325     public static final String JavaDoc EDITOR_HYPERLINK_KEY_MODIFIER_MASK= AbstractTextEditor.PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK;
326
327     /**
328      * A named preference that holds the color used for hyperlinks.
329      * <p>
330      * Value is of type <code>String</code>. A RGB color value encoded as a string
331      * using class <code>PreferenceConverter</code>
332      * </p>
333      *
334      * @see org.eclipse.jface.resource.StringConverter
335      * @see org.eclipse.jface.preference.PreferenceConverter
336      * @since 3.1
337      */

338     public final static String JavaDoc EDITOR_HYPERLINK_COLOR= DefaultHyperlinkPresenter.HYPERLINK_COLOR;
339
340     /**
341      * A named preference that controls disabling of the overwrite mode.
342      * <p>
343      * Value is of type <code>Boolean</code>.
344      * </p>
345      *
346      * @since 3.1
347      */

348     public static final String JavaDoc EDITOR_DISABLE_OVERWRITE_MODE= "disable_overwrite_mode"; //$NON-NLS-1$
349

350     /**
351      * A named preference that controls whether a confirmation
352      * dialog is shown before editing derived input.
353      * <p>
354      * Value is of type <code>Boolean</code>.
355      * </p>
356      *
357      * @since 3.3
358      */

359     public static final String JavaDoc EDITOR_WARN_IF_INPUT_DERIVED= "warn_if_input_derived"; //$NON-NLS-1$
360

361     /**
362      * A named preference that controls if smart home/end navigation is on or off
363      * <p>
364      * Value is of type <code>Boolean</code>.
365      * </p>
366      *
367      * @since 3.3
368      */

369     public static final String JavaDoc EDITOR_SMART_HOME_END= AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END;
370
371     /**
372      * A named preference that controls the display of whitespace characters.
373      * <p>
374      * Value is of type <code>Boolean</code>.
375      * </p>
376      *
377      * @since 3.3
378      */

379     public static final String JavaDoc EDITOR_SHOW_WHITESPACE_CHARACTERS= AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS;
380
381     /**
382      * A named preference that controls the display of the range indicator.
383      * <p>
384      * Value is of type <code>Boolean</code>.
385      * </p>
386      *
387      * @since 3.1
388      */

389     public static final String JavaDoc SHOW_RANGE_INDICATOR= "show_range_indicator"; //$NON-NLS-1$
390

391     /**
392      * A named preference that controls whether the user is asked before switching the quick diff
393      * reference when showing revision information..
394      * <p>
395      * Value is of type <code>String</code>.
396      * </p>
397      *
398      * @since 3.2
399      */

400     public static final String JavaDoc REVISION_ASK_BEFORE_QUICKDIFF_SWITCH= "quickdiff.nowarn.before.switch"; //$NON-NLS-1$
401

402     /**
403      * A named preference that controls the rendering mode of the revision ruler.
404      * <p>
405      * Value is of type <code>String</code> and should contain the name of a
406      * {@link org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension.RenderingMode}.
407      * </p>
408      *
409      * @since 3.3
410      */

411     public static final String JavaDoc REVISION_RULER_RENDERING_MODE= "revisionRulerRenderingMode"; //$NON-NLS-1$
412

413     /**
414      * A named preference that controls the rendering of the author on the revision ruler.
415      * <p>
416      * Value is of type <code>Boolean</code>.
417      * </p>
418      *
419      * @since 3.3
420      */

421     public static final String JavaDoc REVISION_RULER_SHOW_AUTHOR= "revisionRulerShowAuthor"; //$NON-NLS-1$
422

423     /**
424      * A named preference that controls rendering of the revision on the revision ruler.
425      * <p>
426      * Value is of type <code>Boolean</code>.
427      * </p>
428      *
429      * @since 3.3
430      */

431     public static final String JavaDoc REVISION_RULER_SHOW_REVISION= "revisionRulerShowRevision"; //$NON-NLS-1$
432

433     /**
434      * A named preference that controls whether text drag and drop is enabled.
435      * <p>
436      * Value is of type <code>Boolean</code>.
437      * </p>
438      *
439      * @since 3.3
440      */

441     public static final String JavaDoc EDITOR_TEXT_DRAG_AND_DROP_ENABLED= AbstractTextEditor.PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED;
442     
443     /**
444      * A named preference that defines whether the hint to make hover sticky should be shown.
445      * <p>
446      * Value is of type <code>Boolean</code>.
447      * </p>
448      *
449      * @since 3.3
450      */

451     public static final String JavaDoc EDITOR_SHOW_TEXT_HOVER_AFFORDANCE= "showTextHoverAffordance"; //$NON-NLS-1$
452

453     /**
454     * Initializes the given preference store with the default values.
455      *
456     * @param store the preference store to be initialized
457     */

458     public static void initializeDefaultValues(IPreferenceStore store) {
459         ColorRegistry registry= null;
460         if (PlatformUI.isWorkbenchRunning())
461             registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
462
463         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.USE_ANNOTATIONS_PREFERENCE_PAGE, false);
464         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE, false);
465
466         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, true);
467         setDefaultAndFireEvent(store,
468                 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR,
469                 findRGB(registry, ITextEditorThemeConstants.CURRENT_LINE_COLOR, new RGB(232, 242, 254)));
470
471         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 4);
472         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, false);
473
474         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNDO_HISTORY_SIZE, 200);
475
476         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, false);
477         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 80);
478         
479         setDefaultAndFireEvent(store,
480                 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR,
481                 findRGB(registry,ITextEditorThemeConstants.PRINT_MARGIN_COLOR, new RGB(176, 180 , 185)));
482
483         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, false);
484         setDefaultAndFireEvent(store,
485                 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR,
486                 findRGB(registry, ITextEditorThemeConstants.LINE_NUMBER_RULER_COLOR, new RGB(120, 120, 120)));
487
488         if (!store.getBoolean(USE_QUICK_DIFF_PREFERENCE_PAGE)) {
489             store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON, true);
490             store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE, false);
491             store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER, "org.eclipse.ui.internal.editors.quickdiff.LastSaveReferenceProvider"); //$NON-NLS-1$
492
}
493
494         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, true);
495
496         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION, false);
497         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER, false);
498         PreferenceConverter.setDefault(store, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR, new RGB(0, 0, 0));
499
500         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS, false);
501         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET, true);
502
503         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR, true);
504         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR, true);
505
506         store.setDefault(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, true);
507         setDefaultAndFireEvent(store,
508                 AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
509                 findRGB(registry, ITextEditorThemeConstants.PREFERENCE_COLOR_BACKGROUND, new RGB(255, 255, 255)));
510         
511         store.setDefault(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, true);
512         setDefaultAndFireEvent(store,
513                 AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
514                 findRGB(registry, ITextEditorThemeConstants.PREFERENCE_COLOR_FOREGROUND, new RGB(0,0,0)));
515         
516         String JavaDoc mod1Name= Action.findModifierString(SWT.MOD1); // SWT.COMMAND on MAC; SWT.CONTROL elsewhere
517
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED, true);
518         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER, mod1Name);
519         store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER_MASK, SWT.MOD1);
520         
521         setDefaultAndFireEvent(store,
522                 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_COLOR,
523                 findRGB(registry,ITextEditorThemeConstants.HYPERLINK_COLOR, new RGB(0, 0, 255)));
524
525         HyperlinkDetectorDescriptor[] descriptors= EditorsUI.getHyperlinkDetectorRegistry().getHyperlinkDetectorDescriptors();
526         for (int i= 0; i < descriptors.length; i++) {
527             int stateMask= computeStateMask(descriptors[i].getModifierKeys());
528             if (stateMask == SWT.SHIFT) {
529                 EditorsPlugin.logErrorMessage("The '" + descriptors[i].getId() + "' hyperlink detector specifies 'Shift' as modifier. This is not allowed and hence replaced with the default modifier."); //$NON-NLS-1$ //$NON-NLS-2$
530
stateMask= -1;
531             }
532             store.setDefault(descriptors[i].getId() + HyperlinkDetectorDescriptor.STATE_MASK_POSTFIX, stateMask);
533         }
534
535         store.setToDefault(EDITOR_DISABLE_OVERWRITE_MODE);
536
537         /*
538          * As of 3.3 we enabled spell checking per default
539          * but do not want this to impact our performance tests. For this
540          * reason we disable it when running the UI test application.
541          */

542         boolean isInTestMode= System.getProperty("eclipse.perf.dbloc") != null; //$NON-NLS-1$
543
boolean isInstalled= EditorsUI.getSpellingService().getSpellingEngineDescriptors().length > 0;
544         store.setDefault(SpellingService.PREFERENCE_SPELLING_ENABLED, !isInTestMode && isInstalled);
545         store.setDefault(SpellingService.PREFERENCE_SPELLING_ENGINE, ""); //$NON-NLS-1$
546

547         store.setDefault(SHOW_RANGE_INDICATOR, true);
548         store.setDefault(REVISION_ASK_BEFORE_QUICKDIFF_SWITCH, ""); //$NON-NLS-1$
549

550         setDefaultAndFireEvent(store,
551                 AbstractTextEditor.PREFERENCE_COLOR_FIND_SCOPE,
552                 findRGB(registry, ITextEditorThemeConstants.FIND_SCOPE_COLOR, new RGB(185, 176 , 180)));
553         
554         store.setDefault(AbstractTextEditor.PREFERENCE_RULER_CONTRIBUTIONS, ""); //$NON-NLS-1$
555
store.setDefault(REVISION_RULER_RENDERING_MODE, IRevisionRulerColumnExtension.AGE.name());
556         store.setDefault(REVISION_RULER_SHOW_AUTHOR, false);
557         store.setDefault(REVISION_RULER_SHOW_REVISION, false);
558
559         store.setDefault(EDITOR_WARN_IF_INPUT_DERIVED, true);
560         store.setDefault(EDITOR_SMART_HOME_END, true);
561         store.setDefault(EDITOR_SHOW_WHITESPACE_CHARACTERS, false);
562         store.setDefault(EDITOR_TEXT_DRAG_AND_DROP_ENABLED, true);
563         store.setDefault(EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true);
564         
565         MarkerAnnotationPreferences.initializeDefaultValues(store);
566     }
567
568     /**
569      * Sets the default value and fires a property
570      * change event if necessary.
571      *
572      * @param store the preference store
573      * @param key the preference key
574      * @param newValue the new value
575      * @since 3.3
576      */

577     private static void setDefaultAndFireEvent(IPreferenceStore store, String JavaDoc key, RGB newValue) {
578         RGB oldValue= null;
579         if (store.isDefault(key))
580             oldValue= PreferenceConverter.getDefaultColor(store, key);
581         
582         PreferenceConverter.setDefault(store, key, newValue);
583         
584         if (oldValue != null && !oldValue.equals(newValue))
585             store.firePropertyChangeEvent(key, oldValue, newValue);
586     }
587     
588     /**
589      * Returns the RGB for the given key in the given color registry.
590      *
591      * @param registry the color registry
592      * @param key the key for the constant in the registry
593      * @param defaultRGB the default RGB if no entry is found
594      * @return RGB the RGB
595      * @since 3.3
596      */

597     private static RGB findRGB(ColorRegistry registry, String JavaDoc key, RGB defaultRGB) {
598         if (registry == null)
599             return defaultRGB;
600         
601         RGB rgb= registry.getRGB(key);
602         if (rgb != null)
603             return rgb;
604         return defaultRGB;
605     }
606
607     /**
608      * Computes the state mask out of the given modifiers string.
609      *
610      * @param modifiers a string containing modifiers
611      * @return the state mask
612      * @since 3.3
613      */

614     private static final int computeStateMask(String JavaDoc modifiers) {
615         if (modifiers == null)
616             return -1;
617
618         if (modifiers.length() == 0)
619             return SWT.NONE;
620
621         int stateMask= 0;
622         StringTokenizer JavaDoc modifierTokenizer= new StringTokenizer JavaDoc(modifiers, ",;.:+-* "); //$NON-NLS-1$
623
while (modifierTokenizer.hasMoreTokens()) {
624             int modifier= findLocalizedModifier(modifierTokenizer.nextToken());
625             if (modifier == 0 || (stateMask & modifier) == modifier)
626                 return -1;
627             stateMask= stateMask | modifier;
628         }
629         return stateMask;
630     }
631
632     /**
633      * Maps the localized modifier name to a code in the same
634      * manner as #findModifier.
635      *
636      * @param modifierName the modifier name
637      * @return the SWT modifier bit, or <code>0</code> if no match was found
638      * @since 3.3
639      */

640     private static final int findLocalizedModifier(String JavaDoc modifierName) {
641         if (modifierName == null)
642             return SWT.NONE;
643
644         if (modifierName.equalsIgnoreCase("M1")) //$NON-NLS-1$
645
return SWT.MOD1;
646         if (modifierName.equalsIgnoreCase("M2")) //$NON-NLS-1$
647
return SWT.MOD2;
648         if (modifierName.equalsIgnoreCase("M3")) //$NON-NLS-1$
649
return SWT.MOD3;
650         if (modifierName.equalsIgnoreCase("M4")) //$NON-NLS-1$
651
return SWT.MOD4;
652         if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.CTRL)))
653             return SWT.CTRL;
654         if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.SHIFT)))
655             return SWT.SHIFT;
656         if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.ALT)))
657             return SWT.ALT;
658         if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.COMMAND)))
659             return SWT.COMMAND;
660
661         return SWT.NONE;
662     }
663     
664 }
665
Popular Tags