本文整理汇总了Java中org.eclipse.ui.IURIEditorInput类的典型用法代码示例。如果您正苦于以下问题:Java IURIEditorInput类的具体用法?Java IURIEditorInput怎么用?Java IURIEditorInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IURIEditorInput类属于org.eclipse.ui包,在下文中一共展示了IURIEditorInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPathFromInput
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
public static String getPathFromInput(IEditorInput in) {
IResource res = ResourceUtil.getResource(in);
if (res != null) {
try {
if (res.getProject().hasNature(NATURE.ID)) {
return res.getLocation().toOSString();
}
} catch (CoreException ex) {
Log.log(Log.LOG_WARNING, "Nature error", ex); //$NON-NLS-1$
}
}
if (in instanceof IURIEditorInput) {
return Paths.get(((IURIEditorInput) in).getURI()).toString();
} else {
return null;
}
}
示例2: getPath
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
/**
* Gets the {@link IPath} from the given {@link IEditorInput}.
*
* @param editorInput
* the {@link IEditorInput}
* @return the {@link IPath} from the given {@link IEditorInput} if any, <code>null</code> otherwise
*/
public static IPath getPath(final IEditorInput editorInput) {
final IPath path;
if (editorInput instanceof ILocationProvider) {
path = ((ILocationProvider)editorInput).getPath(editorInput);
} else if (editorInput instanceof IURIEditorInput) {
final URI uri = ((IURIEditorInput)editorInput).getURI();
if (uri != null) {
final File osFile = URIUtil.toFile(uri);
if (osFile != null) {
path = Path.fromOSString(osFile.getAbsolutePath());
} else {
path = null;
}
} else {
path = null;
}
} else {
path = null;
}
return path;
}
示例3: isModifiable
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
@Override
public boolean isModifiable(Object element) {
if (isWorkspaceExternalEditorInput(element)) {
URIInfo info= (URIInfo) getElementInfo(element);
if (info != null) {
if (info.updateCache) {
try {
updateCache((IURIEditorInput) element);
} catch (CoreException x) {
handleCoreException(x, "XtextDocumentProvider.isModifiable");
}
}
return info.isModifiable;
}
}
return super.isModifiable(element);
}
示例4: isReadOnly
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
@Override
public boolean isReadOnly(Object element) {
if (isWorkspaceExternalEditorInput(element)) {
URIInfo info= (URIInfo) getElementInfo(element);
if (info != null) {
if (info.updateCache) {
try {
updateCache((IURIEditorInput) element);
} catch (CoreException x) {
handleCoreException(x, "XtextDocumentProvider.isReadOnly");
}
}
return info.isReadOnly;
}
}
return super.isReadOnly(element);
}
示例5: 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;
}
}
示例6: getURI
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
/**
* Returns the URI for the specific editor input.
*
* @param input
* the editor input
* @return the URI, or null if none could be determined
*/
public static URI getURI(IEditorInput input)
{
if (input instanceof IFileEditorInput)
{
return ((IFileEditorInput) input).getFile().getLocationURI();
}
if (input instanceof IURIEditorInput)
{
return ((IURIEditorInput) input).getURI();
}
if (input instanceof IPathEditorInput)
{
return URIUtil.toURI(((IPathEditorInput) input).getPath());
}
return null;
}
示例7: getPath
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
private IPath getPath(IEditorPart otherEditor)
{
IEditorInput input = otherEditor.getEditorInput();
try
{
if (input instanceof IPathEditorInput)
{
return ((IPathEditorInput) input).getPath();
}
URI uri = (URI) input.getAdapter(URI.class);
if (uri != null)
{
return new Path(uri.getHost() + Path.SEPARATOR + uri.getPath());
}
if (input instanceof IURIEditorInput)
{
return URIUtil.toPath(((IURIEditorInput) input).getURI());
}
}
catch (Exception e)
{
}
return null;
}
示例8: getSourceFilePathFromEditorInput
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
private static IPath getSourceFilePathFromEditorInput(IEditorInput editorInput) {
if (editorInput instanceof IURIEditorInput) {
URI uri = ((IURIEditorInput) editorInput).getURI();
if (uri != null) {
IPath path = URIUtil.toPath(uri);
if (path != null) {
return path;
}
}
}
if (editorInput instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) editorInput).getFile();
if (file != null) {
return file.getLocation();
}
}
if (editorInput instanceof ILocationProvider) {
return ((ILocationProvider) editorInput).getPath(editorInput);
}
return null;
}
示例9: partActivated
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
@Override
public void partActivated(IWorkbenchPartReference partRef) {
IEditorPart part = partRef.getPage().getActiveEditor();
if (!(part instanceof AbstractTextEditor))
return;
// log new active file
IEditorInput input = part.getEditorInput();
if (input instanceof IURIEditorInput) {
URI uri = ((IURIEditorInput)input).getURI();
if (uri != null && uri.getPath() != null) {
String currentFile = uri.getPath();
long currentTime = System.currentTimeMillis() / 1000;
if (!currentFile.equals(WakaTime.getDefault().lastFile) || WakaTime.getDefault().lastTime + WakaTime.FREQUENCY * 60 < currentTime) {
WakaTime.sendHeartbeat(currentFile, WakaTime.getActiveProject(), false);
WakaTime.getDefault().lastFile = currentFile;
WakaTime.getDefault().lastTime = currentTime;
}
}
}
}
示例10: getInputPath
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
public IPath getInputPath( IEditorInput input )
{
if ( input instanceof IURIEditorInput )
{
//return new Path( ( (IURIEditorInput) input ).getURI( ).getPath( ) );
URI uri = ( (IURIEditorInput) input ).getURI( );
if(uri == null && input instanceof IFileEditorInput)
return ((IFileEditorInput)input).getFile( ).getFullPath( );
IPath localPath = URIUtil.toPath( uri );
String host = uri.getHost( );
if ( host != null && localPath == null )
{
return new Path( host + uri.getPath( ) ).makeUNC( true );
}
return localPath;
}
if ( input instanceof IFileEditorInput )
{
return ( (IFileEditorInput) input ).getFile( ).getLocation( );
}
return null;
}
示例11: 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;
}
示例12: getExternalFileEditorInput
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
/**
* @return the IEditorInput if we're dealing with an external file (or null otherwise)
*/
public static IEditorInput getExternalFileEditorInput(ITextEditor editor) {
IEditorInput input = editor.getEditorInput();
//only return not null if it's an external file (IFileEditorInput marks a workspace file, not external file)
if (input instanceof IFileEditorInput) {
return null;
}
if (input instanceof IPathEditorInput) { //PydevFileEditorInput would enter here
return input;
}
try {
if (input instanceof IURIEditorInput) {
return input;
}
} catch (Throwable e) {
//IURIEditorInput not added until eclipse 3.3
}
//Note that IStorageEditorInput is not handled for external files (files from zip)
return input;
}
示例13: refreshParser
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
/**
* Use only for non-project parsers
* @param {@link IFileEditorInput} {@link IResource} or null
* @return true if refresh was triggered successfully
*/
private boolean refreshParser(PgDbParser parser, IResource res, IProgressMonitor monitor)
throws InterruptedException, IOException, CoreException {
if (res instanceof IFile && res.getProject().hasNature(NATURE.ID)) {
parser.getObjFromProjFile((IFile) res, monitor);
return true;
}
IEditorInput in = getEditorInput();
if (in instanceof IURIEditorInput) {
IURIEditorInput uri = (IURIEditorInput) in;
IDocument document = getDocumentProvider().getDocument(getEditorInput());
InputStream stream = new ByteArrayInputStream(document.get().getBytes(StandardCharsets.UTF_8));
parser.fillRefsFromInputStream(stream, Paths.get(uri.getURI()).toString(), monitor);
return true;
}
return false;
}
示例14: openStream
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
private InputStream openStream(IEditorInput input) throws CoreException,
IOException {
if (input instanceof IStorageEditorInput) {
final IStorage storage = ((IStorageEditorInput) input).getStorage();
return storage.getContents();
}
if (input instanceof IURIEditorInput) {
final URI uri = ((IURIEditorInput) input).getURI();
return uri.toURL().openStream();
}
throw new IOException("Unsupported input type: " + input.getClass()); //$NON-NLS-1$
}
示例15: createDocumentProvider
import org.eclipse.ui.IURIEditorInput; //导入依赖的package包/类
private IDocumentProvider createDocumentProvider(IEditorInput input2) {
// System.out.println(input2.getClass().toString());
if (input2 instanceof IFileEditorInput) {
return new NCLDocumentProvider();
} else if (input2 instanceof IURIEditorInput) {
NCLTextDocumentProvider docProvider = new NCLTextDocumentProvider();
return docProvider;
} else {
return new TextFileDocumentProvider();
}
}