private void openFile(File file, DotGraphView view) { if (view.currentFile == null) { // no workspace file for cur. graph IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path("")); // $NON-NLS-1$ fileStore = fileStore.getChild(file.getAbsolutePath()); if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) { IWorkbenchPage page = view.getSite().getPage(); try { IDE.openEditorOnFileStore(page, fileStore); } catch (PartInitException e) { e.printStackTrace(); } } } else { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IPath location = Path.fromOSString(file.getAbsolutePath()); IFile copy = workspace.getRoot().getFileForLocation(location); IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); if (registry.isSystemExternalEditorAvailable(copy.getName())) { try { view.getViewSite() .getPage() .openEditor(new FileEditorInput(copy), IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID); } catch (PartInitException e) { e.printStackTrace(); } } } }
@Override public IEditorDescriptor getEditorDescriptor(String name, IEditorRegistry editorReg) { IEditorDescriptor editorDesc = null; // next check the OS for in-place editor (OLE on Win32) if (editorReg.isSystemInPlaceEditorAvailable(name)) { editorDesc = editorReg.findEditor(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID); } // next check with the OS for an external editor if (editorDesc == null && editorReg.isSystemExternalEditorAvailable(name)) { editorDesc = editorReg.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID); } // next lookup the default text editor if (editorDesc == null) { editorDesc = editorReg.findEditor(IDEWorkbenchPlugin.DEFAULT_TEXT_EDITOR_ID); } return editorDesc; }