1 /*******************************************************************************
2  * Copyright (c) 2000, 2019 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.ui.texteditor;
15 
16 import java.util.StringTokenizer;
17 
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.graphics.RGB;
20 
21 import org.eclipse.jface.action.Action;
22 import org.eclipse.jface.dialogs.MessageDialogWithToggle;
23 import org.eclipse.jface.preference.IPreferenceStore;
24 import org.eclipse.jface.preference.PreferenceConverter;
25 
26 import org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter;
27 import org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension;
28 
29 import org.eclipse.ui.internal.editors.text.EditorsPlugin;
30 import org.eclipse.ui.internal.editors.text.EditorsPluginPreferenceInitializer;
31 
32 import org.eclipse.ui.texteditor.spelling.SpellingService;
33 
34 import org.eclipse.ui.editors.text.EditorsUI;
35 
36 
37 /**
38  * Preference constants used in the extended text editor preference store.
39  *
40  * @since 3.0
41  * @noinstantiate This class is not intended to be instantiated by clients.
42  * @noextend This class is not intended to be subclassed by clients.
43  */
44 public class AbstractDecoratedTextEditorPreferenceConstants {
45 
46 
47 	/**
48 	 * Prevent initialization.
49 	 */
AbstractDecoratedTextEditorPreferenceConstants()50 	private AbstractDecoratedTextEditorPreferenceConstants() {
51 	}
52 
53 	/**
54 	 * A named preference that controls whether the current line highlighting is turned on or off
55 	 * (value <code>"currentLine"</code>).
56 	 * <p>
57 	 * The preference value is of type <code>Boolean</code>.
58 	 * </p>
59 	 */
60 	public final static String EDITOR_CURRENT_LINE= "currentLine"; //$NON-NLS-1$
61 
62 	/**
63 	 * A named preference that holds the color used to highlight the current line
64 	 * (value <code>"currentLineColor"</code>).
65 	 * <p>
66 	 * The preference value is of type <code>String</code>. A RGB color value encoded as a string
67 	 * using class <code>PreferenceConverter</code>.
68 	 * </p>
69 	 * @see org.eclipse.jface.resource.StringConverter
70 	 * @see PreferenceConverter
71 	 */
72 	public final static String EDITOR_CURRENT_LINE_COLOR= "currentLineColor"; //$NON-NLS-1$
73 
74 	/**
75 	 * A named preference that holds the number of spaces used per tab in the text editor.
76 	 * <p>
77 	 * Value is of type <code>int</code>: positive int value specifying the number of
78 	 * spaces per tab.
79 	 * </p>
80 	 */
81 	public final static String EDITOR_TAB_WIDTH= "tabWidth"; //$NON-NLS-1$
82 
83 	/**
84 	 * A named preference that specifies if the editor uses spaces for tabs.
85 	 * <p>
86 	 * Value is of type <code>Boolean</code>. If <code>true</code>spaces instead of tabs are used
87 	 * in the editor. If <code>false</code> the editor inserts a tab character when pressing the tab
88 	 * key.
89 	 * </p>
90 	 */
91 	public final static String EDITOR_SPACES_FOR_TABS= "spacesForTabs"; //$NON-NLS-1$
92 
93 	/**
94 	 * A named preference that specifies if the editor removes multiple spaces on delete/backspace
95 	 * key as if they were tabs. Only relevant when {@link #EDITOR_SPACES_FOR_TABS} preference is
96 	 * set to <code>true</code>.
97 	 * <p>
98 	 * Value is of type <code>Boolean</code>. If <code>true</code>, the editor removes multiple
99 	 * spaces.
100 	 * </p>
101 	 *
102 	 * @since 3.13
103 	 */
104 	public final static String EDITOR_DELETE_SPACES_AS_TABS= "removeSpacesAsTabs"; //$NON-NLS-1$
105 
106 	/**
107 	 * A named preference that holds the size of the editor's undo history.
108 	 * <p>
109 	 * Value is of type <code>int</code>: 0 or positive int value specifying the size of
110 	 * the editor's undo history.
111 	 * </p>
112 	 * @since 3.1
113 	 */
114 	public final static String EDITOR_UNDO_HISTORY_SIZE= "undoHistorySize"; //$NON-NLS-1$
115 
116 	/**
117 	 * A named preference that controls whether the print margin is turned on or off
118 	 * (value <code>"printMargin"</code>).
119 	 * <p>
120 	 * The preference value is of type <code>Boolean</code>.
121 	 * </p>
122 	 */
123 	public final static String EDITOR_PRINT_MARGIN= "printMargin"; //$NON-NLS-1$
124 
125 	/**
126 	 * A named preference that holds the color used to render the print margin
127 	 * (value <code>"printMarginColor"</code>).
128 	 * <p>
129 	 * The preference value is of type <code>String</code>. A RGB color value encoded as a string
130 	 * using class <code>PreferenceConverter</code>.
131 	 * </p>
132 	 * @see org.eclipse.jface.resource.StringConverter
133 	 * @see PreferenceConverter
134 	 */
135 	public final static String EDITOR_PRINT_MARGIN_COLOR= "printMarginColor"; //$NON-NLS-1$
136 
137 	/**
138 	 * Print margin column
139 	 * (value <code>"printMarginColumn"</code>).
140 	 * <p>
141 	 * The preference value is of type <code>int</code>.
142 	 * </p>
143 	 */
144 	public final static String EDITOR_PRINT_MARGIN_COLUMN= "printMarginColumn"; //$NON-NLS-1$
145 
146 	/**
147 	 * Tells whether editors are allowed to override the print margin preference (value
148 	 * <code>"printMarginAllowOverride"</code>).
149 	 * <p>
150 	 * The preference value is of type <code>boolean</code>.
151 	 * </p>
152 	 *
153 	 * @noreference This field is not intended to be referenced by clients.
154 	 */
155 	public final static String EDITOR_PRINT_MARGIN_ALLOW_OVERRIDE= "printMarginAllowOverride"; //$NON-NLS-1$
156 
157 	/**
158 	 * A named preference that controls whether the editor shows unknown
159 	 * indicators in text (squiggly lines).
160 	 * (value <code>"othersIndication"</code>).
161 	 * <p>
162 	 * The preference value is of type <code>Boolean</code>.
163 	 * </p>
164 	 * @deprecated as of 3.0 there are no UNKNOWN annotations any more
165 	 */
166 	@Deprecated
167 	public final static String EDITOR_UNKNOWN_INDICATION= "othersIndication"; //$NON-NLS-1$
168 
169 	/**
170 	 * A named preference that holds the color used to render unknown indicators
171 	 * (value <code>"othersIndicationColor"</code>).
172 	 * <p>
173 	 * The preference value is of type <code>String</code>. A RGB color value encoded as a string
174 	 * using class <code>PreferenceConverter</code>.
175 	 * </p>
176 	 * @see #EDITOR_UNKNOWN_INDICATION
177 	 * @see org.eclipse.jface.resource.StringConverter
178 	 * @see PreferenceConverter
179 	 * @deprecated As of 3.0, there are no UNKNOWN annotations any more
180 	 */
181 	@Deprecated
182 	public final static String EDITOR_UNKNOWN_INDICATION_COLOR= "othersIndicationColor"; //$NON-NLS-1$
183 
184 	/**
185 	 * A named preference that controls whether the overview ruler shows unknown indicators
186 	 * (value <code>"othersIndicationInOverviewRuler"</code>).
187 	 * <p>
188 	 * The preference value is of type <code>Boolean</code>.
189 	 * </p>
190 	 * @deprecated As of 3.0, there are no UNKNOWN annotations any more
191 	 */
192 	@Deprecated
193 	public final static String EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER= "othersIndicationInOverviewRuler"; //$NON-NLS-1$
194 
195 	/**
196 	 * A named preference that controls if the overview ruler is shown in the UI
197 	 * (value <code>"overviewRuler"</code>).
198 	 * <p>
199 	 * The preference value is of type <code>Boolean</code>.
200 	 * </p>
201 	 */
202 	public final static String EDITOR_OVERVIEW_RULER= "overviewRuler"; //$NON-NLS-1$
203 
204 	/**
205 	 * A named preference that controls if the line number ruler is shown in the UI
206 	 * (value <code>"lineNumberRuler"</code>).
207 	 * <p>
208 	 * The preference value is of type <code>Boolean</code>.
209 	 * </p>
210 	 */
211 	public final static String EDITOR_LINE_NUMBER_RULER= "lineNumberRuler"; //$NON-NLS-1$
212 
213 	/**
214 	 * A named preference that controls if the caret offset is shown in the status line.
215 	 * <p>
216 	 * The preference value is of type <code>Boolean</code>.
217 	 * </p>
218 	 *
219 	 * @since 3.12
220 	 */
221 	public final static String EDITOR_SHOW_CARET_OFFSET= AbstractTextEditor.PREFERENCE_SHOW_CARET_OFFSET;
222 
223 	/**
224 	 * A named preference that controls if the selection size (number of selected characters) is
225 	 * shown in the status line.
226 	 * <p>
227 	 * The preference value is of type <code>Boolean</code>.
228 	 * </p>
229 	 *
230 	 * @since 3.12
231 	 */
232 	public final static String EDITOR_SHOW_SELECTION_SIZE= AbstractTextEditor.PREFERENCE_SHOW_SELECTION_SIZE;
233 
234 	/**
235 	 * A named preference that holds the color used to render line numbers inside the line number
236 	 * ruler (value <code>"lineNumberColor"</code>).
237 	 * <p>
238 	 * The preference value is of type <code>String</code>. A RGB color value encoded as a string
239 	 * using class <code>PreferenceConverter</code>.
240 	 * </p>
241 	 *
242 	 * @see org.eclipse.jface.resource.StringConverter
243 	 * @see PreferenceConverter
244 	 * @see #EDITOR_LINE_NUMBER_RULER
245 	 */
246 	public final static String EDITOR_LINE_NUMBER_RULER_COLOR= "lineNumberColor"; //$NON-NLS-1$
247 
248 	/**
249 	 * A named preference that controls whether this plug-in's
250 	 * Annotations preference page is used to configure annotations.
251 	 * <p>
252 	 * Value is of type <code>boolean</code>.
253 	 * </p>
254 	 */
255 	public static final String USE_ANNOTATIONS_PREFERENCE_PAGE= "useAnnotationsPrefPage"; //$NON-NLS-1$
256 
257 	/**
258 	 * A named preference that controls whether this plug-in's
259 	 * Quick Diff preference page is used to configure Quick Diff.
260 	 * <p>
261 	 * Value is of type <code>boolean</code>.
262 	 * </p>
263 	 */
264 	public static final String USE_QUICK_DIFF_PREFERENCE_PAGE= "useQuickDiffPrefPage"; //$NON-NLS-1$
265 
266 	/**
267 	 * A named preference that controls whether quick diff colors are shown on the line number bar.
268 	 * <p>
269 	 * Value is of type <code>boolean</code>.
270 	 * </p>
271 	 */
272 	public static final String QUICK_DIFF_ALWAYS_ON= "quickdiff.quickDiff"; //$NON-NLS-1$
273 
274 	/**
275 	 * A named preference that controls the default quick diff reference provider.
276 	 * <p>
277 	 * Value is of type <code>String</code>.
278 	 * </p>
279 	 */
280 	public static final String QUICK_DIFF_DEFAULT_PROVIDER= "quickdiff.defaultProvider"; //$NON-NLS-1$
281 
282 	/**
283 	 * A named preference that controls the default quick diff reference provider.
284 	 * <p>
285 	 * Value is of type <code>String</code>.
286 	 * </p>
287 	 */
288 	public static final String QUICK_DIFF_CHARACTER_MODE= "quickdiff.characterMode"; //$NON-NLS-1$
289 
290 	/**
291 	 * A named preference that controls whether custom carets are used in the
292 	 * editor or not.
293 	 * <p>
294 	 * Value is of type <code>Boolean</code>. If <code>false</code>, only
295 	 * the default caret is used in the editor.
296 	 * </p>
297 	 */
298 	public static final String EDITOR_USE_CUSTOM_CARETS= AbstractTextEditor.PREFERENCE_USE_CUSTOM_CARETS;
299 
300 	/**
301 	 * A named preference that controls whether carets are drawn wide or not.
302 	 * <p>
303 	 * Value is of type <code>Boolean</code>. If <code>true</code>, the caret is
304 	 * twice as wide as the default caret.
305 	 * </p>
306 	 */
307 	public static final String EDITOR_WIDE_CARET= AbstractTextEditor.PREFERENCE_WIDE_CARET;
308 
309 	/**
310 	 * A named preference that controls whether to use saturated colors in the overview ruler.
311 	 * <p>
312 	 * Value is of type <code>Boolean</code>. If <code>true</code>, saturated colors are used
313 	 * </p>
314 	 *
315 	 * @since 3.8
316 	 * @see org.eclipse.jface.text.source.IOverviewRulerExtension#setUseSaturatedColors(boolean)
317 	 */
318 	public static final String USE_SATURATED_COLORS_IN_OVERVIEW_RULER= "Accessibility.UseSaturatedColors"; //$NON-NLS-1$;
319 
320 	/**
321 	 * A named preference that holds the color used as the text selection foreground.
322 	 * This value has no effect if the system default color is used.
323 	 * <p>
324 	 * Value is of type <code>String</code>. A RGB color value encoded as a string
325 	 * using class <code>PreferenceConverter</code>
326 	 * </p>
327 	 *
328 	 * @see org.eclipse.jface.resource.StringConverter
329 	 * @see PreferenceConverter
330 	 */
331 	public final static String EDITOR_SELECTION_FOREGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND;
332 
333 	/**
334 	 * A named preference that describes if the system default selection foreground color
335 	 * is used as the text selection foreground.
336 	 * <p>
337 	 * Value is of type <code>Boolean</code>.
338 	 * </p>
339 	 */
340 	public final static String EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT;
341 
342 	/**
343 	 * A named preference that holds the color used as the text selection background.
344 	 * This value has no effect if the system default color is used.
345 	 * <p>
346 	 * Value is of type <code>String</code>. A RGB color value encoded as a string
347 	 * using class <code>PreferenceConverter</code>
348 	 * </p>
349 	 *
350 	 * @see org.eclipse.jface.resource.StringConverter
351 	 * @see PreferenceConverter
352 	 */
353 	public final static String EDITOR_SELECTION_BACKGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND;
354 
355 	/**
356 	 * A named preference that describes if the system default selection background color
357 	 * is used as the text selection background.
358 	 * <p>
359 	 * Value is of type <code>Boolean</code>.
360 	 * </p>
361 	 */
362 	public final static String EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT;
363 
364 	/**
365 	 * A named preference that controls if hyperlinks are turned on or off.
366 	 * <p>
367 	 * Value is of type <code>Boolean</code>.
368 	 * </p>
369 	 *
370 	 * @since 3.1
371 	 */
372 	public static final String EDITOR_HYPERLINKS_ENABLED= AbstractTextEditor.PREFERENCE_HYPERLINKS_ENABLED;
373 
374 	/**
375 	 * A named preference that controls the key modifier for hyperlinks.
376 	 * <p>
377 	 * Value is of type <code>String</code>.
378 	 * </p>
379 	 *
380 	 * @since 3.1
381 	 */
382 	public static final String EDITOR_HYPERLINK_KEY_MODIFIER= AbstractTextEditor.PREFERENCE_HYPERLINK_KEY_MODIFIER;
383 
384 	/**
385 	 * A named preference that controls the key modifier mask for hyperlinks.
386 	 * The value is only used if the value of <code>EDITOR_HYPERLINK_KEY_MODIFIER</code>
387 	 * cannot be resolved to valid SWT modifier bits.
388 	 * <p>
389 	 * Value is of type <code>String</code>.
390 	 * </p>
391 	 *
392 	 * @see #EDITOR_HYPERLINK_KEY_MODIFIER
393 	 * @since 3.1
394 	 */
395 	public static final String EDITOR_HYPERLINK_KEY_MODIFIER_MASK= AbstractTextEditor.PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK;
396 
397 	/**
398 	 * A named preference that holds the color used for hyperlinks.
399 	 * <p>
400 	 * Value is of type <code>String</code>. A RGB color value encoded as a string
401 	 * using class <code>PreferenceConverter</code>
402 	 * </p>
403 	 *
404 	 * @see org.eclipse.jface.resource.StringConverter
405 	 * @see org.eclipse.jface.preference.PreferenceConverter
406 	 * @since 3.1
407 	 */
408 	public final static String EDITOR_HYPERLINK_COLOR= DefaultHyperlinkPresenter.HYPERLINK_COLOR;
409 
410 	/**
411 	 * A named preference that holds the preference whether to use the native link color.
412 	 * <p>
413 	 * The preference value is of type <code>Boolean</code>.
414 	 * </p>
415 	 *
416 	 * @since 3.5
417 	 */
418 	public final static String EDITOR_HYPERLINK_COLOR_SYSTEM_DEFAULT= DefaultHyperlinkPresenter.HYPERLINK_COLOR_SYSTEM_DEFAULT;
419 
420 	/**
421 	 * A named preference that controls disabling of the overwrite mode.
422 	 * <p>
423 	 * Value is of type <code>Boolean</code>.
424 	 * </p>
425 	 * <p>
426 	 * <strong>Note:</strong> As of 3.3, this preference can no longer
427 	 * be set via UI but is still honored by the code. A workspace that
428 	 * was started at least once with 3.3 has this preference set to <code>false</code>.
429 	 * Workspaces started with 3.4 keep their current preference.
430 	 *
431 	 * @since 3.1
432 	 */
433 	public static final String EDITOR_DISABLE_OVERWRITE_MODE= "disable_overwrite_mode"; //$NON-NLS-1$
434 
435 	/**
436 	 * A named preference that controls whether a confirmation
437 	 * dialog is shown before editing derived input.
438 	 * <p>
439 	 * Value is of type <code>Boolean</code>.
440 	 * </p>
441 	 *
442 	 * @since 3.3
443 	 */
444 	public static final String EDITOR_WARN_IF_INPUT_DERIVED= "warn_if_input_derived"; //$NON-NLS-1$
445 
446 	/**
447 	 * A named preference that controls if smart home/end navigation is on or off
448 	 * <p>
449 	 * Value is of type <code>Boolean</code>.
450 	 * </p>
451 	 *
452 	 * @since 3.3
453 	 */
454 	public static final String EDITOR_SMART_HOME_END= AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END;
455 
456 	/**
457 	 * A named preference that controls the display of whitespace characters.
458 	 * <p>
459 	 * Value is of type <code>Boolean</code>.
460 	 * </p>
461 	 *
462 	 * <p>
463 	 * The following preferences can be used for fine-grained configuration when enabled.
464 	 * </p>
465 	 * <ul>
466 	 * <li>{@link #EDITOR_SHOW_LEADING_SPACES}</li>
467 	 * <li>{@link #EDITOR_SHOW_ENCLOSED_SPACES}</li>
468 	 * <li>{@link #EDITOR_SHOW_TRAILING_SPACES}</li>
469 	 * <li>{@link #EDITOR_SHOW_LEADING_IDEOGRAPHIC_SPACES}</li>
470 	 * <li>{@link #EDITOR_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES}</li>
471 	 * <li>{@link #EDITOR_SHOW_TRAILING_IDEOGRAPHIC_SPACES}</li>
472 	 * <li>{@link #EDITOR_SHOW_LEADING_TABS}</li>
473 	 * <li>{@link #EDITOR_SHOW_ENCLOSED_TABS}</li>
474 	 * <li>{@link #EDITOR_SHOW_TRAILING_TABS}</li>
475 	 * <li>{@link #EDITOR_SHOW_CARRIAGE_RETURN}</li>
476 	 * <li>{@link #EDITOR_SHOW_LINE_FEED}</li>
477 	 * <li>{@link #EDITOR_WHITESPACE_CHARACTER_ALPHA_VALUE}</li>
478 	 * </ul>
479 	 *
480 	 * @since 3.3
481 	 */
482 	public static final String EDITOR_SHOW_WHITESPACE_CHARACTERS= AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS;
483 
484 	/**
485 	 * A named preference that controls the display of leading Space characters. The value is used
486 	 * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>.
487 	 * <p>
488 	 * Value is of type <code>Boolean</code>.
489 	 * </p>
490 	 *
491 	 * @since 3.7
492 	 */
493 	public static final String EDITOR_SHOW_LEADING_SPACES= AbstractTextEditor.PREFERENCE_SHOW_LEADING_SPACES;
494 
495 	/**
496 	 * A named preference that controls the display of enclosed Space characters. The value is used
497 	 * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>.
498 	 * <p>
499 	 * Value is of type <code>Boolean</code>.
500 	 * </p>
501 	 *
502 	 * @since 3.7
503 	 */
504 	public static final String EDITOR_SHOW_ENCLOSED_SPACES= AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_SPACES;
505 
506 	/**
507 	 * A named preference that controls the display of trailing Space characters. The value is used
508 	 * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>.
509 	 * <p>
510 	 * Value is of type <code>Boolean</code>.
511 	 * </p>
512 	 *
513 	 * @since 3.7
514 	 */
515 	public static final String EDITOR_SHOW_TRAILING_SPACES= AbstractTextEditor.PREFERENCE_SHOW_TRAILING_SPACES;
516 
517 	/**
518 	 * A named preference that controls the display of leading Ideographic Space characters. The
519 	 * value is used only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is
520 	 * <code>true</code>.
521 	 * <p>
522 	 * Value is of type <code>Boolean</code>.
523 	 * </p>
524 	 *
525 	 * @since 3.7
526 	 */
527 	public static final String EDITOR_SHOW_LEADING_IDEOGRAPHIC_SPACES= AbstractTextEditor.PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES;
528 
529 	/**
530 	 * A named preference that controls the display of enclosed Ideographic Space characters. The
531 	 * value is used only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is
532 	 * <code>true</code>.
533 	 * <p>
534 	 * Value is of type <code>Boolean</code>.
535 	 * </p>
536 	 *
537 	 * @since 3.7
538 	 */
539 	public static final String EDITOR_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES= AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES;
540 
541 	/**
542 	 * A named preference that controls the display of trailing Ideographic Space characters. The
543 	 * value is used only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is
544 	 * <code>true</code>.
545 	 * <p>
546 	 * Value is of type <code>Boolean</code>.
547 	 * </p>
548 	 *
549 	 * @since 3.7
550 	 */
551 	public static final String EDITOR_SHOW_TRAILING_IDEOGRAPHIC_SPACES= AbstractTextEditor.PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES;
552 
553 	/**
554 	 * A named preference that controls the display of leading Tab characters. The value is used
555 	 * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>.
556 	 * <p>
557 	 * Value is of type <code>Boolean</code>.
558 	 * </p>
559 	 *
560 	 * @since 3.7
561 	 */
562 	public static final String EDITOR_SHOW_LEADING_TABS= AbstractTextEditor.PREFERENCE_SHOW_LEADING_TABS;
563 
564 	/**
565 	 * A named preference that controls the display of enclosed Tab characters. The value is used
566 	 * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>.
567 	 * <p>
568 	 * Value is of type <code>Boolean</code>.
569 	 * </p>
570 	 *
571 	 * @since 3.7
572 	 */
573 	public static final String EDITOR_SHOW_ENCLOSED_TABS= AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_TABS;
574 
575 	/**
576 	 * A named preference that controls the display of trailing Tab characters. The value is used
577 	 * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>.
578 	 * <p>
579 	 * Value is of type <code>Boolean</code>.
580 	 * </p>
581 	 *
582 	 * @since 3.7
583 	 */
584 	public static final String EDITOR_SHOW_TRAILING_TABS= AbstractTextEditor.PREFERENCE_SHOW_TRAILING_TABS;
585 
586 	/**
587 	 * A named preference that controls the display of Carriage Return characters. The value is used
588 	 * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>.
589 	 * <p>
590 	 * Value is of type <code>Boolean</code>.
591 	 * </p>
592 	 *
593 	 * @since 3.7
594 	 */
595 	public static final String EDITOR_SHOW_CARRIAGE_RETURN= AbstractTextEditor.PREFERENCE_SHOW_CARRIAGE_RETURN;
596 
597 	/**
598 	 * A named preference that controls the display of Line Feed characters. The value is used only
599 	 * if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>.
600 	 * <p>
601 	 * Value is of type <code>Boolean</code>.
602 	 * </p>
603 	 *
604 	 * @since 3.7
605 	 */
606 	public static final String EDITOR_SHOW_LINE_FEED= AbstractTextEditor.PREFERENCE_SHOW_LINE_FEED;
607 
608 	/**
609 	 * A named preference that controls the alpha value of whitespace characters. The value is used
610 	 * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>.
611 	 * <p>
612 	 * Value is of type <code>Integer</code>.
613 	 * </p>
614 	 *
615 	 * @since 3.7
616 	 */
617 	public static final String EDITOR_WHITESPACE_CHARACTER_ALPHA_VALUE= AbstractTextEditor.PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE;
618 
619 	/**
620 	 * A named preference that controls the display of the range indicator.
621 	 * <p>
622 	 * Value is of type <code>Boolean</code>.
623 	 * </p>
624 	 *
625 	 * @since 3.1
626 	 */
627 	public static final String SHOW_RANGE_INDICATOR= "show_range_indicator"; //$NON-NLS-1$
628 
629 	/**
630 	 * A named preference that controls whether the user is asked before switching the quick diff
631 	 * reference when showing revision information..
632 	 * <p>
633 	 * Value is of type <code>String</code>.
634 	 * </p>
635 	 *
636 	 * @since 3.2
637 	 */
638 	public static final String REVISION_ASK_BEFORE_QUICKDIFF_SWITCH= "quickdiff.nowarn.before.switch"; //$NON-NLS-1$
639 
640 	/**
641 	 * A named preference that controls the rendering mode of the revision ruler.
642 	 * <p>
643 	 * Value is of type <code>String</code> and should contain the name of a
644 	 * {@link org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension.RenderingMode}.
645 	 * </p>
646 	 *
647 	 * @since 3.3
648 	 */
649 	public static final String REVISION_RULER_RENDERING_MODE= "revisionRulerRenderingMode"; //$NON-NLS-1$
650 
651 	/**
652 	 * A named preference that controls the rendering of the author on the revision ruler.
653 	 * <p>
654 	 * Value is of type <code>Boolean</code>.
655 	 * </p>
656 	 *
657 	 * @since 3.3
658 	 */
659 	public static final String REVISION_RULER_SHOW_AUTHOR= "revisionRulerShowAuthor"; //$NON-NLS-1$
660 
661 	/**
662 	 * A named preference that controls rendering of the revision on the revision ruler.
663 	 * <p>
664 	 * Value is of type <code>Boolean</code>.
665 	 * </p>
666 	 *
667 	 * @since 3.3
668 	 */
669 	public static final String REVISION_RULER_SHOW_REVISION= "revisionRulerShowRevision"; //$NON-NLS-1$
670 
671 	/**
672 	 * A named preference that controls whether text drag and drop is enabled.
673 	 * <p>
674 	 * Value is of type <code>Boolean</code>.
675 	 * </p>
676 	 *
677 	 * @since 3.3
678 	 */
679 	public static final String EDITOR_TEXT_DRAG_AND_DROP_ENABLED= AbstractTextEditor.PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED;
680 
681 	/**
682 	 * A named preference that defines whether the hint to make hover sticky should be shown.
683 	 * <p>
684 	 * Value is of type <code>Boolean</code>.
685 	 * </p>
686 	 *
687 	 * @since 3.3
688 	 */
689 	public static final String EDITOR_SHOW_TEXT_HOVER_AFFORDANCE= "showTextHoverAffordance"; //$NON-NLS-1$
690 
691 	/**
692 	 * A named preference that controls if hovers should automatically be closed
693 	 * when the mouse is moved into them, or when they should be enriched.
694 	 * <p>
695 	 * Value is of type <code>Integer</code> and maps to the following
696 	 * {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode}:
697 	 * </p>
698 	 * <ul>
699 	 * <li>-1: <code>null</code> (don't allow moving the mouse into a hover),</li>
700 	 * <li>0: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#AFTER_DELAY},</li>
701 	 * <li>1: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#IMMEDIATELY},</li>
702 	 * <li>2: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#ON_CLICK}.</li>
703 	 * </ul>
704 	 *
705 	 * @since 3.4
706 	 */
707 	public static final String EDITOR_HOVER_ENRICH_MODE= AbstractTextEditor.PREFERENCE_HOVER_ENRICH_MODE;
708 
709 	/**
710 	* Initializes the given preference store with the default values.
711 	 *
712 	* @param store the preference store to be initialized
713 	*/
initializeDefaultValues(IPreferenceStore store)714 	public static void initializeDefaultValues(IPreferenceStore store) {
715 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.USE_ANNOTATIONS_PREFERENCE_PAGE, false);
716 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE, false);
717 
718 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, true);
719 
720 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 4);
721 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, false);
722 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_DELETE_SPACES_AS_TABS, false);
723 
724 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNDO_HISTORY_SIZE, 200);
725 
726 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, false);
727 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 80);
728 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_ALLOW_OVERRIDE, false);
729 
730 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, false);
731 
732 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_CARET_OFFSET, true);
733 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_SELECTION_SIZE, true);
734 
735 		if (!store.getBoolean(USE_QUICK_DIFF_PREFERENCE_PAGE)) {
736 			store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON, true);
737 			store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE, false);
738 			store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER, "org.eclipse.ui.internal.editors.quickdiff.LastSaveReferenceProvider"); //$NON-NLS-1$
739 		}
740 
741 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, true);
742 
743 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION, false);
744 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER, false);
745 		PreferenceConverter.setDefault(store, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR, new RGB(0, 0, 0));
746 
747 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS, false);
748 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET, true);
749 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.USE_SATURATED_COLORS_IN_OVERVIEW_RULER, false);
750 
751 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR, true);
752 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR, true);
753 
754 		store.setDefault(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, true);
755 
756 		store.setDefault(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, true);
757 
758 		String mod1Name= Action.findModifierString(SWT.MOD1);	// SWT.COMMAND on MAC; SWT.CONTROL elsewhere
759 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED, true);
760 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_COLOR_SYSTEM_DEFAULT, true);
761 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER, mod1Name);
762 		store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER_MASK, SWT.MOD1);
763 
764 		HyperlinkDetectorDescriptor[] descriptors= EditorsUI.getHyperlinkDetectorRegistry().getHyperlinkDetectorDescriptors();
765 		for (HyperlinkDetectorDescriptor descriptor : descriptors) {
766 			int stateMask = computeStateMask(descriptor.getModifierKeys());
767 			if (stateMask == SWT.SHIFT) {
768 				EditorsPlugin.logErrorMessage("The '" + descriptor.getId() + "' hyperlink detector specifies 'Shift' as modifier. This is not allowed and hence replaced with the default modifier."); //$NON-NLS-1$ //$NON-NLS-2$
769 				stateMask= -1;
770 			}
771 			store.setDefault(descriptor.getId() + HyperlinkDetectorDescriptor.STATE_MASK_POSTFIX, stateMask);
772 		}
773 
774 		boolean isInstalled= EditorsUI.getSpellingService().getSpellingEngineDescriptors().length > 0;
775 		store.setDefault(SpellingService.PREFERENCE_SPELLING_ENABLED, isInstalled);
776 		store.setDefault(SpellingService.PREFERENCE_SPELLING_ENGINE, ""); //$NON-NLS-1$
777 
778 		store.setDefault(SHOW_RANGE_INDICATOR, true);
779 		store.setDefault(REVISION_ASK_BEFORE_QUICKDIFF_SWITCH, MessageDialogWithToggle.ALWAYS);
780 
781 		store.setDefault(AbstractTextEditor.PREFERENCE_RULER_CONTRIBUTIONS, ""); //$NON-NLS-1$
782 		store.setDefault(REVISION_RULER_RENDERING_MODE, IRevisionRulerColumnExtension.AGE.name());
783 		store.setDefault(REVISION_RULER_SHOW_AUTHOR, false);
784 		store.setDefault(REVISION_RULER_SHOW_REVISION, false);
785 
786 		store.setDefault(EDITOR_WARN_IF_INPUT_DERIVED, true);
787 		store.setDefault(EDITOR_SMART_HOME_END, true);
788 
789 		store.setDefault(EDITOR_SHOW_WHITESPACE_CHARACTERS, false);
790 		store.setDefault(EDITOR_SHOW_LEADING_SPACES, true);
791 		store.setDefault(EDITOR_SHOW_ENCLOSED_SPACES, true);
792 		store.setDefault(EDITOR_SHOW_TRAILING_SPACES, true);
793 		store.setDefault(EDITOR_SHOW_LEADING_IDEOGRAPHIC_SPACES, true);
794 		store.setDefault(EDITOR_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES, true);
795 		store.setDefault(EDITOR_SHOW_TRAILING_IDEOGRAPHIC_SPACES, true);
796 		store.setDefault(EDITOR_SHOW_LEADING_TABS, true);
797 		store.setDefault(EDITOR_SHOW_ENCLOSED_TABS, true);
798 		store.setDefault(EDITOR_SHOW_TRAILING_TABS, true);
799 		store.setDefault(EDITOR_SHOW_CARRIAGE_RETURN, true);
800 		store.setDefault(EDITOR_SHOW_LINE_FEED, true);
801 		store.setDefault(EDITOR_WHITESPACE_CHARACTER_ALPHA_VALUE, 80);
802 
803 		store.setDefault(EDITOR_TEXT_DRAG_AND_DROP_ENABLED, true);
804 		store.setDefault(EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true);
805 		store.setDefault(EDITOR_HOVER_ENRICH_MODE, 0);
806 		store.setDefault(AbstractTextEditor.PREFERENCE_WORD_WRAP_ENABLED, false);
807 
808 		MarkerAnnotationPreferences.initializeDefaultValues(store);
809 
810 		EditorsPluginPreferenceInitializer.setThemeBasedPreferences(store, false);
811 	}
812 
813 	/**
814 	 * Computes the state mask out of the given modifiers string.
815 	 *
816 	 * @param modifiers a string containing modifiers
817 	 * @return the state mask
818 	 * @since 3.3
819 	 */
computeStateMask(String modifiers)820 	private static final int computeStateMask(String modifiers) {
821 		if (modifiers == null)
822 			return -1;
823 
824 		if (modifiers.isEmpty())
825 			return SWT.NONE;
826 
827 		int stateMask= 0;
828 		StringTokenizer modifierTokenizer= new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
829 		while (modifierTokenizer.hasMoreTokens()) {
830 			int modifier= findLocalizedModifier(modifierTokenizer.nextToken());
831 			if (modifier == 0 || (stateMask & modifier) == modifier)
832 				return -1;
833 			stateMask= stateMask | modifier;
834 		}
835 		return stateMask;
836 	}
837 
838 	/**
839 	 * Maps the localized modifier name to a code in the same
840 	 * manner as #findModifier.
841 	 *
842 	 * @param modifierName the modifier name
843 	 * @return the SWT modifier bit, or <code>0</code> if no match was found
844 	 * @since 3.3
845 	 */
findLocalizedModifier(String modifierName)846 	private static final int findLocalizedModifier(String modifierName) {
847 		if (modifierName == null)
848 			return SWT.NONE;
849 
850 		if (modifierName.equalsIgnoreCase("M1")) //$NON-NLS-1$
851 			return SWT.MOD1;
852 		if (modifierName.equalsIgnoreCase("M2")) //$NON-NLS-1$
853 			return SWT.MOD2;
854 		if (modifierName.equalsIgnoreCase("M3")) //$NON-NLS-1$
855 			return SWT.MOD3;
856 		if (modifierName.equalsIgnoreCase("M4")) //$NON-NLS-1$
857 			return SWT.MOD4;
858 		if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.CTRL)))
859 			return SWT.CTRL;
860 		if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.SHIFT)))
861 			return SWT.SHIFT;
862 		if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.ALT)))
863 			return SWT.ALT;
864 		if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.COMMAND)))
865 			return SWT.COMMAND;
866 
867 		return SWT.NONE;
868 	}
869 
870 }
871