How to get full path of file in a CLIENT side plugin?
public void run(AdvisableOperation operation, IProcessConfigurationElement advisorConfiguration, IAdvisorInfoCollector collector, IProgressMonitor monitor) throws TeamRepositoryException {
Object operationData = operation.getOperationData();
if (!(operationData instanceof DeliverOperationData)) {
return;
}
DeliverOperationData data = (DeliverOperationData) operationData;
List<IChangeSetHandle> changeSetHandles = data.getChangeSetHandles();
IRepositoryItemService itemService = getService(IRepositoryItemService.class);
IScmService scmService = getService(IScmService.class);
IItemServiceIterator changeSetIterator = ItemServiceIteratorFactory.INSTANCE.createFetchItemsIterator(itemService, changeSetHandles.toArray(new IItemHandle[changeSetHandles.size()]), IRepositoryItemService.COMPLETE);
while (changeSetIterator.hasNext()) {
IChangeSet changeSet = (IChangeSet) changeSetIterator.next();
if (changeSet == null) {
continue;
}
for (IChange change : (List<IChange>) changeSet.changes()) {
if (change.kind() == IChange.DELETE) {
IVersionableHandle versionableHandle = change.beforeState();
ServiceConfigurationProvider configProvider = ServiceConfigurationProvider.FACTORY.create(
data.getDestWorkspace(), changeSet.getComponent());
public class ExportChange extends AbstractActionDelegate {public ExportChange {}
@Overridepublic void run(Shell shell IWorkbenchPage page, IStructuredSelection selection) {
......
}
One answer
public class ExportChange extends AbstractActionDelegate {
private SnapshotId selectedSnapshot;
public ExportChange() {
}
@Override
public void run(Shell shell, IWorkbenchPage page, IStructuredSelection selection) {
List<ChangeSetWrapper> changeSetWrappers = AdapterUtil.adaptList(selection.toList(), ChangeSetWrapper.class);
List<IActivitySource> sources = AdapterUtil.adaptList(selection.toList(), IActivitySource.class);
for (IActivitySource next : sources) {
List<IRemoteActivity> activities = next.getActivities();
changeSetWrappers.addAll(RemoteActivityAdapter.convertToChangeSetWrappers(activities));
}
if (!changeSetWrappers.isEmpty()) {
ITeamRepository repo = changeSetWrappers.get(0).getRepository();
IScmService scmService = (IScmService) repo.getClientLibrary(IScmService.class);
IWorkspaceManager workspaceManager = (IWorkspaceManager) repo.getClientLibrary(IWorkspaceManager.class);
List<IChangeSet> changeSets = CollectionUtil.filterDupes(ChangeSetWrapper.getChangeSets(changeSetWrappers));
for(IChangeSet changeSet : changeSets) {
for(IChange change : (List<IChange>)changeSet.changes()) {
IVersionableHandle versionableHandle = change.beforeState();
.............
}
}
}
return;
}
}
Comments
I see. So, I guess you can use SCMPlatform to get the IWorkspaceConnection. SCMPlatform.getWorkspaceManager().createWorkspace() or
SCMPlatform.getWorkspaceManager(repo).getWorkspaceConnection().
1 vote
So i still need that the login user should provide a workspace selection so that i can create a IWorkspaceConnection?
If you do not have the workspace context, I think this can help -
IWorkspaceManager wsm= SCMPlatform.getWorkspaceManager(repo);
IVersionableManager vm = wsm.versionableManager();
IVersionable vn = vm.fetchCompleteState(versionableHandle, monitor );
From IVersionable you can then calculate the path. Let me know if it helps.
1 vote
I thought you may also want to check this question - https://jazz.net/forum/questions/49910/how-to-get-an-iconfiguration-from-ichangeset
And the work item - https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=152190
These two talk about how to get workspace using changeset.
1 vote
Thanks for your reply, i know that we must have a workspace/stream to calculate the full path of a file item, and there is no problem to show a dialog to let user to select it.
I don't think Change Explorer stores the path in a way to make it available to someone writing an extension like you yourself.
You can also check out a few more posts -
https://jazz.net/forum/questions/8704/is-it-possible-to-get-the-full-path-name-of-a-ifileitem
https://jazz.net/forum/questions/93557/how-get-full-path-of-the-file-from-changeset-using-api
2 votes
Comments
Surya Tripathi
Jul 10 '13, 7:04 p.m.Not sure exactly where would you want to get the full path, but could you try something like this -
- Get IConfiguration. You can get this from IWorkspaceConnection
- Call locateAncestors(). This will give you INameItemPair.
- You would be able to get the information you need from it.
Please let me know if this works for you.
1 vote