Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9caa7aca1d92c11efbb3a385d684f1cfb9374b1d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
/*******************************************************************************
 * Copyright (c) 2000, 2003 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.ui.texteditor;

import org.eclipse.swt.graphics.RGB;


/**
 * An annotation preference provides all the information required for handing the preferences for the presentation of annotations of a specified type.
 * The provided information covers:
 * <ul>
 * <li> the preference key for the presentation  color
 * <li> the default presentation color
 * <li> the preference key for the visibility of annotations inside text
 * <li> the default visibility of annotations inside text
 * <li> the preference key for the visibility of annotations inside the overview ruler
 * <li> the default visibility of annotations inside the overview ruler
 * <li> the presentation layer
 * <li> how the annotation type should be presented on a preference page
 * <li> whether the annotation type should be presented in the header of the overview ruler
 * <li> the marker type if the annotation type is derived from an <code>IMarker</code>
 * <li> the severity of the marker if the annotation type is derived from an <code>IMarker</code>
 * <li> the preference key for the visibility in the next/previous navigation toolbar drop down action
 * <li> the default value for the visibility in the next/previous navigation toolbar drop down action
 * <li> the preference key for go to next navigation enablement
 * <li> the default value for go to next navigation enablement
 * <li> the preference key for got to previous navigation enablement
 * <li> the default value for got to previous navigation enablement
 * </ul>
 * 
 * @since 2.1
 */
public class AnnotationPreference {
	
	/** The annotation type */
	private Object fAnnotationType;
	/** The preference label */
	private String fPreferenceLabel;
	/** The marker type */
	private String fMarkerType;
	/** The marker severity */
	private int fSeverity;
	/** The preference key for the presentation color */
	private String fColorKey;
	/** The default presentation color */
	private RGB fColorValue;
	/** The preference key for the visibility inside text */
	private String fTextKey;
	/** The default visibility inside text */
	private boolean fTextValue;
	/** The preference key for the visibility in the overview ruler */
	private String fOverviewRulerKey;
	/** The default visibility in the overview ruler */
	private boolean fOverviewRulerValue;
	/** The presentation layer */
	private int fPresentationLayer;
	/** Indicates whether the annotation type contributed to the overview ruler's header */
	private boolean fContributesToHeader;
	/**
	 * The preference key for highlighting inside text.
	 * @since 3.0
	 */
	private String fHighlightKey;
	/**
	 * The default value for highlighting inside text.
	 * @since 3.0
	 */
	private boolean fHighlightValue;
	/**
	 * The preference key for the visibility in the vertical ruler.
	 * @since 3.0
	 */
	private String fVerticalRulerKey;
	/**
	 * The default visibility in the vertical ruler.
	 * @since 3.0
	 */
	private boolean fVerticalRulerValue;
	/**
	 * The preference key for the visibility in the next/previous drop down toolbar action.
	 * @since 3.0
	 */
	private String fShowInNextPrevDropdownToolbarActionKey;
	/**
	 * The default value for the visibility in the next/previous drop down toolbar action.
	 * @since 3.0
	 */
	private boolean fShowInNextPrevDropdownToolbarAction;
	/**
	 * The preference key for go to next navigation enablement.
	 * @since 3.0
	 */
	private String fIsGoToNextNavigationTargetKey;
	/**
	 * The default value for go to next navigation enablement.
	 * @since 3.0
	 */
	private boolean fIsGoToNextNavigationTarget;
	/**
	 * The preference key for go to previous navigation enablement.
	 * @since 3.0
	 */
	private String fIsGoToPreviousNavigationTargetKey;
	/**
	 * The default value for go to previous navigation enablement.
	 * @since 3.0
	 */
	private boolean fIsGoToPreviousNavigationTarget;
	

	/**
	 * Creates a new uninitialized annotation preference.
	 */
	public AnnotationPreference() {
	}
		
