Search in sources :

Example 26 with IContentTypeManager

use of org.eclipse.core.runtime.content.IContentTypeManager in project webtools.sourceediting by eclipse.

the class TestContentTypeHandlers method testDTDExists.

public void testDTDExists() {
    String id = "org.eclipse.wst.dtd.core.dtdsource";
    IContentTypeManager registry = getContentTypeRegistry();
    IContentType identifier = registry.getContentType(id);
    assertTrue("content type identifier " + id + " does not have DTD type ", identifier != null);
}
Also used : IContentTypeManager(org.eclipse.core.runtime.content.IContentTypeManager) IContentType(org.eclipse.core.runtime.content.IContentType)

Example 27 with IContentTypeManager

use of org.eclipse.core.runtime.content.IContentTypeManager in project webtools.sourceediting by eclipse.

the class TestContentTypeHandlers method testXMLExistsByFileExtension.

public void testXMLExistsByFileExtension() throws IOException {
    String filename = "test.xml";
    IContentTypeManager registry = getContentTypeRegistry();
    IContentType identifier = registry.getDescriptionFor(new NullStream(), filename, IContentDescription.ALL).getContentType();
    assertTrue("content type identifier for " + filename + " does not have XML type ", identifier != null);
}
Also used : IContentTypeManager(org.eclipse.core.runtime.content.IContentTypeManager) IContentType(org.eclipse.core.runtime.content.IContentType)

Example 28 with IContentTypeManager

use of org.eclipse.core.runtime.content.IContentTypeManager in project webtools.sourceediting by eclipse.

the class TestContentTypeHandlers method testMultipleDefinitions.

public void testMultipleDefinitions() throws IOException {
    String id = ContentTypeIdForCSS.ContentTypeID_CSS;
    String filename = "test.css";
    IContentTypeManager registry = getContentTypeRegistry();
    IContentType identifier1 = registry.getContentType(id);
    IContentType identifier2 = registry.getDescriptionFor(new NullStream(), filename, IContentDescription.ALL).getContentType();
    assertTrue("mulitple content type identifiers need to be equal (but not same instance) ", identifier1.equals(identifier2));
}
Also used : IContentTypeManager(org.eclipse.core.runtime.content.IContentTypeManager) IContentType(org.eclipse.core.runtime.content.IContentType)

Example 29 with IContentTypeManager

use of org.eclipse.core.runtime.content.IContentTypeManager in project webtools.sourceediting by eclipse.

the class TestContentTypeHandlers method testHTMLExistsByFileExtension.

public void testHTMLExistsByFileExtension() throws IOException {
    String filename = "test.html";
    IContentTypeManager registry = getContentTypeRegistry();
    IContentType identifier = registry.getDescriptionFor(new NullStream(), filename, IContentDescription.ALL).getContentType();
    assertTrue("content type identifier for " + filename + " does not have HTML type ", identifier != null);
}
Also used : IContentTypeManager(org.eclipse.core.runtime.content.IContentTypeManager) IContentType(org.eclipse.core.runtime.content.IContentType)

Example 30 with IContentTypeManager

use of org.eclipse.core.runtime.content.IContentTypeManager in project webtools.sourceediting by eclipse.

the class FileUtil method isXSLFile.

/**
 * Determines if a file is a XSLT File.
 * @param file The input IFile to check.
 * @return True if it is a XSLT file, false otherwise.
 */
public static boolean isXSLFile(IFile file) {
    IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
    IContentType[] types = contentTypeManager.findContentTypesFor(file.getName());
    for (IContentType contentType : types) {
        if (contentType.equals(contentTypeManager.getContentType(XSLCore.XSL_CONTENT_TYPE))) {
            return true;
        }
    }
    return false;
}
Also used : IContentTypeManager(org.eclipse.core.runtime.content.IContentTypeManager) IContentType(org.eclipse.core.runtime.content.IContentType)

Aggregations

IContentTypeManager (org.eclipse.core.runtime.content.IContentTypeManager)33 IContentType (org.eclipse.core.runtime.content.IContentType)27 IContentDescription (org.eclipse.core.runtime.content.IContentDescription)8 CoreException (org.eclipse.core.runtime.CoreException)5 InputStream (java.io.InputStream)4 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)3 ArrayList (java.util.ArrayList)2 Set (java.util.Set)2 BufferedInputStream (java.io.BufferedInputStream)1 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFileInfo (org.eclipse.core.filesystem.IFileInfo)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 ProjectScope (org.eclipse.core.resources.ProjectScope)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1