Need to open files from the workspace already loaded...would also require to access history of files
For my application, I need to open files programmatically from the workspace already loaded.
What is the starting point for that ? To be specific, a. I need to open workspace files (from my view) which should be editable b. Need to open Compare editor with N-1 version on the right (read-only) and current workspace version (editable) on the left (like it is done while merging.) |
One answer
Here's the implementation for opening local-workspace's file:
public static IFile openLocalFile(final Shell shell, final IWorkbenchPage page, IShareable shareable, boolean open) { try { Object adapter = shareable.getAdapter(IResource.class); if (adapter instanceof IResource) { IResource resource = (IResource) adapter; IFile file = (IFile) resource; if(open) { openFileWithDefaultEditor(page, file); } return file; } else { URI uri = URIUtil.toURI((IPath) shareable.getFullPath().getAdapter(IPath.class)); String editorId = null; try { IEditorDescriptor desc = IDE.getEditorDescriptor(shareable.getLocalPath().getName()); if (desc != null) { editorId = desc.getId(); } } catch (PartInitException e) { StatusUtil.log(UiPlugin.PLUGIN_ID, e); } if (editorId == null) { editorId = EditorsUI.DEFAULT_TEXT_EDITOR_ID; } try { if(open) { IDE.openEditor(page, uri, editorId, true); } } catch (PartInitException e) { StatusUtil.log(UiPlugin.PLUGIN_ID, e); } } return null; } |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.