	/**
	 * Creates a new annotation preference for the given annotation type.
	 * 
	 * @param annotationType the annotation type
	 * @param colorKey the preference key for the presentation color
	 * @param textKey the preference key for the visibility inside text
	 * @param overviewRulerKey the preference key for the visibility in the overview ruler
	 * @param presentationLayer the presentation layer
	 */
	public AnnotationPreference(Object annotationType, String colorKey, String textKey, String overviewRulerKey, int presentationLayer) {
		fAnnotationType= annotationType;
		fColorKey= colorKey;
		fTextKey= textKey;
		fOverviewRulerKey= overviewRulerKey;
		fPresentationLayer= presentationLayer;
	}
	
	/**
	 * Returns whether the given string is a preference key.
	 * 
	 * @param key the string to test
	 * @return <code>true</code> if the string is a preference key
	 */
	public boolean isPreferenceKey(String key) {
		if (key == null)
			return false;
		return key.equals(fColorKey) || key.equals(fOverviewRulerKey) || key.equals(fTextKey) || key.equals(fHighlightKey) || key.equals(fVerticalRulerKey);
	}
	
	/**
	 * Returns the annotation type.
	 * 
	 * @return the annotation type
	 */
	public Object getAnnotationType() {
		return fAnnotationType;
	}
	
	/**
	 * Returns the marker type.
	 * 
	 * @return the marker type
	 */
	public String getMarkerType() {
		return fMarkerType;
	}

	/**
	 * Returns the preference key for the presentation color.
	 * 
	 * @return the preference key for the presentation color
	 */
	public String getColorPreferenceKey() {
		return fColorKey;
	}
	
	/**
	 * Returns the default presentation color.
	 * 
	 * @return the default presentation color.
	 */
	public RGB getColorPreferenceValue() {
		return fColorValue;
	}
	
	/**
	 * Returns the presentation string for this annotation type.
	 * 
	 * @return the presentation string for this annotation type
	 */
	public String getPreferenceLabel() {
		return fPreferenceLabel;
	}

	/**
	 * Returns the preference key for the visibility in the overview ruler.
	 * 
	 * @return the preference key for the visibility in the overview ruler
	 */
	public String getOverviewRulerPreferenceKey() {
		return fOverviewRulerKey;
	}
	
	/**
	 * Returns the default visibility in the overview ruler.
	 * 
	 * @return the default visibility in the overview ruler
	 */
	public boolean getOverviewRulerPreferenceValue() {
		return fOverviewRulerValue;
	}
	
	/**
	 * Returns the preference key for the visibility in the vertical ruler.
	 * 
	 * @return the preference key for the visibility in the vertical ruler
	 * @since 3.0
	 */
	public String getVerticalRulerPreferenceKey() {
		return fVerticalRulerKey;
	}
	
	/**
	 * Returns the default visibility in the vertical ruler.
	 * 
	 * @return the default visibility in the vertical ruler
	 * @since 3.0
	 */
	public boolean getVerticalRulerPreferenceValue() {
		return fVerticalRulerValue;
	}
	
	/**
	 * Returns the presentation layer.
	 * 
	 * @return the presentation layer
	 */
	public int getPresentationLayer() {
		return fPresentationLayer;
	}

	/**
	 * Returns the marker severity.
	 * 
	 * @return the marker severity
	 */
	public int getSeverity() {
		return fSeverity;
	}

	/**
	 * Returns the preference key for the visibility inside text.
	 * 
	 * @return the preference key for the visibility inside text
	 */
	public String getTextPreferenceKey() {
		return fTextKey;
	}

	/**
	 * Returns the default visibility inside text.
	 * 
	 * @return the default visibility inside text
	 */
	public boolean getTextPreferenceValue() {
		return fTextValue;
	}
	
	/**
	 * Returns the preference key for highlighting inside text.
	 * 
	 * @return the preference key for highlighting inside text
	 * @since 3.0
	 */
	public String getHighlightPreferenceKey() {
		return fHighlightKey;
	}

	/**
	 * Returns the default value for highlighting inside text.
	 * 
	 * @return the default value for highlighting inside text
	 * @since 3.0
	 */
	public boolean getHighlightPreferenceValue() {
		return fHighlightValue;
	}
		
	/**
	 * Returns whether the annotation type contributes to the header of the overview ruler.
	 * 
	 * @return <code>true</code> if the annotation type contributes to the header of the overview ruler
	 */
	public boolean contributesToHeader() {
		return fContributesToHeader;
	}
	
