Java 类org.eclipse.core.runtime.content.IContentType 实例源码

项目:bdf2    文件:ModelFilePage.java   
/**
 * Verifies if fileName is valid name for content type. Takes base content
 * type into consideration.
 * 
 * @param fileName
 * @return true if extension is valid for this content type
 */
boolean extensionValidForContentType(String fileName) {
    boolean valid = false;
    IContentType type = Platform.getContentTypeManager().getContentType(
            ContentTypeID_XML);
    // there is currently an extension
    if (fileName.lastIndexOf('.') != -1) {
        // check what content types are associated with current extension
        IContentType[] types = Platform.getContentTypeManager()
                .findContentTypesFor(fileName);
        int i = 0;
        while ((i < types.length) && !valid) {
            valid = types[i].isKindOf(type);
            ++i;
        }
    } else {
        valid = true; // no extension so valid
    }
    return valid;
}
项目:tm4e    文件:AbstractGrammarRegistryManager.java   
@Override
public IGrammar getGrammarFor(IContentType[] contentTypes) {
    if (contentTypes == null) {
        return null;
    }
    // Find grammar by content type
    for (IContentType contentType : contentTypes) {
        String scopeName = getScopeNameForContentType(contentType.getId());
        if (scopeName != null) {
            IGrammar grammar = getGrammarForScope(scopeName);
            if (grammar != null) {
                return grammar;
            }
        }
    }
    return null;
}
项目:typescript.java    文件:IDEResourcesManager.java   
private IDEResourcesManager() {
    this.registryListenerIntialized = false;
    this.resourceParticipants = new ArrayList<>();
    this.listeners = new ArrayList<ITypeScriptElementChangedListener>();
    updateUseJsAsJsx(Platform.getContentTypeManager().getContentType(JSX_CONTENT_TYPE_ID));

    Platform.getContentTypeManager().addContentTypeChangeListener(new IContentTypeChangeListener() {

        @Override
        public void contentTypeChanged(ContentTypeChangeEvent event) {
            IContentType contentType = event.getContentType();
            if (contentType != null && JSX_CONTENT_TYPE_ID.equals(contentType.getId())) {
                updateUseJsAsJsx(contentType);
            }
        }
    });
}
项目:Source    文件:IdeFileTypeRegistry.java   
/**
 * {@inheritDoc}
 *
 * @see org.eclipse.mylyn.docs.intent.mapping.content.IFileTypeRegistry#getFileType(java.lang.String)
 */
public IFileType getFileType(String typeID) {
    final IFileType res;

    final IFileType delegateFileType = registry.getFileType(typeID);
    if (delegateFileType == null) {
        final IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
        final IContentType contentType = contentTypeManager.getContentType(typeID);
        if (contentType != null) {
            res = new FileType(contentType.getId());
        } else {
            res = null;
        }
    } else {
        res = delegateFileType;
    }

    return res;
}
项目:Source    文件:IdeFileTypeRegistry.java   
/**
 * {@inheritDoc}
 * 
 * @throws IOException
 * @see org.eclipse.mylyn.docs.intent.mapping.content.IFileTypeRegistry#getFileTypeFor(java.io.InputStream,
 *      java.lang.String)
 */
public IFileType getFileTypeFor(InputStream contents, String name) throws IOException {
    final IFileType res;

    final IFileType delegateFileType = registry.getFileTypeFor(contents, name);
    if (delegateFileType == null) {
        final IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(contents,
                name);
        if (contentType != null) {
            res = new FileType(contentType.getId());
        } else {
            res = null;
        }
    } else {
        res = delegateFileType;
    }

    return res;
}
项目:che    文件:ExtensionsRegistry.java   
/**
 * Returns a sharable document factory for the given content types.
 *
 * @param contentTypes the content types used to find the factory
 * @return the sharable document factory or <code>null</code>
 * @deprecated As of 3.5
 */
protected org.eclipse.core.filebuffers.IDocumentFactory doGetDocumentFactory(
    IContentType[] contentTypes) {
  Set set = null;
  int i = 0;
  while (i < contentTypes.length && set == null) {
    set = (Set) fFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
  }

  if (set != null) {
    IConfigurationElement entry = selectConfigurationElement(set);
    return (org.eclipse.core.filebuffers.IDocumentFactory)
        getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
  }
  return null;
}
项目:che    文件:ExtensionsRegistry.java   
/**
 * Returns the set of setup participants for the given content types.
 *
 * @param contentTypes the contentTypes to be used for lookup
 * @return the sharable set of document setup participants
 */
