public static IEditorPart editFile(File file, boolean preferIdeEditor) throws IOException, PartInitException { if (file == null || !file.exists() || !file.isFile() || !file.canRead()) { throw new IOException("Invalid file: '" + file + "'"); } IWorkbench workBench = PlatformUI.getWorkbench(); IWorkbenchPage page = workBench.getActiveWorkbenchWindow().getActivePage(); IPath location = Path.fromOSString(file.getAbsolutePath()); IFileStore fileStore = EFS.getLocalFileSystem().getStore(location); FileStoreEditorInput fileStoreEditorInput = new FileStoreEditorInput(fileStore); String editorId = IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID; if (preferIdeEditor) { IEditorDescriptor editorDescriptor = workBench.getEditorRegistry().getDefaultEditor(file.getName()); if (editorDescriptor != null) { editorId = editorDescriptor.getId(); } } return page.openEditor(fileStoreEditorInput, editorId); }
/** * Saves the content as a temp-file, opens it using SQL-editor * and ensures that UTF-8 is used for everything. */ public static void saveOpenTmpSqlEditor(String content, String filenamePrefix) throws IOException, CoreException { Log.log(Log.LOG_INFO, "Creating file " + filenamePrefix); //$NON-NLS-1$ Path path = Files.createTempFile(filenamePrefix + '_', ".sql"); //$NON-NLS-1$ Files.write(path, content.getBytes(StandardCharsets.UTF_8)); IFileStore externalFile = EFS.getLocalFileSystem().fromLocalFile(path.toFile()); IEditorInput input = new FileStoreEditorInput(externalFile); IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .openEditor(input, EDITOR.SQL); if (part instanceof ITextEditor) { IDocumentProvider prov = ((ITextEditor) part).getDocumentProvider(); if (prov instanceof TextFileDocumentProvider) { ((TextFileDocumentProvider) prov).setEncoding(input, ApgdiffConsts.UTF_8); prov.resetDocument(input); } } }
@Override public void setInput(IEditorInput input) { if(input instanceof FileStoreEditorInput){ MessageBox messageBox=new MessageBox(Display.getCurrent().getActiveShell(),SWT.ICON_WARNING); messageBox.setText(Messages.WARNING); messageBox.setMessage(Messages.JOB_OPENED_FROM_OUTSIDE_WORKSPACE_WARNING); messageBox.open(); } try { GenrateContainerData genrateContainerData = new GenrateContainerData(); genrateContainerData.setEditorInput(input, this); if(StringUtils.equals(this.getJobName()+Messages.JOBEXTENSION, input.getName()) || StringUtils.equals(this.getJobName(), Messages.ELT_GRAPHICAL_EDITOR)){ container = genrateContainerData.getContainerData(); }else{ this.setPartName(input.getName()); } super.setInput(input); } catch (CoreException | IOException ce) { logger.error("Exception while setting input", ce); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().dispose(); MessageDialog.openError(new Shell(), "Error", "Exception occured while opening the graph -\n"+ce.getMessage()); } }
private Container openEditor(IPath jobFilePath) throws CoreException { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (!isJobAlreadyOpen(jobFilePath)) { if (ResourcesPlugin.getWorkspace().getRoot().getFile(jobFilePath).exists()) { IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(jobFilePath); IDE.openEditor(page, iFile); } else { if (jobFilePath.toFile().exists()) { IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(jobFilePath.toFile()); IEditorInput store = new FileStoreEditorInput(fileStore); IDE.openEditorOnFileStore(page, fileStore); } } return SubJobUtility.getCurrentEditor().getContainer(); }else MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Unable to open subjob : "+jobFilePath.lastSegment()+" Subjob is already open \n" + "Please close the job and retry"); return null; }
@Override public IEditorInput getEditorInput(Object element) { if (element instanceof ILineBreakpoint) { return new FileEditorInput((IFile) ((ILineBreakpoint) element).getMarker().getResource()); } IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(element.toString())); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile[] files = root.findFilesForLocationURI(fileStore.toURI()); if (files != null) { for (IFile file : files) { if (file.exists()) { return new FileEditorInput(file); } } } return new FileStoreEditorInput(fileStore); }
private IPath getFilePath(ITextEditor textEditor) { IEditorInput editorInput = textEditor.getEditorInput(); IFile file = ResourceUtil.getFile(editorInput); File localFile = null; if (file != null) { localFile = file.getLocation().toFile(); } else if (editorInput instanceof FileStoreEditorInput) { FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) editorInput; URI uri = fileStoreEditorInput.getURI(); IFileStore location = EFS.getLocalFileSystem().getStore(uri); try { localFile = location.toLocalFile(EFS.NONE, null); } catch (CoreException e) { // ignore } } if (localFile == null) { return null; } else { return Path.fromOSString(localFile.toString()); } }
/** * Adapted from {@link ProductEditor}, replacing references to * {@link ProductInputContext}. */ @Override protected void createSystemFileContexts(InputContextManager manager, FileStoreEditorInput input) { File file = new File(input.getURI()); if (file != null) { String name = file.getName(); if (name.endsWith(".product")) { IFileStore store; try { store = EFS.getStore(file.toURI()); IEditorInput in = new FileStoreEditorInput(store); manager.putContext(in, new ProductXMLInputContext(this, in, true)); } catch (CoreException e) { PDEPlugin.logException(e); } } } }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { IFile file = null; if (input instanceof FileStoreEditorInput) { input = FileUtils.checkAndConvertEditorInput(input, new NullProgressMonitor()); init(site, input); return; } else if (input instanceof IFileEditorInput) { file = ((IFileEditorInput) input).getFile(); } try { getJrContext(file); setSite(site); setPartName(input.getName()); setInput(input); } catch (Exception e) { throw new PartInitException(e.getMessage(), e); } }
private void setTitlePath() { String titlePath = null; if (lastActiveEditor != null) { IEditorInput editorInput = lastActiveEditor.getEditorInput(); if (editorInput instanceof IFileEditorInput) { titlePath = computeTitlePath((IFileEditorInput) editorInput); } else if (editorInput instanceof FileStoreEditorInput) { titlePath = computeTitlePath((FileStoreEditorInput) editorInput); } } titlePathUpdater.updateTitlePath(getWindowConfigurer().getWindow() .getShell(), titlePath); }
public Object getAdapter(Object adaptableObject, Class adapterType) { if (IUniformResource.class == adapterType) { if (adaptableObject instanceof FileStoreEditorInput) { return new FileStoreEditorInputUniformResource((FileStoreEditorInput) adaptableObject); } } else if (IFile.class == adapterType) { if (adaptableObject instanceof FileStoreEditorInput) { URI uri = ((FileStoreEditorInput) adaptableObject).getURI(); IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri); if (files.length == 1) { return files[0]; } } } return null; }
/** * Returns the resource file that the editor belongs to. * * @param editor * @return */ public static IFile getEditorFile(AbstractThemeableEditor editor) { IEditorInput editorInput = editor.getEditorInput(); if (editorInput instanceof IFileEditorInput) { IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput; return fileEditorInput.getFile(); } else if (editorInput instanceof FileStoreEditorInput) { FileStoreEditorInput input = (FileStoreEditorInput) editorInput; IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(input.getURI()); if (files != null && files.length > 0) { return files[0]; } } return null; }
/** * 获取数据源 * @param editorInput * @return ; */ @SuppressWarnings("unchecked") public T getDataSource(IEditorInput editorInput) { if (editorInput instanceof FileEditorInput) { if (editorInput instanceof FileEditorInput) { FileEditorInput fileEditorInput = (FileEditorInput) editorInput; IFile file = fileEditorInput.getFile(); return this.getDataSource(file); } } else if (editorInput instanceof FileStoreEditorInput) { FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) editorInput; Object obj = map.get(generateKey(fileStoreEditorInput)); if (dataSourceClass.isInstance(obj)) { return (T) obj; } } return null; }
/** * Returns the file current viewed in the editor as an IFile Object so it can be passed to other * calls. If there is NO such file it will throw an Assertion Error. * * @return */ public static IFile getFile() { IFile file = null; IWorkbenchWindow win = getWorkBenchWindow(); IWorkbenchPage page = win.getActivePage(); if (page != null) { IEditorPart editor = page.getActiveEditor(); if (editor != null) { IEditorInput input = editor.getEditorInput(); if (input instanceof IFileEditorInput) { file = ((IFileEditorInput) input).getFile(); } else if (input instanceof FileStoreEditorInput) { // What goes here? } } } if (file == null) { throw new AssertionError("null file returned"); } return file; }
@Override public void init( IEditorSite site, IEditorInput input ) throws PartInitException { super.init( site, input ); if ( input instanceof IFileEditorInput ) { String fileName = ( (IFileEditorInput) input ).getFile( ) .getLocation( ) .toOSString( ); setFileName( fileName ); int index = fileName.lastIndexOf( File.separator ); setPartName( fileName.substring( index + 1, fileName.length( ) ) ); } else if ( input instanceof FileStoreEditorInput ) { setFileName( ( (FileStoreEditorInput) input ).getURI( ) .getRawPath( ) ); setPartName( ( (FileStoreEditorInput) input ).getName( ) ); } }
@Override public IAdaptable createElement(IMemento memento) { String fileStr = memento.getString(TAG_FILE); if (fileStr == null || fileStr.length() == 0) { return null; } String zipPath = memento.getString(TAG_ZIP_PATH); final File file = new File(fileStr); if (zipPath == null || zipPath.length() == 0) { //return EditorInputFactory.create(new File(file), false); final URI uri = file.toURI(); IFile[] ret = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri, IContainer.INCLUDE_HIDDEN | IContainer.INCLUDE_PHANTOMS | IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS); if (ret != null && ret.length > 0) { return new FileEditorInput(ret[0]); } try { return new FileStoreEditorInput(EFS.getStore(uri)); } catch (CoreException e) { return new PydevFileEditorInput(file); } } return new PydevZipFileEditorInput(new PydevZipFileStorage(file, zipPath)); }
@Override public IStructuredSelection findSelection(IEditorInput input) { IFile file = ResourceUtil.getFile(input); if (file != null) { return new StructuredSelection(file); } IFileStore fileStore = (IFileStore) input.getAdapter(IFileStore.class); if (fileStore == null && input instanceof FileStoreEditorInput) { URI uri = ((FileStoreEditorInput)input).getURI(); try { fileStore = EFS.getStore(uri); } catch (CoreException e) { } } if (fileStore != null) { return new StructuredSelection(fileStore); } return StructuredSelection.EMPTY; }
private IDocumentProvider createDocumentProvider(IEditorInput input) { if (input instanceof FileStoreEditorInput) { return new BatchTextFileDocumentProvider(); } else { return new BatchFileDocumentProvider(); } }
protected final IEditorPart openEditor(String filePath) throws PartInitException { IPath location = Path.fromOSString(filePath); IFileStore fileStore = EFS.getLocalFileSystem().getStore(location); FileStoreEditorInput fileStoreEditorInput = new FileStoreEditorInput(fileStore); String editorId = IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID; IEditorDescriptor editorDescriptor = getWorkbench().getEditorRegistry().getDefaultEditor(filePath); if (editorDescriptor != null) { editorId = editorDescriptor.getId(); } return openEditor(fileStoreEditorInput, editorId); }
private IDocumentProvider createDocumentProvider(IEditorInput input) { if (input instanceof FileStoreEditorInput) { return new BashTextFileDocumentProvider(); } else { return new BashFileDocumentProvider(); } }
@Override public void run() { try { Path p = Files.createTempFile(Messages.ImprovePerformanceJdbcLoader_performance_helpers + '_', ".sql"); //$NON-NLS-1$ Files.write(p, JdbcQueries.getHelperFunctions(version).getBytes()); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor( new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile(p.toFile())), EDITOR.SQL); } catch (PartInitException | IOException e) { ExceptionNotifier.notifyDefault(Messages.JdbcPerfVersionsDynamic_jdbc_helper_error, e); } }
private IProject getProjectFromActiveGraph() { if(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()!=null) { IEditorInput editorInput=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput(); if(editorInput instanceof IFileEditorInput){ return ((IFileEditorInput)editorInput).getFile().getProject(); }else if(editorInput instanceof FileStoreEditorInput){ new CustomMessageBox(SWT.ERROR ,Messages.ERROR_WHILE_LOADING_CONFIGURATIONS_FOR_EXTERNAL_JOBS,Messages.TITLE_FOR_PROBLEM_IN_LOADING_EXPRESSION_EDITOR).open(); } } return null; }
/** * Sets the editor input. * * @param editorInput * the editor input * @param eltGraphicalEditorInstance * the elt graphical editor instance */ public void setEditorInput(IEditorInput editorInput, ELTGraphicalEditor eltGraphicalEditorInstance) { logger.debug("setEditorInput - "); if((ELTGraphicalEditorInput.class).isAssignableFrom(editorInput.getClass())) {this.editorInput = new GraphicalEditorContiner(editorInput,eltGraphicalEditorInstance);} else{ if((IFileEditorInput.class).isAssignableFrom(editorInput.getClass())) this.editorInput= new FileEditorContainer(editorInput,eltGraphicalEditorInstance); else if((FileStoreEditorInput.class).isAssignableFrom(editorInput.getClass())) this.editorInput=new FileStorageEditorContainer(editorInput,eltGraphicalEditorInstance); } }
private void loadFileAndDeleteSubjobProperties() { if(getEditorInput() instanceof IFileEditorInput){ FileEditorInput fileEditorInput=(FileEditorInput) getEditorInput(); stroeFileInWorkspace(fileEditorInput.getFile()); }else if(getEditorInput() instanceof FileStoreEditorInput){ FileStoreEditorInput fileStoreEditorInput=(FileStoreEditorInput) getEditorInput(); stroeFileInLocalFS(fileStoreEditorInput.getToolTipText()); } }
private IDocumentProvider createDocumentProvider(IEditorInput input) { if (input instanceof FileStoreEditorInput) { return createFileStoreEditorInputProvider(); } else { return createStandardEditorInputProvider(); } }
private static IEditorInput getEditorInput(final String path) { final IFile file = Resources.getFileForLocation(path); if (file != null) { return new FileEditorInput(file); } else { // file is outside of workbench final IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(path)); final IFileInfo fetchInfo = fileStore.fetchInfo(); if (fetchInfo.isDirectory() || !fetchInfo.exists()) { return null; // ensure the file exists } return new FileStoreEditorInput(fileStore); } }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { if (input instanceof FileStoreEditorInput) { throw new PartInitException("An error occured while opening the file.\n\n" + "This might have happened because you tried to open a statechart with File->Open File.\n" + "This is not supported. Please import the file into a project instead."); } super.init(site, input); }
/** * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) */ public void doSave(IProgressMonitor monitor) { // Retrieves the file input. IEditorInput editorInput = this.getEditorInput(); IFile ifile = null; File file = null; if (editorInput instanceof IFileEditorInput) { ifile = ((IFileEditorInput) editorInput).getFile(); } else { URI fileuri = ((FileStoreEditorInput) editorInput).getURI(); file = new File(fileuri.getPath()); } // save now doSave(monitor, ifile, file); }
/** * Retrieves a doxyfile from the active editor. * * @param window a reference to a workbench window * * @return a doxfile retrieved from the active editor input. */ private static Doxyfile getDoxyfileFromActiveEditor(IWorkbenchWindow window) { IFile ifile = null; File file = null; IWorkbenchPage activePage = window.getActivePage(); IEditorPart activeEditorPart = activePage != null ? window.getActivePage().getActiveEditor() : null; if (activeEditorPart != null) { IEditorInput input = activeEditorPart.getEditorInput(); if (input instanceof IFileEditorInput) { ifile = ((IFileEditorInput) input).getFile(); } else if (input instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) input; ifile = (IFile) adaptable.getAdapter(IFile.class); if (ifile == null) { if (adaptable instanceof FileStoreEditorInput) { URI fileuri = ((FileStoreEditorInput) adaptable).getURI(); file = new File(fileuri.getPath()); } else { file = (File) adaptable.getAdapter(File.class); } } } if (ifile != null && !Doxyfile.isDoxyfile(ifile)) { ifile = null; } } if (ifile != null || file != null) { return new Doxyfile(ifile, file); } else { return null; } }
/** * The <code>MultiPageEditorExample</code> implementation of this method * checks that the input is an instance of <code>IFileEditorInput</code> of * <code>FileStoreEditorInput</code> for the external file. In case of external * file a link is created into an appropriate project folder. */ @Override public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException { file = null; if (editorInput instanceof IFileEditorInput) { file = ((IFileEditorInput) editorInput).getFile(); if (MsgEditorPreferences.isBuilderSetupAutomatically()) { IProject p = file.getProject(); if (p != null && p.isAccessible()) { ToggleNatureAction.addOrRemoveNatureOnProject(p, true, true); } } } else if (editorInput instanceof FileStoreEditorInput) { FileStoreEditorInput input = (FileStoreEditorInput)editorInput; file = createLinkedResource(input.getURI().getRawPath()); } if (file != null){ try { messagesBundleGroup = MessagesBundleGroupFactory.createBundleGroup(site, file); } catch (MessageException e) { throw new PartInitException("Cannot create bundle group.", e); //$NON-NLS-1$ } messagesBundleGroup.addMessagesBundleGroupListener(getMsgBundleGroupListner()); markers = new MessagesEditorMarkers(messagesBundleGroup); setPartName(messagesBundleGroup.getName()); setTitleImage(UIUtils.getImage(UIUtils.IMAGE_RESOURCE_BUNDLE)); closeIfAreadyOpen(site, file); super.init(site, editorInput); keyTreeModel = new AbstractKeyTreeModel(messagesBundleGroup); initRAP(); } else { throw new PartInitException("Unable to load the selected file"); //$NON-NLS-1$ } }
public static String getFileExtension(IEditorInput editorInput) { String fileExtention = ""; //$NON-NLS-1$ if (editorInput instanceof FileStoreEditorInput) { String path = ((FileStoreEditorInput) editorInput).getURI().getPath(); fileExtention = path.substring(path.lastIndexOf(".") + 1, path.length()); //$NON-NLS-1$ } else if (editorInput instanceof IFileEditorInput) { fileExtention = ((IFileEditorInput) editorInput).getFile().getFileExtension(); } else if (editorInput instanceof JarEntryEditorInput) { fileExtention = ((JarEntryEditorInput) editorInput).getStorage().getFullPath().getFileExtension(); } return fileExtention; }
public static IEditorInput checkAndConvertEditorInput(IEditorInput editorInput, IProgressMonitor monitor) throws PartInitException { if (editorInput instanceof FileStoreEditorInput) { try { FileStoreEditorInput fsei = (FileStoreEditorInput) editorInput; IFile file = getInProjectFile(fsei.getURI(), monitor); editorInput = new FileEditorInput(file); } catch (CoreException e) { throw new PartInitException(e.getMessage(), e); } } return editorInput; }
/** * 设置数据源 * @param editorInput * @param dataSource * @return ; */ public boolean setDataSource(IEditorInput editorInput, T dataSource) { if (editorInput instanceof FileEditorInput) { FileEditorInput fileEditorInput = (FileEditorInput) editorInput; IFile file = fileEditorInput.getFile(); return setDataSource(file, dataSource); } else if (editorInput instanceof FileStoreEditorInput) { FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) editorInput; map.put(generateKey(fileStoreEditorInput), dataSource); return true; } return false; }
@Override public void init(IEditorSite editorSite, IEditorInput editorInput) throws PartInitException { _editorInput = editorInput; _designerProject = ((BluemixManifestEditorInput)_editorInput).getDesignerProject(); // Setup the bean and the bean loader _beanLoader = new ManifestBeanLoader("bluemix.manifest", (FileStoreEditorInput) editorInput, this); // $NON-NLS-1$ _bean = new ManifestBean((FileStoreEditorInput)editorInput); super.init(editorSite, editorInput); getSite().setSelectionProvider(this); }
private IDocumentProvider createDocumentProvider(IEditorInput input) { if (input instanceof IStorageEditorInput){ return new RustDocumentProvider(); } else if(input instanceof IFileEditorInput || input instanceof FileStoreEditorInput) { return new RustTextDocumentProvider(); } throw new Error("Got IEditorInput of type " + input.getClass()); }
public IEditorInput createEditorInput( Object file ) { if (file instanceof File) { File handle = (File)file; String fileName = handle.getAbsolutePath( ); IWorkspace space = ResourcesPlugin.getWorkspace( ); IWorkspaceRoot root = space.getRoot( ); try { //IFile[] resources = root.findFilesForLocationURI( new URL("file:///" + fileName ).toURI( ) ); //$NON-NLS-1$ IFile[] resources = root.findFilesForLocationURI(new File( fileName ).toURI( ) ); //$NON-NLS-1$ if (resources != null && resources.length > 0) { IEditorInput input = new FileEditorInput(resources[0]); return input; } else { IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(fileName)); IFileInfo fetchInfo = fileStore.fetchInfo(); if (!fetchInfo.isDirectory() && fetchInfo.exists()) { return new FileStoreEditorInput(fileStore); } } } catch(Exception e) { return null; } } return null; }
private static IEditorInput getEditorInput(IFileStore fileStore) { IFile workspaceFile = getWorkspaceFile(fileStore); if (workspaceFile != null) { return new FileEditorInput(workspaceFile); } return new FileStoreEditorInput(fileStore); }
/** * Creates an editor input for the passed file. * * If forceExternalFile is True, it won't even try to create a FileEditorInput, otherwise, * it will try to create it with the most suitable type it can * (i.e.: FileEditorInput, FileStoreEditorInput, PydevFileEditorInput, ...) */ public static IEditorInput create(File file, boolean forceExternalFile) { IPath path = Path.fromOSString(FileUtils.getFileAbsolutePath(file)); if (!forceExternalFile) { //May call again to this method (but with forceExternalFile = true) IEditorInput input = new PySourceLocatorBase().createEditorInput(path, false, null, null); if (input != null) { return input; } } IPath zipPath = new Path(""); while (path.segmentCount() > 0) { if (path.toFile().exists()) { break; } zipPath = new Path(path.lastSegment()).append(zipPath); path = path.uptoSegment(path.segmentCount() - 1); } if (zipPath.segmentCount() > 0 && path.segmentCount() > 0) { return new PydevZipFileEditorInput(new PydevZipFileStorage(path.toFile(), zipPath.toPortableString())); } try { URI uri = file.toURI(); return new FileStoreEditorInput(EFS.getStore(uri)); } catch (Throwable e) { //not always available! (only added in eclipse 3.3) return new PydevFileEditorInput(file); } }
public static IEditorInput getBestEditorInputForUri(URI uri, int memberFlags) { IFile[] files = ResourceUtils.getWorkspaceRoot().findFilesForLocationURI(uri, memberFlags); if(files.length != 0) { // As an improvement, if there is more than one file, we could try to see which one is more relevant // instead of just using the first one. IFile file = files[0]; return new FileEditorInput(file); } else { //file not in workspace IFileStore fileOnLocalDisk = EFS.getLocalFileSystem().getStore(uri); return new FileStoreEditorInput(fileOnLocalDisk); } }