Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 78018 Details for
Bug 198544
[content type] Platform.getContentTypeManager().findContentTypeFor( filename) ignores content type priority
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix 02
198544.txt (text/plain), 4.29 KB, created by
Szymon Brandys
on 2007-09-10 16:13:58 EDT
(
hide
)
Description:
Fix 02
Filename:
MIME Type:
Creator:
Szymon Brandys
Created:
2007-09-10 16:13:58 EDT
Size:
4.29 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.tests.runtime >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.tests.runtime/plugin.xml,v >retrieving revision 1.71 >diff -u -r1.71 plugin.xml >--- plugin.xml 10 Sep 2007 15:56:04 -0000 1.71 >+++ plugin.xml 10 Sep 2007 20:16:21 -0000 >@@ -138,16 +138,18 @@ > name="Sub Foo Bar" > id="subFooBar"/> > <content-type >- file-extensions="xml2" > base-type="org.eclipse.core.runtime.xml" >+ file-extensions="xml2" >+ id="xml-based-different-extension" > name="XML Based with Different Extension" >- id="xml-based-different-extension"> >+ priority="high"> > </content-type> > <content-type >- file-names="xml-based.xml" > base-type="org.eclipse.core.runtime.xml" >+ file-names="xml-based.xml" >+ id="xml-based-specific-name" > name="XML Based with Specific Name" >- id="xml-based-specific-name"/> >+ priority="high"/> > <content-type > file-extensions="samplebin1" > name="Sample Binary 1" >@@ -222,9 +224,10 @@ > <!-- content types for content describer tests --> > <content-type > base-type="org.eclipse.core.runtime.xml" >- name="Root Element" >+ describer="org.eclipse.core.runtime.content.XMLRootElementContentDescriber:org.eclipse.core.runtime.tests.root-element" > id="root-element" >- describer="org.eclipse.core.runtime.content.XMLRootElementContentDescriber:org.eclipse.core.runtime.tests.root-element"/> >+ name="Root Element" >+ priority="high"/> > <content-type > base-type="org.eclipse.core.runtime.xml" > name="DTD" >@@ -237,7 +240,7 @@ > <!-- this content type is used by the content description tests --> > <content-type > name="Void content type" >- id="void"/> >+ id="void"/> > </extension> > <extension > point="org.eclipse.core.runtime.adapters"> >#P org.eclipse.core.contenttype >Index: src/org/eclipse/core/internal/content/ContentTypeMatcher.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeMatcher.java,v >retrieving revision 1.1 >diff -u -r1.1 ContentTypeMatcher.java >--- src/org/eclipse/core/internal/content/ContentTypeMatcher.java 21 Nov 2005 23:06:48 -0000 1.1 >+++ src/org/eclipse/core/internal/content/ContentTypeMatcher.java 10 Sep 2007 20:16:22 -0000 >@@ -36,7 +36,22 @@ > public IContentType findContentTypeFor(InputStream contents, String fileName) throws IOException { > ContentTypeCatalog currentCatalog = getCatalog(); > IContentType[] all = currentCatalog.findContentTypesFor(this, contents, fileName); >- return all.length > 0 ? new ContentTypeHandler((ContentType) all[0], currentCatalog.getGeneration()) : null; >+ return all.length > 0 ? new ContentTypeHandler((ContentType) getContentTypeWithTheHighestPriority(all), currentCatalog.getGeneration()) : null; >+ } >+ >+ /* >+ * Returns a content type with the highest priority from the given list. >+ */ >+ private IContentType getContentTypeWithTheHighestPriority(IContentType[] contentTypes) { >+ IContentType bestMatch = null; >+ for (int i = 0; i < contentTypes.length; i++) { >+ if (bestMatch == null || (((ContentType) bestMatch).getPriority() < ((ContentType) contentTypes[i]).getPriority())) { >+ bestMatch = contentTypes[i]; >+ if (((ContentType) bestMatch).getPriority() == ContentType.PRIORITY_HIGH) >+ break; >+ } >+ } >+ return bestMatch; > } > > /** >@@ -46,7 +61,7 @@ > // basic implementation just gets all content types > ContentTypeCatalog currentCatalog = getCatalog(); > IContentType[] associated = currentCatalog.findContentTypesFor(this, fileName); >- return associated.length == 0 ? null : new ContentTypeHandler((ContentType) associated[0], currentCatalog.getGeneration()); >+ return associated.length == 0 ? null : new ContentTypeHandler((ContentType) getContentTypeWithTheHighestPriority(associated), currentCatalog.getGeneration()); > } > > /**
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 198544
:
78011
| 78018 |
78169
|
78195
|
78196