private List doGetDocumentSetupParticipants(IContentType[] contentTypes) {
  Set resultSet = new HashSet();
  int i = 0;
  while (i < contentTypes.length) {
    Set set = (Set) fSetupParticipantDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
    if (set != null) resultSet.addAll(set);
  }

  List participants = new ArrayList();
  Iterator e = resultSet.iterator();
  while (e.hasNext()) {
    IConfigurationElement entry = (IConfigurationElement) e.next();
    Object participant = getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
    if (participant != null) participants.add(participant);
  }

  return participants.isEmpty() ? null : participants;
}
项目:che    文件:ExtensionsRegistry.java   
/**
 * Returns the set of direct base content types for the given set of content types. Returns <code>
 * null</code> if non of the given content types has a direct base content type.
 *
 * @param contentTypes the content types
 * @return the set of direct base content types
 */
private IContentType[] computeBaseContentTypes(IContentType[] contentTypes) {
  List baseTypes = new ArrayList();
  for (int i = 0; i < contentTypes.length; i++) {
    IContentType baseType = contentTypes[i].getBaseType();
    if (baseType != null) baseTypes.add(baseType);
  }

  IContentType[] result = null;
  int size = baseTypes.size();
  if (size > 0) {
    result = new IContentType[size];
    baseTypes.toArray(result);
  }
  return result;
}
项目:SecureBPMN    文件:ActivitiMultiPageEditor.java   
private boolean isBPM2FileType(final IFileEditorInput editorInput) {

    boolean isBPMN2File = false;
    IFile file = editorInput.getFile();
    try {
      IContentDescription desc = file.getContentDescription();
      if (desc != null) {
        IContentType type = desc.getContentType();
        if (ActivitiBPMNDiagramConstants.BPMN2_CONTENTTYPE_ID.equals(type.getId())) {
          isBPMN2File = true;
        }
      }
    } catch (CoreException e) {
      e.printStackTrace();
      return isBPMN2File;
    }

    return isBPMN2File;
  }
项目:filesync4eclipse    文件:SyncWizard.java   
/**
 * @param file must be not null
 * @return true if the file has "text" content description.
 */
public static boolean hasTextContentType(IFile file) {
    try {
        IContentDescription contentDescr = file.getContentDescription();
        if (contentDescr == null) {
            return false;
        }
        IContentType contentType = contentDescr.getContentType();
        if (contentType == null) {
            return false;
        }
        return contentType.isKindOf(TEXT_TYPE);
        //
    } catch (CoreException e) {
        FileSyncPlugin.log(
                "Could not get content type for: " + file, e, IStatus.WARNING);
    }
    return false;
}
项目:eclipse-wtp-json    文件:JSONSyntaxValidator.java   
private boolean shouldValidate(IResource file, boolean checkExtension) {
    if (file == null || !file.exists() || file.getType() != IResource.FILE)
        return false;
    if (checkExtension) {
        String extension = file.getFileExtension();
        if (extension != null
                && "json".endsWith(extension.toLowerCase(Locale.US))) //$NON-NLS-1$
            return true;
    }

    IContentDescription contentDescription = null;
    try {
        contentDescription = ((IFile) file).getContentDescription();
        if (contentDescription != null) {
            IContentType contentType = contentDescription.getContentType();
            return contentDescription != null
                    && contentType.isKindOf(getJSONContentType());
        }
    } catch (CoreException e) {
        Logger.logException(e);
    }
    return false;
}
项目:APICloud-Studio    文件:XMLEditor.java   
@Override
public String getContentType()
{
    try
    {
        IContentType contentType = ((TextFileDocumentProvider) getDocumentProvider())
                .getContentType(getEditorInput());
        if (contentType != null)
        {
            IContentType baseType = contentType.getBaseType();
            if (baseType != null && IXMLConstants.CONTENT_TYPE_XML.equals(baseType.getId()))
            {
                return contentType.getId();
            }
        }
    }
    catch (Exception e)
    {
    }
    return IXMLConstants.CONTENT_TYPE_XML;
}
项目:APICloud-Studio    文件:BuildParticipantManager.java   
/**
 * Determines if a given content type is associated with the filename.
 * 
 * @param filename
 * @param types
 * @return
 */
