本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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$
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}