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


Java IURIEditorInput.getURI方法代码示例

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


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

示例1: updateCache

import org.eclipse.ui.IURIEditorInput; //导入方法依赖的package包/类
/**
 * @since 2.3
 */
protected void updateCache(IURIEditorInput input) throws CoreException {
	URIInfo info= (URIInfo) getElementInfo(input);
	if (info != null) {
		java.net.URI uri= input.getURI();
		if (uri != null) {
			boolean readOnly = true;
			String uriAsString = uri.toString();
			URI emfURI = URI.createURI(uriAsString);
			if (emfURI.isFile() && !emfURI.isArchive()) {
				// TODO: Should we use the resource set somehow to obtain the URIConverter for the file protocol?
				// see also todo below, but don't run into a stackoverflow ;-)
				Map<String, ?> attributes = URIConverter.INSTANCE.getAttributes(emfURI, null);
				readOnly = Boolean.TRUE.equals(attributes.get(URIConverter.ATTRIBUTE_READ_ONLY));
			}
			info.isReadOnly=  readOnly;
			info.isModifiable= !readOnly;
		}
		info.updateCache= false;
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:24,代码来源:XtextDocumentProvider.java

示例2: getElementOfInput

import org.eclipse.ui.IURIEditorInput; //导入方法依赖的package包/类
/**
 * Returns the element contained in the EditorInput
 */
Object getElementOfInput(IEditorInput input) {
    if (input instanceof IFileEditorInput) {
        return ((IFileEditorInput) input).getFile();
    }
    if (input instanceof IURIEditorInput) {
        IURIEditorInput iuriEditorInput = (IURIEditorInput) input;
        URI uri = iuriEditorInput.getURI();
        return new File(uri);

    }
    if (input instanceof PydevZipFileEditorInput) {
        PydevZipFileEditorInput pydevZipFileEditorInput = (PydevZipFileEditorInput) input;
        try {
            IStorage storage = pydevZipFileEditorInput.getStorage();
            if (storage instanceof PydevZipFileStorage) {
                PydevZipFileStorage pydevZipFileStorage = (PydevZipFileStorage) storage;
                return pydevZipFileStorage;
            }
        } catch (CoreException e) {
            Log.log(e);
        }

    }
    return null;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:29,代码来源:PydevPackageExplorer.java

示例3: isTextFile

import org.eclipse.ui.IURIEditorInput; //导入方法依赖的package包/类
/**
 * Checks if a file is text or binary.
 * 
 * <p>
 * This method will first check if the file extension is known to be for a
 * binary or a text-based file. If the file extension is unknown then it
 * will try to analyze the file content.
 * </p>
 * 
 * @param input
 *            an editor input of the file
 * @return <code>true</code> if the file is more likely to be text file than
 *         binary file, <code>false</code> otherwise.
 */
public static boolean isTextFile(IURIEditorInput input) {
    if (input == null)
        return false;

    String fileName = input.getName();
    if (fileName == null)
        return false;

    String extension = FilenameUtils.getExtension(fileName).toUpperCase();

    if (KnownTextBasedFileExtensions.set().contains(extension))
        return true;

    if (KnownBinaryFileExtensions.set().contains(extension))
        return false;

    URI uri = input.getURI();
    if (uri != null) {
        InputStream is = null;
        try {
            is = uri.toURL().openStream();
            return TextFileDetector.isTextFile(is);
        } catch (IOException e) {
            // Problem reading the editor input - avoid overriding
        } finally {
            // Make sure the input stream is closed
            close(is);
        }
    }

    return false;
}
 
开发者ID:eclipselabs,项目名称:default-text-editor,代码行数:47,代码来源:TextFileDetector.java

示例4: createFakeCompiltationUnit

import org.eclipse.ui.IURIEditorInput; //导入方法依赖的package包/类
/**
 * Creates a fake compilation unit.
 *
 * @param editorInput the URI editor input
 * @return the fake compilation unit
 * @since 3.3
 */
private ICompilationUnit createFakeCompiltationUnit(IURIEditorInput editorInput) {
	try {
		final URI uri= editorInput.getURI();
		final IFileStore fileStore= EFS.getStore(uri);
		final IPath path= URIUtil.toPath(uri);
		String fileStoreName= fileStore.getName();
		if (fileStoreName == null || path == null)
			return null;

		WorkingCopyOwner woc= new WorkingCopyOwner() {
			/*
			 * @see org.eclipse.jdt.core.WorkingCopyOwner#createBuffer(org.eclipse.jdt.core.ICompilationUnit)
			 * @since 3.2
			 */
			@Override
			public IBuffer createBuffer(ICompilationUnit workingCopy) {
				return new DocumentAdapter(workingCopy, fileStore, path);
			}
		};

		IClasspathEntry[] cpEntries= null;
		IJavaProject jp= findJavaProject(path);
		if (jp != null)
			cpEntries= jp.getResolvedClasspath(true);

		if (cpEntries == null || cpEntries.length == 0)
			cpEntries= new IClasspathEntry[] { JavaRuntime.getDefaultJREContainerEntry() };

		final ICompilationUnit cu= woc.newWorkingCopy(fileStoreName, cpEntries, getProgressMonitor());

		if (!isModifiable(editorInput))
			JavaModelUtil.reconcile(cu);

		return cu;
	} catch (CoreException ex) {
		return null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:46,代码来源:CompilationUnitDocumentProvider.java

示例5: getURI

import org.eclipse.ui.IURIEditorInput; //导入方法依赖的package包/类
@Override
public URI getURI(Object element) {
    if (element instanceof IURIEditorInput) {
        IURIEditorInput editorInput = (IURIEditorInput) element;
        return editorInput.getURI();
    }
    return null;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:9,代码来源:PydevFileEditorInput.java

示例6: getURI

import org.eclipse.ui.IURIEditorInput; //导入方法依赖的package包/类
/**
 * Gets the URI associated with the editor.
 * 
 * @param editor
 * @return
 */
public static URI getURI(IEditorPart editor)
{
	// NOTE: Moved from CommonContentAssistProcessor
	if (editor != null)
	{
		IEditorInput editorInput = editor.getEditorInput();

		if (editorInput instanceof IURIEditorInput)
		{
			IURIEditorInput uriEditorInput = (IURIEditorInput) editorInput;
			return uriEditorInput.getURI();
		}
		if (editorInput instanceof IPathEditorInput)
		{
			IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput;
			return URIUtil.toURI(pathEditorInput.getPath());
		}
		if (editorInput instanceof IFileEditorInput)
		{
			IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
			return fileEditorInput.getFile().getLocationURI();
		}
		try
		{
			if (editorInput instanceof IStorageEditorInput)
			{
				IStorageEditorInput storageEditorInput = (IStorageEditorInput) editorInput;
				IStorage storage = storageEditorInput.getStorage();
				if (storage != null)
				{
					IPath path = storage.getFullPath();
					if (path != null)
					{
						return URIUtil.toURI(path);
					}
				}
			}
		}
		catch (CoreException e)
		{
			IdeLog.logError(CommonEditorPlugin.getDefault(), e);
		}
		if (editorInput instanceof ILocationProviderExtension)
		{
			ILocationProviderExtension lpe = (ILocationProviderExtension) editorInput;
			return lpe.getURI(null);
		}
		if (editorInput instanceof ILocationProvider)
		{
			ILocationProvider lp = (ILocationProvider) editorInput;
			return URIUtil.toURI(lp.getPath(null));
		}
	}

	return null;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:63,代码来源:EditorUtil.java


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