private boolean hasType(String contentTypeId, Set<IContentType> types)
{
    if (CollectionsUtil.isEmpty(types))
    {
        // FIXME this means if no content type binding is specified then we assume the build participant is valid
        // for all types!
        return true;
    }
    for (IContentType type : types)
    {
        if (type == null)
        {
            continue;
        }
        if (type.getId().equals(contentTypeId))
        {
            return true;
        }
    }
    return false;
}
项目:APICloud-Studio    文件:ProjectTemplate.java   
/**
 * Returns true if the given file can be evaluated for template-variables.<br>
 * There is no good way of detecting what is binary and what is not, so we decide what is supported by checking if
 * the content type is a sub-type of text.
 * 
 * @param file
 * @return true if the file can be processed; false, otherwise.
 */
private static boolean isSupportedFile(IFile file)
{
    IContentTypeManager manager = Platform.getContentTypeManager();
    if (manager == null)
    {
        return false;
    }
    IContentType contentType = manager.findContentTypeFor(file.getName());
    if (contentType == null)
    {
        return false;
    }
    IContentType text = manager.getContentType("org.eclipse.core.runtime.text"); //$NON-NLS-1$
    return contentType.isKindOf(text);
}
项目:APICloud-Studio    文件:IndexManager.java   
/**
 * Determines if a given content type is associated with the filename.
 * 
 * @param filename
 * @param types
 * @return
 */
private boolean hasType(String filename, Set<IContentType> types)
{
    if (types == null || types.isEmpty())
    {
        return false;
    }
    for (IContentType type : types)
    {
        if (type == null)
        {
            continue;
        }
        if (type.isAssociatedWith(filename))
        {
            return true;
        }
    }
    return false;
}
项目:APICloud-Studio    文件:AbstractThemeableEditor.java   
public String getContentType()
{
    try
    {
        IContentType contentType = ((TextFileDocumentProvider) getDocumentProvider())
                .getContentType(getEditorInput());
        if (contentType != null)
        {
            return contentType.getId();
        }
    }
    catch (Exception e)
    {
        IdeLog.logError(CommonEditorPlugin.getDefault(), e);
    }
    return null;
}
项目:OpenSPIFe    文件:ProfileUtil.java   
public static boolean isProfileContentType (IResource resource) {
    if ((resource instanceof IFile) && resource.exists()) {
        try {
            IContentDescription cd = ((IFile)resource).getContentDescription();
            if (cd != null) {
                IContentType type = cd.getContentType();
                if ((type != null) && type.isKindOf(PROFILE_CONTENT_TYPE)) {
                    return true;
                }
            }
        } catch (CoreException e) {
            LogUtil.error(e);
        }
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:PropertiesFileSourceViewerConfiguration.java   
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
    if (!EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED))
        return null;

    IReconcilingStrategy strategy= new SpellingReconcileStrategy(sourceViewer, EditorsUI.getSpellingService()) {
        @Override
        protected IContentType getContentType() {
            return PROPERTIES_CONTENT_TYPE;
        }
    };

    MonoReconciler reconciler= new MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
}
项目:Eclipse-Postfix-Code-Completion    文件:EditorUtility.java   
private static boolean isClassFile(IFile file) {
    IContentDescription contentDescription;
    try {
        contentDescription= file.getContentDescription();
    } catch (CoreException e) {
        contentDescription= null;
    }
    if (contentDescription == null)
        return false;

    IContentType contentType= contentDescription.getContentType();
    if (contentType == null)
        return false;

    return "org.eclipse.jdt.core.javaClass".equals(contentType.getId()); //$NON-NLS-1$
}
项目:editorconfig-eclipse    文件:EditorConfigSourceViewerConfiguration.java   
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
    if (!EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED))
        return null;

    IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, EditorsUI.getSpellingService()) {
        @Override
        protected IContentType getContentType() {
            return EditorConfigTextTools.EDITORCONFIG_CONTENT_TYPE;
        }
    };

    MonoReconciler reconciler = new MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
}
项目:mybatipse    文件:ConfigRegistry.java   
/**
 * Scans the project and returns the MyBatis config file if found.<br>
 * If there are multiple files in the project, only the first one is returned.
 * 
 * @param project
 * @return MyBatis config file or <code>null</code> if none found.
 */
