Emulate "Open Local File" action of ChangeExplorer
I want to emulate the "Open Local File" action provided in the ChangeExplorer view in my application. All I have is the change-set information. From my view, I'm able to programmatically open ChangeExplorer view giving it ChangeSetInput.
Now, I want to give another action in my view that would do the "Open Local File" action.
Looked at SDK's OpenLocalFileAction class, which uses IShareable to open a file. How do I create an IShareable from a changeSet ? If that is possible, then I can use the OpenLocalFileAction directly.
Now, I want to give another action in my view that would do the "Open Local File" action.
Looked at SDK's OpenLocalFileAction class, which uses IShareable to open a file. How do I create an IShareable from a changeSet ? If that is possible, then I can use the OpenLocalFileAction directly.
Accepted answer
IShareable doesn't map to a change set. A shareable represents a resource that is shared with RTC. This can be a file so you'll have to look into the change set to get the items.
ISharingManager sharingManager = FileSystemCore.getSharingManager();
With the sharing manager, you can use the items from the change set (the versionables) to find the shareable on disk.
sharingManager.findShareables(versionableHandle, progressMonitor);
ISharingManager sharingManager = FileSystemCore.getSharingManager();
With the sharing manager, you can use the items from the change set (the versionables) to find the shareable on disk.
sharingManager.findShareables(versionableHandle, progressMonitor);
Comments
Thanks Tim. I could achieve "Open Local File" action through following code:
final List<IShareable> shareables = new ArrayList<IShareable>();
ISharingManager sharingManager = FileSystemCore.getSharingManager();
IVersionableHandle versionHandle = (IVersionableHandle) IFileItem.ITEM_TYPE.createItemHandle(UUID.valueOf(fileUUID), UUID.valueOf(stateUUID)); shareables.addAll((List<IShareable>)sharingManager.findShareables(versionHandle, new NullProgressMonitor()));
if(shareables.size() > 0) {
OpenLocalFileAction.openLocalFile(parent.getShell(), getSite().getPage(), shareables.get(0));
}