Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 198544 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-7 / +10 lines)
Lines 138-153 Link Here
138
            name="Sub Foo Bar"
138
            name="Sub Foo Bar"
139
            id="subFooBar"/>
139
            id="subFooBar"/>
140
      <content-type
140
      <content-type
141
            file-extensions="xml2"
142
            base-type="org.eclipse.core.runtime.xml"
141
            base-type="org.eclipse.core.runtime.xml"
142
            file-extensions="xml2"
143
            id="xml-based-different-extension"
143
            name="XML Based with Different Extension"
144
            name="XML Based with Different Extension"
144
            id="xml-based-different-extension">
145
            priority="high">
145
      </content-type>
146
      </content-type>
146
      <content-type
147
      <content-type
147
            file-names="xml-based.xml"
148
            base-type="org.eclipse.core.runtime.xml"
148
            base-type="org.eclipse.core.runtime.xml"
149
            file-names="xml-based.xml"
150
            id="xml-based-specific-name"
149
            name="XML Based with Specific Name"
151
            name="XML Based with Specific Name"
150
            id="xml-based-specific-name"/>
152
            priority="high"/>
151
      <content-type
153
      <content-type
152
            file-extensions="samplebin1"
154
            file-extensions="samplebin1"
153
            name="Sample Binary 1"
155
            name="Sample Binary 1"
Lines 222-230 Link Here
222
      <!-- content types for content describer tests -->
224
      <!-- content types for content describer tests -->
223
      <content-type
225
      <content-type
224
            base-type="org.eclipse.core.runtime.xml"
226
            base-type="org.eclipse.core.runtime.xml"
225
            name="Root Element"
227
            describer="org.eclipse.core.runtime.content.XMLRootElementContentDescriber:org.eclipse.core.runtime.tests.root-element"
226
            id="root-element"
228
            id="root-element"
227
            describer="org.eclipse.core.runtime.content.XMLRootElementContentDescriber:org.eclipse.core.runtime.tests.root-element"/>
229
            name="Root Element"
230
            priority="high"/>
228
      <content-type
231
      <content-type
229
            base-type="org.eclipse.core.runtime.xml"
232
            base-type="org.eclipse.core.runtime.xml"
230
            name="DTD"
233
            name="DTD"
Lines 237-243 Link Here
237
      <!-- this content type is used by the content description tests -->
240
      <!-- this content type is used by the content description tests -->
238
      <content-type
241
      <content-type
239
            name="Void content type"
242
            name="Void content type"
240
            id="void"/>      
243
            id="void"/>
241
   </extension>
244
   </extension>
242
   <extension
245
   <extension
243
         point="org.eclipse.core.runtime.adapters">
246
         point="org.eclipse.core.runtime.adapters">
(-)src/org/eclipse/core/internal/content/ContentTypeMatcher.java (-2 / +17 lines)
Lines 36-42 Link Here
36
	public IContentType findContentTypeFor(InputStream contents, String fileName) throws IOException {
36
	public IContentType findContentTypeFor(InputStream contents, String fileName) throws IOException {
37
		ContentTypeCatalog currentCatalog = getCatalog();
37
		ContentTypeCatalog currentCatalog = getCatalog();
38
		IContentType[] all = currentCatalog.findContentTypesFor(this, contents, fileName);
38
		IContentType[] all = currentCatalog.findContentTypesFor(this, contents, fileName);
39
		return all.length > 0 ? new ContentTypeHandler((ContentType) all[0], currentCatalog.getGeneration()) : null;
39
		return all.length > 0 ? new ContentTypeHandler((ContentType) getContentTypeWithTheHighestPriority(all), currentCatalog.getGeneration()) : null;
40
	}
41
	
42
	/*
43
	 * Returns a content type with the highest priority from the given list.
44
	 */
45
	private IContentType getContentTypeWithTheHighestPriority(IContentType[] contentTypes) {
46
		IContentType bestMatch = null;
47
		for (int i = 0; i < contentTypes.length; i++) {
48
			if (bestMatch == null || (((ContentType) bestMatch).getPriority() < ((ContentType) contentTypes[i]).getPriority())) {
49
				bestMatch = contentTypes[i];
50
				if (((ContentType) bestMatch).getPriority() == ContentType.PRIORITY_HIGH)
51
					break;
52
			}
53
		}
54
		return bestMatch;
40
	}
55
	}
41
56
42
	/**
57
	/**
Lines 46-52 Link Here
46
		// basic implementation just gets all content types
61
		// basic implementation just gets all content types
47
		ContentTypeCatalog currentCatalog = getCatalog();
62
		ContentTypeCatalog currentCatalog = getCatalog();
48
		IContentType[] associated = currentCatalog.findContentTypesFor(this, fileName);
63
		IContentType[] associated = currentCatalog.findContentTypesFor(this, fileName);
49
		return associated.length == 0 ? null : new ContentTypeHandler((ContentType) associated[0], currentCatalog.getGeneration());
64
		return associated.length == 0 ? null : new ContentTypeHandler((ContentType) getContentTypeWithTheHighestPriority(associated), currentCatalog.getGeneration());
50
	}
65
	}
51
66
52
	/**
67
	/**

Return to bug 198544