private Map<IFile, IContentType> search(IJavaProject project)
{
    final Map<IFile, IContentType> configFiles = new ConcurrentHashMap<IFile, IContentType>();
    try
    {
        project.getResource().accept(new ConfigVisitor(configFiles), IContainer.NONE);

        for (IPackageFragmentRoot root : project.getPackageFragmentRoots())
        {
            if (root.getKind() != IPackageFragmentRoot.K_SOURCE)
                continue;
            root.getResource().accept(new ConfigVisitor(configFiles), IContainer.NONE);
        }
    }
    catch (CoreException e)
    {
        Activator.log(Status.ERROR, "Searching MyBatis Config xml failed.", e);
    }

    return configFiles;
}
项目:mybatipse    文件:ConfigRegistry.java   
@Override
public boolean visit(IResourceProxy proxy) throws CoreException
{
    if (proxy.isDerived())
        return false;

    if (proxy.getType() == IResource.FILE && proxy.getName().endsWith(".xml"))
    {
        IFile file = (IFile)proxy.requestResource();
        IContentDescription contentDesc = file.getContentDescription();
        if (contentDesc != null)
        {
            IContentType contentType = contentDesc.getContentType();
            if (contentType != null && (contentType.isKindOf(configContentType)
                || contentType.isKindOf(springConfigContentType)))
            {
                configFiles.put(file, contentType);
            }
        }
    }
    return true;
}
项目:eclipse-wtp-webresources    文件:WebResourcesValidator.java   
/**
 * Gets list of content types this validator is interested in
 * 
 * @return All HTML-related content types
 */
private IContentType[] getOtherSupportedContentTypes() {
    if (fOtherSupportedContentTypes == null) {
        List contentTypes = new ArrayList(3);
        if (fAdditionalContentTypesIDs != null) {
            for (int i = 0; i < fAdditionalContentTypesIDs.length; i++) {
                IContentType type = Platform.getContentTypeManager()
                        .getContentType(fAdditionalContentTypesIDs[i]);
                if (type != null) {
                    contentTypes.add(type);
                }
            }
        }
        fOtherSupportedContentTypes = (IContentType[]) contentTypes
                .toArray(new IContentType[contentTypes.size()]);
    }
    return fOtherSupportedContentTypes;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PropertiesFileSourceViewerConfiguration.java   
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
    if (!EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED))
        return null;

    IReconcilingStrategy strategy= new SpellingReconcileStrategy(sourceViewer, EditorsUI.getSpellingService()) {
        @Override
        protected IContentType getContentType() {
            return PROPERTIES_CONTENT_TYPE;
        }
    };

    MonoReconciler reconciler= new MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:EditorUtility.java   
private static boolean isClassFile(IFile file) {
    IContentDescription contentDescription;
    try {
        contentDescription= file.getContentDescription();
    } catch (CoreException e) {
        contentDescription= null;
    }
    if (contentDescription == null)
        return false;

    IContentType contentType= contentDescription.getContentType();
    if (contentType == null)
        return false;

    return "org.eclipse.jdt.core.javaClass".equals(contentType.getId()); //$NON-NLS-1$
}
项目:data-mapper    文件:TransformationEditor.java   
/**
 * {@inheritDoc}
 *
 * @see EditorPart#init(IEditorSite, IEditorInput)
 */
@Override
public void init(final IEditorSite site,
        final IEditorInput input) throws PartInitException {
    final IContentType contentType =
            Platform.getContentTypeManager().getContentType(DozerConfigContentTypeDescriber.ID);
    if (!contentType.isAssociatedWith(input.getName()))
        throw new PartInitException("The Fuse Transformation editor can only be opened with a"
                + " Dozer configuration file.");
    setSite(site);
    setInput(input);
    setPartName(input.getName());

    configFile = ((FileEditorInput) getEditorInput()).getFile();
    final IJavaProject javaProject = JavaCore.create(configFile.getProject());
    try {
        loader =
                (URLClassLoader) JavaUtil.getProjectClassLoader(javaProject,
                        getClass().getClassLoader());
        config = DozerMapperConfiguration.loadConfig(new File(configFile.getLocationURI()),
                loader);
    } catch (final Exception e) {
        throw new PartInitException("Unable to load transformation configuration file", e);
    }
}
项目:birt    文件:PreviewToolbarMenuAction.java   
private boolean isEnable( )
{
    IEditorPart editor = UIUtil.getActiveEditor( true );
    if ( editor != null )
    {
        IContentType[] contentTypes = Platform.getContentTypeManager( )
                .findContentTypesFor( editor.getEditorInput( ).getName( ) );
        for ( IContentType type : contentTypes )
        {
            if ( type.getId( )
                    .equals( "org.eclipse.birt.report.designer.ui.editors.reportdesign" ) //$NON-NLS-1$
                    || type.getId( )
                            .equals( "org.eclipse.birt.report.designer.ui.editors.reporttemplate" ) ) //$NON-NLS-1$
                return true;
        }
    }
    return false;
}
项目:glassmaker    文件:NewCardFileWizardPage.java   
/**
 * Verifies if fileName is valid name for content type. Takes base content
 * type into consideration.
 * 
 * @param fileName
 * @return true if extension is valid for this content type
 */
