Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7397f01e33e0a0d1800fe3b719994fae190c92dc (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, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.ui.texteditor;

import java.net.URL;
import com.ibm.icu.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

import org.osgi.framework.Bundle;

import org.eclipse.swt.graphics.RGB;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;

import org.eclipse.core.resources.IMarker;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.StringConverter;

import org.eclipse.ui.editors.text.EditorsUI;

import org.eclipse.ui.internal.editors.text.EditorsPlugin;


/**
 * Objects of this class provide access to all extensions declared for the <code>markerAnnotationSpecification</code> extension point.
 * The extensions are represented as instances of {@link org.eclipse.ui.texteditor.AnnotationPreference}.
 *
 * @since 2.1
 */
public class MarkerAnnotationPreferences {

	/**
	 * Initializes the given preference store with the default marker annotation values.
	 *
	 * @param store the preference store to be initialized
	 * @since 3.0
	 */
	public static void initializeDefaultValues(IPreferenceStore store) {

		boolean ignoreAnnotationsPrefPage= store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.USE_ANNOTATIONS_PREFERENCE_PAGE);
		boolean ignoreQuickDiffPrefPage= store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE);

		MarkerAnnotationPreferences preferences= EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
		Iterator e= preferences.getAnnotationPreferences().iterator();
		while (e.hasNext()) {
			AnnotationPreference info= (AnnotationPreference) e.next();

			if (ignoreAnnotationsPrefPage && info.isIncludeOnPreferencePage() && isComplete(info))
				continue;

			if (ignoreQuickDiffPrefPage && (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange") //$NON-NLS-1$
					|| (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) //$NON-NLS-1$
					|| (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffDeletion")) //$NON-NLS-1$
				))
				continue;

			store.setDefault(info.getTextPreferenceKey(), info.getTextPreferenceValue());
			store.setDefault(info.getOverviewRulerPreferenceKey(), info.getOverviewRulerPreferenceValue());
			if (info.getVerticalRulerPreferenceKey() != null)
				store.setDefault(info.getVerticalRulerPreferenceKey(), info.getVerticalRulerPreferenceValue());
			PreferenceConverter.setDefault(store, info.getColorPreferenceKey(), info.getColorPreferenceValue());
			if (info.getShowInNextPrevDropdownToolbarActionKey() != null)
				store.setDefault(info.getShowInNextPrevDropdownToolbarActionKey(), info.isShowInNextPrevDropdownToolbarAction());
			if (info.getIsGoToNextNavigationTargetKey() != null)
				store.setDefault(info.getIsGoToNextNavigationTargetKey(), info.isGoToNextNavigationTarget());
			if (info.getIsGoToPreviousNavigationTargetKey() != null)
				store.setDefault(info.getIsGoToPreviousNavigationTargetKey(), info.isGoToPreviousNavigationTarget());
			if (info.getHighlightPreferenceKey() != null)
				store.setDefault(info.getHighlightPreferenceKey(), info.getHighlightPreferenceValue());
			if (info.getTextStylePreferenceKey() != null)
				store.setDefault(info.getTextStylePreferenceKey(), info.getTextStyleValue());
		}
	}

	/**
	 * Removes the marker annotation values which are shown on the
	 * general Annotations page  from the given store and prevents
	 * setting the default values in the future.
	 * <p>
	 * Note: In order to work this method must be called before any
	 *       call to {@link #initializeDefaultValues(IPreferenceStore)}
	 * </p>
	 * <p>
	 * This method is not part of the API and must only be called
	 * by {@link org.eclipse.ui.editors.text.EditorsUI}
	 * </p>
	 *
	 * @param store the preference store to be initialized
	 * @throws IllegalStateException if not called by {@link org.eclipse.ui.editors.text.EditorsUI}
	 * @since 3.0
	 */
	public static void useAnnotationsPreferencePage(IPreferenceStore store) throws IllegalStateException {
		checkAccess();

		store.putValue(AbstractDecoratedTextEditorPreferenceConstants.USE_ANNOTATIONS_PREFERENCE_PAGE, Boolean.toString(true));

		MarkerAnnotationPreferences preferences= EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
		Iterator e= preferences.getAnnotationPreferences().iterator();
		while (e.hasNext()) {
			AnnotationPreference info= (AnnotationPreference) e.next();

			// Only reset annotations shown on Annotations preference page
			if (!info.isIncludeOnPreferencePage() || !isComplete(info))
				continue;

			store.setToDefault(info.getTextPreferenceKey());
			store.setToDefault(info.getOverviewRulerPreferenceKey());
			if (info.getVerticalRulerPreferenceKey() != null)
				store.setToDefault(info.getVerticalRulerPreferenceKey());
			store.setToDefault(info.getColorPreferenceKey());
			if (info.getShowInNextPrevDropdownToolbarActionKey() != null)
				store.setToDefault(info.getShowInNextPrevDropdownToolbarActionKey());
			if (info.getIsGoToNextNavigationTargetKey() != null)
				store.setToDefault(info.getIsGoToNextNavigationTargetKey());
			if (info.getIsGoToPreviousNavigationTargetKey() != null)
				store.setToDefault(info.getIsGoToPreviousNavigationTargetKey());
			if (info.getHighlightPreferenceKey() != null)
				store.setToDefault(info.getHighlightPreferenceKey());
			if (info.getTextStylePreferenceKey() != null)
				store.setToDefault(info.getTextStylePreferenceKey());
		}
	}

	/**
	 * Removes the Quick Diff marker annotation values which are shown on the
	 * general Quick Diff page from the given store and prevents
	 * setting the default values in the future.
	 * <p>
	 * Note: In order to work this method must be called before any
	 *       call to {@link #initializeDefaultValues(IPreferenceStore)}
	 * </p>
	 * <p>
	 * This method is not part of the API and must only be called
	 * by {@link EditorsUI}
	 * </p>
	 *
	 * @param store the preference store to be initialized
	 * @throws IllegalStateException if not called by {@link EditorsUI}
	 * @since 3.0
	 */
	public static void useQuickDiffPreferencePage(IPreferenceStore store) throws IllegalStateException {
		checkAccess();

		store.putValue(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE, Boolean.toString(true));

		MarkerAnnotationPreferences preferences= EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
		Iterator e= preferences.getAnnotationPreferences().iterator();
		while (e.hasNext()) {
			AnnotationPreference info= (AnnotationPreference) e.next();

			// Only reset annotations shown on Quick Diff preference page

			if (!(info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange") //$NON-NLS-1$
				|| (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) //$NON-NLS-1$
				|| (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffDeletion")) //$NON-NLS-1$
			))
				continue;

			store.setToDefault(info.getTextPreferenceKey());
			store.setToDefault(info.getOverviewRulerPreferenceKey());
			if (info.getVerticalRulerPreferenceKey() != null)
				store.setToDefault(info.getVerticalRulerPreferenceKey());
			store.setToDefault(info.getColorPreferenceKey());
			if (info.getShowInNextPrevDropdownToolbarActionKey() != null)
				store.setToDefault(info.getShowInNextPrevDropdownToolbarActionKey());
			if (info.getIsGoToNextNavigationTargetKey() != null)
				store.setToDefault(info.getIsGoToNextNavigationTargetKey());
			if (info.getIsGoToPreviousNavigationTargetKey() != null)
				store.setToDefault(info.getIsGoToPreviousNavigationTargetKey());
			if (info.getHighlightPreferenceKey() != null)
				store.setToDefault(info.getHighlightPreferenceKey());
			if (info.getTextStylePreferenceKey() != null)
				store.setToDefault(info.getTextStylePreferenceKey());
		}
	}

	private static final class AccessChecker extends SecurityManager {
		public Class[] getClassContext() {
			return super.getClassContext();
		}
	}
	/**
	 * Checks correct access.
	 *
	 * @throws IllegalStateException if not called by {@link EditorsUI}
	 * @since 3.0
	 */
	private static void checkAccess() throws IllegalStateException {
		Class[] elements = new AccessChecker().getClassContext();
		if (!(elements[3].equals(EditorsUI.class)
				|| elements[4].equals(EditorsUI.class)))
			throw new IllegalStateException();
	}


	/** The list of extension fragments. */
	private List fFragments;
	/** The list of extensions. */
	private List fPreferences;

	/**
	 * Creates a new marker annotation preferences to access
	 * marker annotation preferences.
	 */
	public MarkerAnnotationPreferences() {
		this(false);
	}

	/**
	 * Creates a new marker annotation preferences to access
	 * marker annotation preferences.
	 * @param initFromPreferences tells this instance to initialize itself from the preferences
	 * 
	 * @since 3.2
	 */
	private MarkerAnnotationPreferences(boolean initFromPreferences) {
		if (initFromPreferences)
			initializeSharedMakerAnnotationPreferences();
	}

	/**
	 * Returns all extensions provided for the <code>markerAnnotationSpecification</code> extension point.
	 *
	 * @return all extensions provided for the <code>markerAnnotationSpecification</code> extension point
	 */
	public List getAnnotationPreferences() {
		if (fPreferences == null)
			initialize();
		return fPreferences;
	}

	/**
	 * Returns all extensions provided for the <code>markerAnnotationSpecification</code>
	 * extension point including fragments. Fragments share the preference part
	 * with a marker annotation specifications provided for a super type but do
	 * change the presentation part.
	 *
	 * @return all extensions provided for the <code>markerAnnotationSpecification</code>
	 *         extension point including fragments
	 */
	public List getAnnotationPreferenceFragments() {
		if (fFragments == null)
			initialize();
		return fFragments;
	}

	private void initialize() {
		synchronized (EditorsPlugin.getDefault()) {
			if (!EditorsPlugin.getDefault().isMarkerAnnotationPreferencesInitialized())
				EditorsPlugin.getDefault().setMarkerAnnotationPreferences(new MarkerAnnotationPreferences(true));
		}

		MarkerAnnotationPreferences sharedPrefs= EditorsPlugin.getDefault().getMarkerAnnotationPreferences();

		fFragments= cloneAnnotationPreferences(sharedPrefs.fFragments);
		fPreferences= cloneAnnotationPreferences(sharedPrefs.fPreferences);
	}
			
	/**
	 * Reads all extensions provided for the <code>markerAnnotationSpecification</code> extension point and
	 * translates them into <code>AnnotationPreference</code> objects.
	 */
	private void initializeSharedMakerAnnotationPreferences() {

		// initialize lists - indicates that the initialization happened
		fFragments= new ArrayList(2);
		fPreferences= new ArrayList(2);

		// populate list
		IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "markerAnnotationSpecification"); //$NON-NLS-1$
		if (extensionPoint != null) {
			IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
			for (int i= 0; i < elements.length; i++) {
				AnnotationPreference spec= createSpec(elements[i]);
				if (spec != null)
					fFragments.add(spec);
				if (isComplete(spec))
					fPreferences.add(spec);
			}
		}

		final Collator collator= Collator.getInstance();
		Collections.sort(fFragments, new Comparator() {
			/*
			 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
			 */
			public int compare(Object o1, Object o2) {
				if (o1 == o2)
					return 0;

				AnnotationPreference ap1= (AnnotationPreference)o1;
				AnnotationPreference ap2= (AnnotationPreference)o2;

				String label1= ap1.getPreferenceLabel();
				String label2= ap2.getPreferenceLabel();

				if (label1 == null && label2 == null)
					return 0;

				if (label1 == null)
					return -1;

				if (label2 == null)
					return 1;

				return collator.compare(label1, label2);
			}
		});
	}
	
	/**
	 * Deeply clones the given list of <code>AnnotationPreference</code>.
	 * 
	 * @param annotationPreferences a list of <code>AnnotationPreference</code>
	 * @return the cloned list of cloned annotation preferences
	 * @since 3.1
	 */
	private List cloneAnnotationPreferences(List annotationPreferences) {
		if (annotationPreferences == null)
			return null;
		List clone= new ArrayList(annotationPreferences.size());
		Iterator iter= annotationPreferences.iterator();
		while (iter.hasNext())
			clone.add(clone(((AnnotationPreference)iter.next())));
		return clone;
	}
	
	/**
	 * Clones the given annotation preference.
	 * 
	 * @param annotationPreference the annotation preference to clone
	 * @return the cloned annotation preference
	 * @since 3.1
	 */
	private AnnotationPreference clone(AnnotationPreference annotationPreference) {
		if (annotationPreference == null)
			return null;
		
		AnnotationPreference clone= new AnnotationPreference();
		if (annotationPreference.getAnnotationType() != null) {
			clone.setAnnotationType(annotationPreference.getAnnotationType());
			clone.merge(annotationPreference);
		}
		
		return clone;
	}

	/**
	 * Checks if <code>spec</code> has all the attributes previously required
	 * by the marker annotation preference extension point. These are: color, text
	 * and overview ruler preference keys.
	 *
	 * @param spec the <code>AnnotationPreference</code> to check
	 * @return <code>true</code> if <code>spec</code> is complete, <code>false</code> otherwise
	 * @since 3.0
	 */
	private static boolean isComplete(AnnotationPreference spec) {
		return spec.getColorPreferenceKey() != null
				&& spec.getColorPreferenceValue() != null
				&& spec.getTextPreferenceKey() != null
				&& spec.getOverviewRulerPreferenceKey() != null;
	}

	/**
	 * Creates a <code>AnnotationPreference</code> the given configuration element.
	 *
	 * @param element the configuration element
	 * @return the created annotation preference
	 */
	private AnnotationPreference createSpec(IConfigurationElement element) {

		String s;
		int i;
		boolean b;

		ReadOnlyAnnotationPreference info= new ReadOnlyAnnotationPreference();

		s= element.getAttribute("annotationType");  //$NON-NLS-1$
		if (s == null || s.trim().length() == 0) return null;
		info.setAnnotationType(s);

		s= element.getAttribute("label");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setPreferenceLabel(s);

		s= element.getAttribute("markerType");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setMarkerType(s);

		s= element.getAttribute("markerSeverity");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {
			i= StringConverter.asInt(s, IMarker.SEVERITY_INFO);
			info.setSeverity(i);
		}

		s= element.getAttribute("textPreferenceKey");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setTextPreferenceKey(s);

		s= element.getAttribute("textPreferenceValue");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {
			b= StringConverter.asBoolean(s, false);
			info.setTextPreferenceValue(b);
		}

		s= element.getAttribute("highlightPreferenceKey");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setHighlightPreferenceKey(s);

		s= element.getAttribute("highlightPreferenceValue");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {
			b= StringConverter.asBoolean(s, false);
			info.setHighlightPreferenceValue(b);
		}

		s= element.getAttribute("overviewRulerPreferenceKey");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setOverviewRulerPreferenceKey(s);

		s= element.getAttribute("overviewRulerPreferenceValue");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {
			b= StringConverter.asBoolean(s, false);
			info.setOverviewRulerPreferenceValue(b);
		}

		s= element.getAttribute("verticalRulerPreferenceKey");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setVerticalRulerPreferenceKey(s);

		s= element.getAttribute("verticalRulerPreferenceValue");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {
			b= StringConverter.asBoolean(s, true);
			info.setVerticalRulerPreferenceValue(b);
		}

		s= element.getAttribute("colorPreferenceKey");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setColorPreferenceKey(s);

		s= element.getAttribute("colorPreferenceValue");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {
			RGB rgb= StringConverter.asRGB(s);
			info.setColorPreferenceValue(rgb == null ? new RGB(0,0,0) : rgb);
		}

		s= element.getAttribute("presentationLayer");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {
			i= StringConverter.asInt(s, 0);
			info.setPresentationLayer(i);
		}

		s= element.getAttribute("contributesToHeader");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {
			b= StringConverter.asBoolean(s, false);
			info.setContributesToHeader(b);
		}

		s= element.getAttribute("showInNextPrevDropdownToolbarActionKey");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setShowInNextPrevDropdownToolbarActionKey(s);

		s= element.getAttribute("showInNextPrevDropdownToolbarAction");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {
			b= StringConverter.asBoolean(s, false);
			info.setShowInNextPrevDropdownToolbarAction(b);
		}

		s= element.getAttribute("isGoToNextNavigationTargetKey");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setIsGoToNextNavigationTargetKey(s);

		s= element.getAttribute("isGoToNextNavigationTarget");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {
			b= StringConverter.asBoolean(s, false);
			info.setIsGoToNextNavigationTarget(b);
		}

		s= element.getAttribute("isGoToPreviousNavigationTargetKey");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setIsGoToPreviousNavigationTargetKey(s);

		s= element.getAttribute("isGoToPreviousNavigationTarget");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {
			b= StringConverter.asBoolean(s, false);
			info.setIsGoToPreviousNavigationTarget(b);
		}

		s= element.getAttribute("symbolicIcon");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setSymbolicImageName(s);

		s= element.getAttribute("icon");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setImageDescriptor(getImageDescriptor(s, element));
		
		s= element.getAttribute("quickFixIcon");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setQuickFixImageDescriptor(getImageDescriptor(s, element));

		s= element.getAttribute("annotationImageProvider"); //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setAnnotationImageProviderData(element, "annotationImageProvider"); //$NON-NLS-1$

		s= element.getAttribute("textStylePreferenceKey"); //$NON-NLS-1$
		if (s != null && s.trim().length() > 0)
			info.setTextStylePreferenceKey(s);

		s= element.getAttribute("textStylePreferenceValue");  //$NON-NLS-1$
		if (s != null && s.trim().length() > 0) {

			if (AnnotationPreference.STYLE_BOX.equals(s)
					|| AnnotationPreference.STYLE_IBEAM.equals(s)
					|| AnnotationPreference.STYLE_SQUIGGLES.equals(s)
					|| AnnotationPreference.STYLE_UNDERLINE.equals(s))
				info.setTextStyleValue(s);
			else
				info.setTextStyleValue(AnnotationPreference.STYLE_NONE);

		}

		s= element.getAttribute("includeOnPreferencePage");  //$NON-NLS-1$
		info.setIncludeOnPreferencePage(s == null || StringConverter.asBoolean(s, true));

		info.markReadOnly();
		
		return info;
	}

	/**
	 * Returns the image descriptor for the icon path specified by the given configuration
	 * element.
	 *
	 * @param iconPath the icon path
	 * @param element the configuration element
	 * @return the image descriptor
	 * @since 3.0
	 */
	private ImageDescriptor getImageDescriptor(String iconPath, IConfigurationElement element) {
		String pluginId= element.getContributor().getName();
		Bundle bundle= Platform.getBundle(pluginId);
		if (bundle == null)
			return null;

		URL url= FileLocator.find(bundle, new Path(iconPath), null);
		if (url != null)
			return ImageDescriptor.createFromURL(url);
		
		return ImageDescriptor.getMissingImageDescriptor();
	}
}

Back to the top