View | Details | Raw Unified | Return to bug 333930 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/commons/core/ExtensionPointReader.java (-1 / +26 lines)
Lines 43-48 Link Here
43
43
44
	private final List<T> items;
44
	private final List<T> items;
45
45
46
	private String filterAttributeId;
47
48
	private String filterAttributeValue;
49
50
	public ExtensionPointReader(String pluginId, String extensionId, String elementId, Class<T> clazz,
51
			String filterAttributeId, String filterAttributeValue) {
52
		this(pluginId, extensionId, elementId, clazz);
53
		this.filterAttributeId = filterAttributeId;
54
		this.filterAttributeValue = filterAttributeValue;
55
	}
56
46
	public ExtensionPointReader(String pluginId, String extensionId, String elementId, Class<T> clazz) {
57
	public ExtensionPointReader(String pluginId, String extensionId, String elementId, Class<T> clazz) {
47
		Assert.isNotNull(pluginId);
58
		Assert.isNotNull(pluginId);
48
		Assert.isNotNull(extensionId);
59
		Assert.isNotNull(extensionId);
Lines 89-95 Link Here
89
			for (IExtension extension : extensions) {
100
			for (IExtension extension : extensions) {
90
				IConfigurationElement[] elements = extension.getConfigurationElements();
101
				IConfigurationElement[] elements = extension.getConfigurationElements();
91
				for (IConfigurationElement element : elements) {
102
				for (IConfigurationElement element : elements) {
92
					if (element.getName().equals(elementId)) {
103
					if (element.getName().equals(elementId) && shouldRead(element)) {
93
						T item = readElement(element, result);
104
						T item = readElement(element, result);
94
						if (item != null) {
105
						if (item != null) {
95
							items.add(item);
106
							items.add(item);
Lines 104-109 Link Here
104
		return result;
115
		return result;
105
	}
116
	}
106
117
118
	/**
119
	 * Determines whether the element should be instantiated by this ExtensionPointReader. This implementation checks
120
	 * whether the element defines an attribute with id and value matching filterAttributeId and filterAttributeValue.
121
	 * If filterAttributeValue is the empty string, an element is also considered to match if it does not define the
122
	 * attribute.
123
	 * <p>
124
	 * Subclasses may override.
125
	 */
126
	protected boolean shouldRead(IConfigurationElement element) {
127
		return filterAttributeId == null || filterAttributeValue == null
128
				|| filterAttributeValue.equals(element.getAttribute(filterAttributeId))
129
				|| (filterAttributeValue.length() == 0 && element.getAttribute(filterAttributeId) == null);
130
	}
131
107
	protected void handleResult(IStatus result) {
132
	protected void handleResult(IStatus result) {
108
		if (!result.isOK()) {
133
		if (!result.isOK()) {
109
			StatusHandler.log(result);
134
			StatusHandler.log(result);

Return to bug 333930