It's all about the answers!

Ask a question

Load workspace using API

Adam Coulthard (1322116) | asked May 30 '13, 5:45 a.m.

I'm creating a plugin to help our developers to "fast" load a workspace.  For a certain development project there are certain eclipse projects that they would need to load to work.  What I would like to do would be say if I choose this development project from a wizard a new workspace is created and it automatically loads the specific components and eclipse projects that the developer needs.

I've not been able to find anything obvious within the API to take a string "" and pass this into a load mechanism to actually perform the load.

Any suggestions / pointers would be great.



Accepted answer

permanent link
Tim Mok (6.6k38) | answered May 30 '13, 11:05 a.m.
It sounds like you want to just call out to something that will do the load for you with what you specify. You can use  the IOperationFactory.instance.getLoadOperation(LoadDilemmaHandler) to get a load operation but you'll have to supply your own dilemma handler because the Eclipse dilemma handler isn't API. Otherwise, your users won't get the same kind of experience if there are issues during load that need user interaction.

I would recommend looking at load rules to achieve what you want without having to write your own plugin.
Adam Coulthard selected this answer as the correct answer

Adam Coulthard commented May 31 '13, 10:39 a.m. | edited May 31 '13, 10:58 a.m.

 Thanks for the quick answer Tim.  Using the IOperationFactory and the ILoadOperation has worked a treat but I'll definitely have a look into the load rules as well.

Cheers Adam

One other answer

permanent link
Stefano Antoniazzi (1701711) | answered May 11 '16, 8:44 a.m.
edited May 11 '16, 8:50 a.m.
 In general using plain java API here is a trace of what is possible (used in RTC 4.0.7):

IWorkspaceManager workspaceManager = ...
IWorkspaceHandle workspaceHandle = ...
String sandboxPathName = ...
ISharingManager sharingManager = ...
IItemManager itemManager = ...

IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandle, progressMonitor);
IPath sandboxPath = new Path(sandboxPathName);
ILocation sandboxLocation = new PathLocation(sandboxPath);
ISandbox sandbox = sharingManager.getSandbox(sandboxLocation, false);
List<IComponentHandle> componentHandles = workspaceConnection.getComponents();
for (IComponentHandle componentHandle : componentHandles) {
   IComponent component = (IComponent) itemManager.fetchCompleteItem(componentHandle, IItemManager.DEFAULT, progressMonitor);
   IConfiguration configuration = workspaceConnection.configuration(componentHandle);
   Map<String, IVersionableHandle> versionableMap = configuration.childEntriesForRoot(progressMonitor);
   versionableHandles = versionableMap.values();
   LoadDilemmaHandler loadDilemmaHandler = ...
   ILoadOperation loadOperation = IOperationFactory.instance.getLoadOperation(loadDilemmaHandler);
   loadOperation.requestLoad(sandbox,/*IRelativeLocation*/ null, workspaceConnection, componentHandle, versionableHandles);;
   sharingManager.deregister(sandbox, progressMonitor);

Stefano Antoniazzi commented May 11 '16, 10:01 a.m.

 I used a LoadDilemmaHandler similar to what you may find in

Gidi Gal commented Aug 25 '18, 4:58 p.m.
Thanks for sharing this code.
I tried it (working currently on RTC 6.0.6), managed to load workspace into a sandbox.
However, when I try to refresh the sandbox from the RTC client after copying files into it, I don't see any indication in the pending changes view about unresolved files.
Any idea which API call is missing in order for refresh to work correctly ?

Gidi Gal commented Aug 26 '18, 4:23 a.m. | edited Aug 26 '18, 4:25 a.m.
I did not use this line

sharingManager.deregister(sandbox, progressMonitor);

If I call deregister the loaded components are marked as unloaded
and the sandbox is not known in RTC client.

Your answer

Register or 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.