Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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.)

0 votes



One answer

Permanent link
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;
    }

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,939

Question asked: May 30 '14, 2:25 a.m.

Question was seen: 4,233 times

Last updated: Nov 24 '14, 3:36 a.m.

Confirmation Cancel Confirm