	/**
	 * Sets the annotation type.
	 * 
	 * @param annotationType the annotation type
	 */
	public void setAnnotationType(Object annotationType) {
		fAnnotationType= annotationType;
	}
	
	/**
	 * Sets the marker type.
	 * 
	 * @param markerType the marker type
	 */
	public void setMarkerType(String markerType) {
		fMarkerType= markerType;
	}
	
	/**
	 * Sets the preference key for the presentation color.
	 * 
	 * @param colorKey the preference key
	 */
	public void setColorPreferenceKey(String colorKey) {
		fColorKey= colorKey;
	}

	/**
	 * Sets the default presentation color.
	 * 
	 * @param colorValue the default color
	 */
	public void setColorPreferenceValue(RGB colorValue) {
		fColorValue= colorValue;
	}
	
	/**
	 * Sets the presentation label of this annotation type.
	 * 
	 * @param label the presentation label
	 */
	public void setPreferenceLabel(String label) {
		fPreferenceLabel= label;
	}

	/**
	 * Sets the preference key for the visibility in the overview ruler.
	 * 
	 * @param overviewRulerKey the preference key
	 */
	public void setOverviewRulerPreferenceKey(String overviewRulerKey) {
		fOverviewRulerKey= overviewRulerKey;
	}
	
	/**
	 * Sets the default visibility in the overview ruler.
	 * 
	 * @param overviewRulerValue <code>true</code> if visible by default, <code>false</code> otherwise
	 */
	public void setOverviewRulerPreferenceValue(boolean overviewRulerValue) {
		fOverviewRulerValue= overviewRulerValue;
	}
	
	/**
	 * Sets the preference key for the visibility in the vertical ruler.
	 * 
	 * @param verticalRulerKey the preference key
	 * @since 3.0
	 */
	public void setVerticalRulerPreferenceKey(String verticalRulerKey) {
		fVerticalRulerKey= verticalRulerKey;
	}
	
	/**
	 * Sets the default visibility in the vertical ruler.
	 * 
	 * @param verticalRulerValue <code>true</code> if visible by default, <code>false</code> otherwise
	 * @since 3.0
	 */
	public void setVerticalRulerPreferenceValue(boolean verticalRulerValue) {
		fVerticalRulerValue= verticalRulerValue;
	}
	
	/**
	 * Sets the presentation layer.
	 * 
	 * @param presentationLayer the presentation layer
	 */
	public void setPresentationLayer(int presentationLayer) {
		fPresentationLayer= presentationLayer;
	}
	
	/**
	 * Sets the marker serverity.
	 * 
	 * @param severity the marker severity
	 */
	public void setSeverity(int severity) {
		fSeverity= severity;
	}

	/**
	 * Sets the preference key for the visibility of squiggles inside text.
	 * 
	 * @param textKey the preference key
	 */
	public void setTextPreferenceKey(String textKey) {
		fTextKey= textKey;
	}

	/**
	 * Sets the default visibility inside text.
	 * 
	 * @param textValue <code>true</code> if visible by default, <code>false</code> otherwise
	 */
	public void setTextPreferenceValue(boolean textValue) {
		fTextValue= textValue;
	}
	
	/**
	 * Sets the preference key for highlighting inside text.
	 * 
	 * @param highlightKey the preference key
	 * @since 3.0
	 */
	public void setHighlightPreferenceKey(String highlightKey) {
		fHighlightKey= highlightKey;
	}
	
	/**
	 * Sets the default value for highlighting inside text.
	 * 
	 * @param highlightValue <code>true</code> if highlighted in text by default, <code>false</code> otherwise
	 * @since 3.0
	 */
	public void setHighlightPreferenceValue(boolean highlightValue) {
		fHighlightValue= highlightValue;
	}
	
	/**
	 * Sets whether the annotation type contributes to the overview ruler's header.
	 * 
	 * @param contributesToHeader <code>true</code> if in header, <code>false</code> otherwise
	 */
	public void setContributesToHeader(boolean contributesToHeader) {
		fContributesToHeader= contributesToHeader;
	}
	
