Load workspace using API
Hello,
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 "com.project.name" and pass this into a load mechanism to actually perform the load.
Any suggestions / pointers would be great.
Thanks
Adam
Accepted answer
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.
I would recommend looking at load rules to achieve what you want without having to write your own plugin.
One other answer
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);
loadOperation.run(progressMonitor);
sharingManager.deregister(sandbox, progressMonitor);
}