private boolean extensionValidForContentType(String fileName) {
    boolean valid = false;

    IContentType type = getContentType();
    // there is currently an extension
    if (fileName.lastIndexOf('.') != -1) {
        // check what content types are associated with current extension
        IContentType[] types = Platform.getContentTypeManager().findContentTypesFor(fileName);
        int i = 0;
        while (i < types.length && !valid) {
            valid = types[i].isKindOf(type);
            ++i;
        }
    } else
        valid = true; // no extension so valid
    return valid;
}
项目:IndentGuide    文件:IndentGuidePreferencePage.java   
private void setupContentTypes(final TreeItem parent, final IContentType baseType) {
  final IContentTypeManager manager = Platform.getContentTypeManager();
  final IContentType[] contentTypes = manager.getAllContentTypes();
  for (final IContentType type : contentTypes) {
    if (equals(type.getBaseType(), baseType) && type.isKindOf(textType)) {
      TreeItem item = null;
      if (parent == null) {
        item = new TreeItem(contentTypesTree, SWT.NONE);
      } else {
        item = new TreeItem(parent, SWT.NONE);
      }
      item.setText(type.getName());
      item.setData(type.getId());
      setupContentTypes(item, type);
    }
  }
}
项目:bdf2    文件:ModelFilePage.java   
/**
 * Get list of valid extensions for XML Content type
 * 
 * @return List
 */
