It's all about the answers!

Ask a question

How can I set descriptions on snapshots and baselines programmatically with the JAVA API

Mike Philpot (324) | asked Nov 27 '12, 6:39 a.m.
In the GUI is is possible to set and modify a description for snapshots and baselines. However, our team automates everything. We need to set and/or modify descriptions for snapshots and baselines to mark them after we create and perform operations on them. I know that descriptions can be done through the GUI, but that is useless to us. (i.e. can't be automated.) SCM doesn't have this function on any of the subcommands. So, the API seems our only route.

I didn't see a simple method for doing this in the API, nor did I find any info in the forums after searching around quite a while. I'm probably overlooking something obvious. I somebody could point me in the right direction, I'd really appreciate it. Thanks.

Accepted answer

permanent link
Ralph Schoon (63.2k33646) | answered Nov 28 '12, 12:02 p.m.
edited Nov 28 '12, 12:02 p.m.

If you have the SDK set up, open the baseline properties (where you can rename the baseline) for example and Plug-In Spy the dialog. Use the Eclipse Java Search to find the dialog class and then look into it. The client code to change the properties looks like this:

        final boolean result[] = { true };
        BusyIndicator.showWhile(null, new Runnable() {
            public void run() {
                RepositoryOperation op = new RepositoryOperation() {
                    public void repositoryRun(IProgressMonitor monitor, IStatusCollector problems) throws TeamRepositoryException {
                        SubMonitor progress = SubMonitor.convert(monitor, 4);
                        ITeamRepository repo = ClientRepositoryUtil.getRepository(baseline);
                        IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(repo);
                        IBaselineConnection connection = wm.getBaselineConnection(baseline, progress.newChild(1));
                        if (!NullUtil.equals(baseline.getName(), newName)) {
                            connection.setName(newName, progress.newChild(1));
                        if (!NullUtil.equals(baseline.getComment(), newComment)) {
                            connection.setComment(newComment, progress.newChild(1));
                try {
                    WorkbenchUtil.runBackgroundSave(TempHelper.MONITOR, op, Messages.BaselinePropertyPage_0);
                } catch (CoreException e) {
Mike Philpot selected this answer as the correct answer

Ralph Schoon commented Nov 28 '12, 12:06 p.m.

PS: Please be aware that there are several API's. There are a lot of other frameworks involved such as Eclipse.

Developing for these kinds of API's is not trivial, it is a challenge and always will be. You need a huge amount of stamina to get to example code and find out how to use it. I am doing this for quite some time now and it never gets easy.

Mike Philpot commented Nov 28 '12, 12:42 p.m.

Yep. I agree with you completely. Our group started on this stuff last year and I started this summer. It's a bit daunting. We've managed to figure out how to code up most stuff, but its still easy to get lost. :-)

Mike Philpot commented Nov 28 '12, 3:48 p.m. | edited Nov 28 '12, 3:49 p.m.

Now that I've seen how the GUI is doing things, I think setting the description fields boils down to something like the following:

For baselines:

        connect (baselineHandle).setComment ("The Description Text", getMonitor ());

For snapshots:

        getWorkspaceManager ().setComment (baselineSet, "The Description Text", getMonitor ());

I try these out in our code in the near future and post the results back here.

Thanks again for all the help, esp the pointer the the Plug-in Spy.

Ralph Schoon commented Nov 28 '12, 6:23 p.m. | edited Nov 28 '12, 6:23 p.m.

Please consider to accept one of the answers, it makes it easier to understand questions are closed. (And it adds reputation to whoever answered the question)

Mike Philpot commented Nov 29 '12, 5:45 a.m.

Will definitely do that. Just wanted to try out the above in code first to confirm. Should have something today of all goes well.

Mike Philpot commented Nov 29 '12, 3:06 p.m.

I was able to test these out and they worked great. Thanks again for all the help.

showing 5 of 6 show 1 more comments

2 other answers

permanent link
Ralph Schoon (63.2k33646) | answered Nov 28 '12, 6:48 a.m.
edited Nov 28 '12, 6:51 a.m.
Hi Mike,

I would suggest to read Robin Bobbitt's blog about the Plug In Spy. If you do want to extend RTC it is essential you can find the API by usage such as the new Snapshot Dialog yourself.

If you use the Plug In Spy you can easily find the NewSnapshotDialog which is referenced by where you can find this code:

    private void promptAndCreate(Shell shell, ITeamRepository repo, IWorkspace workspace) {
        NewSnapshotDialog dialog = new NewSnapshotDialog(shell, NLS.bind(Messages.NewSnapshotAction_0, workspace.getName()), repo, workspace);
        if ( == IDialogConstants.OK_ID) {
            createSnapshot(repo, workspace, dialog.getName(), dialog.getComment(), dialog.getCreateNewBaselines(), dialog.getExcludedComponents());

    private void createSnapshot(final ITeamRepository repo, final IWorkspace workspace, final String name, final String comment, final boolean createNewBaselines, final List excludedComponents) {
        getOperationRunner().enqueue(Messages.NewSnapshotAction_1, new RepositoryOperation(repo) {
            public void repositoryRun(IProgressMonitor monitor, IStatusCollector problems) throws TeamRepositoryException {
                SubMonitor progress = SubMonitor.convert(monitor, 100);
                IWorkspaceConnection connection = SCMPlatform.getWorkspaceManager(repo).getWorkspaceConnection(workspace, progress.newChild(10));
                try {
                            excludedComponents, name, comment, createNewBaselines, progress.newChild(90));
                    final AbstractPlaceWrapper wrapper = AbstractPlaceWrapper.newWrapper(connection.getResolvedWorkspace());
                    SnapshotListView.openSearch(getContext().getDisplay(), wrapper);
                } catch (ConflictsProhibitOperationException e) {
                            Messages.NewSnapshotAction_3, IStatus.INFO);

I forgot to mention that the snippets that come with the Plain Java Client Library also contain interesting examples for example Snippet 2 is for SCM. At the end of it you can use

        workspace.createBaseline(component, "Baseline", "Desc", monitor);

to create a baseline.

Mike Philpot commented Nov 28 '12, 11:21 a.m.

Thanks so much for the info.

I was able to bring up the Plug-in Spy; however, I was unable to display any source with it. What I get from it when I look at the active editor class, (in this case: TeamPlacePart2), is the following:

Class File Editor

Source not found

The jar of this class file belongs to container 'External Plug-ins' which does not allow modifications to source attachments on its entries.

Perhaps my client needs some settings to allow access to the source? We are using ver, Build Id:  RTC-I20111006-1106.

The code I'm trying to examine is for the snapshot editor. (Which is what you get if you right click a snapshot in the GUI and hit Open.) As you know, this is where you can set/modify the description of an existing snapshot.

I get a similar result when looking at the Properties page for baselines. Just the same Source not found page in the Class File Editor.

Mike Philpot commented Nov 28 '12, 11:22 a.m. | edited Nov 28 '12, 11:30 a.m.

So, at the moment, I'm still looking through the API. No joy so far...

With a workspace connection I can do something like:

workspace.setDescription ("My description", getMonitor ());

I thought if I had a baseline or baseline set (snapshot) handle that I'd be able to do something similar.

But I don't see any methods which update or set the description. I see a getComment method for snapshots, nothing to even retrieve it for baselines, and nothing for set or update or anything that remotely resembles such for either snapshots or baselines.

Perhaps the GUI is using some internal methods that aren't available to us? Or likely I'm just looking at the wrong code and am missing something?

Anyway, thanks again for the help. Let me know if you can get me pointed in the right direction. Also, it would be great to get the Plug-in Spy to display the actual source; so, if there are some settings/config steps I can do to get that as well, I'd really appreciate it.

Ralph Schoon commented Nov 28 '12, 11:35 a.m.

The Plug in Spy needs the source (the RTC SDK) to be installed to see source. How this can be done is described in (Lab 1) which is back referenced in my blog in various posts, where you might be able to find other useful API too.

Ralph Schoon commented Nov 28 '12, 11:57 a.m.

As a side note, if you don't intent to run the whole workshop and just set up the SDK, just read lab 1, do the installs, but skip the setup and repotools import and start setting up Eclipse with the SDK at

1.4 Complete Setup of Your RTC Eclipse Client

You won't have a debug server, but you would be able to use the Plug-In Spy in just this RTC workspace with the SDK set up.

Mike Philpot commented Nov 28 '12, 12:38 p.m.

Thanks for the info.

I'll go through the lab to see shat I might have missed when setting up my client, but I do have the SDK. We build our own plugin to extend the SCM command line to do stuff for our automation that isn't already provided in SCM. Hopefully, I'll figure it out. I'll post back after I've had a look at lab 1.

Mike Philpot commented Nov 28 '12, 3:41 p.m.

OK, found why I couldn't see the source. I needed to make the SDK active under Window -> Preferences -> Plug-in Development -> Target Platform.

Thanks for the info in the labs.

showing 5 of 6 show 1 more comments

permanent link
kanjbala jawahar (601816) | answered Nov 28 '12, 11:11 p.m.
Just as a note to Philpot's response above:
connect(baselineHandle) essentially gets a baselineConnection and on that object one would call the setComment.

To get a baselineConnection one would do:
SCMPlatform.getWorkspaceManager (ITeamRepository).getBaselineConnection (baselineHandle, IProgressMonitor)

This info. is for anybody else who might be needing the same functionality.

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.