	/**
	 * Returns the default value for go to next navigation enablement.
	 * 
	 * @return <code>true</code> if enabled by default
	 * @since 3.0
	 */
	public boolean isGoToNextNavigationTarget() {
		return fIsGoToNextNavigationTarget;
	}

	/**
	 * Sets the default value for go to next navigation enablement.
	 * 
	 * @param isGoToNextNavigationTarget <code>true</code> if enabled by default
	 * @since 3.0
	 */
	public void setIsGoToNextNavigationTarget(boolean isGoToNextNavigationTarget) {
		fIsGoToNextNavigationTarget= isGoToNextNavigationTarget;
	}

	/**
	 * Returns the preference key for go to next navigation enablement.
	 * 
	 * @return the preference key or <code>null</code> if the key is undefined
	 * @since 3.0
	 */
	public String getIsGoToNextNavigationTargetKey() {
		return fIsGoToNextNavigationTargetKey;
	}

	/**
	 * Sets the preference key for go to next navigation enablement.
	 * 
	 * @param isGoToNextNavigationTargetKey <code>true</code> if enabled by default
	 * @since 3.0
	 */
	public void setIsGoToNextNavigationTargetKey(String isGoToNextNavigationTargetKey) {
		fIsGoToNextNavigationTargetKey= isGoToNextNavigationTargetKey;
	}

	/**
	 * Returns the default value for go to previous navigation enablement.
	 * 
	 * @return <code>true</code> if enabled by default
	 * @since 3.0
	 */
	public boolean isGoToPreviousNavigationTarget() {
		return fIsGoToPreviousNavigationTarget;
	}

	/**
	 * Sets the default value for go to previous navigation enablement.
	 * 
	 * @param isGoToPreviousNavigationTarget <code>true</code> if enabled by default
	 * @since 3.0
	 */
	public void setIsGoToPreviousNavigationTarget(boolean isGoToPreviousNavigationTarget) {
		fIsGoToPreviousNavigationTarget= isGoToPreviousNavigationTarget;
	}

	/**
	 * Returns the preference key for go to previous navigation enablement.
	 * 
	 * @return the preference key or <code>null</code> if the key is undefined
	 * @since 3.0
	 */
	public String getIsGoToPreviousNavigationTargetKey() {
		return fIsGoToPreviousNavigationTargetKey;
	}

	/**
 	 * Sets the preference key for go to previous navigation enablement.
 	 * 
 	 * @param isGoToPreviousNavigationTargetKey the preference key
	 * @since 3.0
	 */
	public void setIsGoToPreviousNavigationTargetKey(String isGoToPreviousNavigationTargetKey) {
		fIsGoToPreviousNavigationTargetKey= isGoToPreviousNavigationTargetKey;
	}

	/**	
	 * Returns the preference key for the visibility in the next/previous drop down toolbar action.
	 * 
	 * @return the preference key or <code>null</code> if the key is undefined
	 * @since 3.0
	 */
	public String getShowInNextPrevDropdownToolbarActionKey() {
		return fShowInNextPrevDropdownToolbarActionKey;
	}

	/**
	 * Sets the preference key for the visibility in the next/previous drop down toolbar action.
	 * 
	 * @param showInNextPrevDropdownToolbarActionKey the preference key
	 * @since 3.0
	 */
	public void setShowInNextPrevDropdownToolbarActionKey(String showInNextPrevDropdownToolbarActionKey) {
		fShowInNextPrevDropdownToolbarActionKey= showInNextPrevDropdownToolbarActionKey;
	}
	
	/**
	 * Returns the default value for the visibility in the next/previous drop down toolbar action.
	 * 
	 * @return <code>true</code> if enabled by default
	 * @since 3.0
	 */
	public boolean isShowInNextPrevDropdownToolbarAction() {
		return fShowInNextPrevDropdownToolbarAction;
	}

	/**
	 * Sets the default value for the visibility in the next/previous drop down toolbar action.
	 * 
	 * @param showInNextPrevDropdownToolbarAction <code>true</code> if enabled by default
	 * @since 3.0
	 */
	public void setShowInNextPrevDropdownToolbarAction(boolean showInNextPrevDropdownToolbarAction) {
		fShowInNextPrevDropdownToolbarAction= showInNextPrevDropdownToolbarAction;
	}
}

Back to the top