List<String> getValidExtensions() {
    if (fValidExtensions == null) {
        IContentType type = Platform.getContentTypeManager()
                .getContentType(ContentTypeID_XML);
        fValidExtensions = new ArrayList<String>(Arrays.asList(type
                .getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
    }
    return fValidExtensions;

}
项目:tm4e    文件:TMPresentationReconciler.java   
private IGrammar findGrammar(ContentTypeInfo info) {
    IGrammar grammar;
    IContentType[] contentTypes = info.getContentTypes();
    // Discover the well grammar from the contentTypes
    grammar = TMEclipseRegistryPlugin.getGrammarRegistryManager().getGrammarFor(contentTypes);
    if (grammar == null) {
        // Discover the well grammar from the filetype
        String fileName = info.getFileName();
        if (fileName != null) {
            String fileType = new Path(fileName).getFileExtension();
            grammar = TMEclipseRegistryPlugin.getGrammarRegistryManager().getGrammarForFileType(fileType);
        }
    }
    return grammar;
}
项目:tm4e    文件:ContentTypeLabelProvider.java   
@Override
public String getColumnText(Object element, int columnIndex) {
    String contentTypeId = (String) element;
    switch (columnIndex) {
    case 0:
        IContentType contentType = Platform.getContentTypeManager().getContentType(contentTypeId);
        if (contentType == null) {
            return contentTypeId;
        }
        return contentType.getName() + " (" + contentType.getId() + ")";
    default:
        return ""; //$NON-NLS-1$
    }
}
项目:tm4e    文件:LanguageConfigurationAutoEditStrategy.java   
private IContentType[] findContentTypes(IDocument document) {
    if (this.document != null && this.document.equals(document)) {
        return contentTypes;
    }
    try {
        ContentTypeInfo info = ContentTypeHelper.findContentTypes(document);
        this.contentTypes = info.getContentTypes();
        this.document = document;
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return contentTypes;
}
项目:typescript.java    文件:IDEResourcesManager.java   
/**
 * Returns the {@link ScriptKindName} from the given file object and null
 * otherwise.
 * 
 * @param fileObject
 * @return the {@link ScriptKindName} from the given file object and null
 *         otherwise.
 */
public ScriptKindName getScriptKind(Object fileObject) {
    String ext = getExtension(fileObject);
    if (ext != null) {
        ext = ext.toLowerCase();
        if (FileUtils.TS_EXTENSION.equals(ext)) {
            return ScriptKindName.TS;
        } else if (FileUtils.TSX_EXTENSION.equals(ext)) {
            return ScriptKindName.TSX;
        } else if (FileUtils.JSX_EXTENSION.equals(ext)) {
            return ScriptKindName.JSX;
        } else if (FileUtils.JS_EXTENSION.equals(ext)) {
            return useJsAsJsx ? ScriptKindName.JSX : ScriptKindName.JS;
        }
    }
    if (fileObject instanceof IFile) {
        try {
            IContentType contentType = ((IFile) fileObject).getContentDescription().getContentType();
            if (contentType != null) {
                String contentTypeId = contentType.getId();
                if (TS_CONTENT_TYPE_ID.equals(contentTypeId)) {
                    return ScriptKindName.TS;
                } else if (TSX_CONTENT_TYPE_ID.equals(contentTypeId)) {
                    return ScriptKindName.TSX;
                } else if (JSX_CONTENT_TYPE_ID.equals(contentTypeId)) {
                    return ScriptKindName.JSX;
                } else if (JS_CONTENT_TYPE_ID.equals(contentTypeId)) {
                    return useJsAsJsx ? ScriptKindName.JSX : ScriptKindName.JS;
                }
            }
        } catch (Exception e) {
            return null;
        }
    }
    return null;
}
项目:Source    文件:EObjectFileConnectorDelegateTests.java   
@Test
public void getContentType() {
    final IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
    final IContentType contentType = contentTypeManager.getContentType("org.eclipse.emf.ecore.xmi");
    final IFileType expected = MappingUtils.getFileTypeRegistry().getFileType(contentType.getId());

    assertEquals(expected, delegate.getFileType());
}
项目:Source    文件:TextFileConnectorDelegateTests.java   
@Test
public void getContentType() {
    final IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
    final IContentType contentType = contentTypeManager.getContentType(IContentTypeManager.CT_TEXT);
    final IFileType expected = MappingUtils.getFileTypeRegistry().getFileType(contentType.getId());

    assertEquals(expected, delegate.getFileType());
}
项目:Source    文件:IdeFileTypeRegistry.java   
/**
 * {@inheritDoc}
 *
 * @see org.eclipse.mylyn.docs.intent.mapping.content.IFileTypeRegistry#isKindOf(java.lang.String,
 *      java.lang.String)
 */
public boolean isKindOf(String typeID, String superTypeID) {
    final boolean res;

    if (registry.isKindOf(typeID, superTypeID)) {
        res = true;
    } else {
        final IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
        final IContentType contentType = contentTypeManager.getContentType(typeID);
        final IContentType superContentType = contentTypeManager.getContentType(superTypeID);
        res = contentType != null && contentType.isKindOf(superContentType);
    }

    return res;
}
项目:default-text-editor    文件:EditorAssociationOverride.java   
@Override
public IEditorDescriptor overrideDefaultEditor(IEditorInput editorInput,
        IContentType contentType, IEditorDescriptor editorDescriptor) {
    // Override with default text editor only if no association is found yet
    if (editorDescriptor == null && editorInput != null
            && editorInput instanceof IURIEditorInput
            && isOverrideEnabled()
            && TextFileDetector.isTextFile((IURIEditorInput) editorInput)) {
        return getTextEditorDescriptor();
    }
    return editorDescriptor;
}
项目:default-text-editor    文件:EditorAssociationOverride.java   
@Override
public IEditorDescriptor overrideDefaultEditor(String fileName,
        IContentType contentType, IEditorDescriptor editorDescriptor) {
    // Override with default text editor only if no association is found yet
    if (editorDescriptor == null && fileName != null && isOverrideEnabled()
            && TextFileDetector.isTextFile(fileName)) {
        return getTextEditorDescriptor();
    }
    return editorDescriptor;
}
项目:che    文件:TextSearchVisitor.java   
private boolean hasBinaryContent(CharSequence seq, IFile file) throws CoreException {
  IContentDescription desc = file.getContentDescription();
  if (desc != null) {
    IContentType contentType = desc.getContentType();
    if (contentType != null
        && contentType.isKindOf(
            Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT))) {
      return false;
    }
  }

  // avoid calling seq.length() at it runs through the complete file,
  // thus it would do so for all binary files.
  try {
    int limit = FileCharSequenceProvider.BUFFER_SIZE;
    for (int i = 0; i < limit; i++) {
      if (seq.charAt(i) == '\0') {
        return true;
      }
    }
  } catch (IndexOutOfBoundsException e) {
  } catch (FileCharSequenceException ex) {
    if (ex.getCause() instanceof CharConversionException) return true;
    throw ex;
  }
  return false;
}