当前位置: 首页>>代码示例>>Java>>正文


Java IContentDescription.getContentType方法代码示例

本文整理汇总了Java中org.eclipse.core.runtime.content.IContentDescription.getContentType方法的典型用法代码示例。如果您正苦于以下问题:Java IContentDescription.getContentType方法的具体用法?Java IContentDescription.getContentType怎么用?Java IContentDescription.getContentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.runtime.content.IContentDescription的用法示例。


在下文中一共展示了IContentDescription.getContentType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isBPM2FileType

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
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;
  }
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:20,代码来源:ActivitiMultiPageEditor.java

示例2: hasTextContentType

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
/**
 * @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;
}
 
开发者ID:iloveeclipse,项目名称:filesync4eclipse,代码行数:23,代码来源:SyncWizard.java

示例3: shouldValidate

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
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;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:24,代码来源:JSONSyntaxValidator.java

示例4: isProfileContentType

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
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;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:ProfileUtil.java

示例5: isJavaPropertiesFile

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
/**
 * Checks whether the passed file editor input defines a Java properties file.
 * 
 * @param element the file editor input
 * @return <code>true</code> if element defines a Java properties file, <code>false</code>
 *         otherwise
 * @throws CoreException
 * 
 * @since 3.7
 */
public static boolean isJavaPropertiesFile(Object element) throws CoreException {
	if (JAVA_PROPERTIES_FILE_CONTENT_TYPE == null || !(element instanceof IFileEditorInput))
		return false;

	IFileEditorInput input= (IFileEditorInput)element;

	IFile file= input.getFile();
	if (file == null || !file.isAccessible())
		return false;

	IContentDescription description= file.getContentDescription();
	if (description == null || description.getContentType() == null || !description.getContentType().isKindOf(JAVA_PROPERTIES_FILE_CONTENT_TYPE))
		return false;

	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:PropertiesFileDocumentProvider.java

示例6: isClassFile

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
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$
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:EditorUtility.java

示例7: visit

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
@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;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:23,代码来源:ConfigRegistry.java

示例8: hasBinaryContent

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:TextSearchVisitor.java

示例9: canHandle

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
/**
 * Check file extension to validate
 */
private boolean canHandle(IFile file) {
	boolean result = false;
	if (file != null) {
		try {
			IContentDescription contentDescription = file
					.getContentDescription();
			if (contentDescription != null) {
				IContentType fileContentType = contentDescription
						.getContentType();
				if (fileContentType.isKindOf(fHTMLContentType)) {
					result = true;
				} else {
					IContentType[] otherTypes = getOtherSupportedContentTypes();
					for (int i = 0; i < otherTypes.length; i++) {
						result = result
								|| fileContentType.isKindOf(otherTypes[i]);
					}
				}
			} else if (fHTMLContentType != null) {
				result = fHTMLContentType.isAssociatedWith(file.getName());
			}
		} catch (CoreException e) {
			// should be rare, but will ignore to avoid logging "encoding
			// exceptions" and the like here.
		}
	}
	return result;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:32,代码来源:WebResourcesValidator.java

示例10: theSelectionIsValid

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
@Override
protected final boolean theSelectionIsValid(final IFile theSelection) {
    try {
        final IContentDescription contentDescription = theSelection.getContentDescription();
        return contentDescription != null && contentDescription.getContentType() != null
                //&& org.ijis.gra.mpd.Activator.CONTENT_TYPE.equals(contentDescription.getContentType().getId())
        		&&"catalog.xml".equals(theSelection.getName())
                && theSelection.getParent() != theSelection.getProject();
    } catch (final CoreException e) {
        // no-op
    }
    return false;
}
 
开发者ID:GRA-UML,项目名称:tool,代码行数:14,代码来源:GRAsppartifact2model.java

示例11: theSelectionIsValid

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
@Override
protected final boolean theSelectionIsValid(final IFile theSelection) {
    try {
        final IContentDescription contentDescription = theSelection.getContentDescription();
        return contentDescription != null && contentDescription.getContentType() != null
                && org.search.niem.mpd.Activator.CONTENT_TYPE.equals(contentDescription.getContentType().getId())
                && theSelection.getParent() != theSelection.getProject();
    } catch (final CoreException e) {
        // no-op
    }
    return false;
}
 
开发者ID:info-sharing-environment,项目名称:NIEM-Modeling-Tool,代码行数:13,代码来源:NIEMmpdartifact2model.java

示例12: hasBinaryContent

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
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;
}
 
开发者ID:agusevas,项目名称:logan,代码行数:28,代码来源:PatternTextSearchVisitor.java


注:本文中的org.eclipse.core.runtime.content.IContentDescription.getContentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。