Hiding UI Contributions in the RTC Eclipse Client


Is it possible to hide UI Elements in the RTC Eclipse client? This is a question I have been asked several times already. I always thought it would only be possible to add new UI elements but not hide them. Javier’s initial question and his example on Jazz.net prove that I was completely wrong. Sorry, but I was simply not aware of this capability.

Why is this interesting?

This is interesting, because if you want to extend the RTC Client UI with context menus, you might want to also be able to remove existing UI elements like context menus.

One use case is described in Javier’s question and example. Another example could be to do some checking before someone can complete a change set in the RTC Eclipse UI.There is no extension point that you can use to prevent completing and once it is completed, you can’t reverse the operation. If you could remove the context menu entry and provide a new one that  does some checking before calling the original action, you could greatly enhance this scenario with very few effort.

Just Starting With Extending RTC?

If you just get started with extending Rational Team Concert, or create API based automation, start with the post Learning To Fly: Getting Started with the RTC Java API’s and follow the linked resources.

You should be able to use the following code in this environment and get your own automation or extension working.

The Approach

Javier’s example shows how this can be done based on Activities in Eclipse extending the org.eclipse.ui.activities extensionpoint.

The basic idea here is to define Activities. These Activities can then be bond to

  • Existing Activities – e.g. to make sure the UI defined in an Activity will only be enabled and show if the existing Activity is enabled
  • Categories – to group several activities and enable/disable them together
  • UI Contributions

Now you can enable and disable the UI elements defined by this Activity.

If you don’t enable an activity, the UI element is hidden. Dependent on how the Activity is defined, there are different ways to enable and disable the activity, for example using Categories in the preference, or the Activity API. In addition there is an expression based activation mechanism.

See the Eclipse Documentation for Activities for more information.

Example

Lets stay in the area of the example with completing a change set above. We want to disable the context menu entry for the complete Change set action.

First it is necessary to create the plugin and to create the extension for the Activity. Create the plugin with the name com.ibm.js.team.activity.scm.cscomplete for example. Add an extension to the org.eclipse.ui.activities extension point and use com.ibm.js.team.activity.scm.cscomplete.activity as the id of the Activity.

Now it is possible to add a new activityPatternBinding for the menu item to be hidden and bind it to the the Activity com.ibm.js.team.activity.scm.cscomplete.activity defined before.

The plugin.xml looks like below.

Plug-in XML code

The new activityPatternBinding requires a pattern to map to the UI element. The pattern format is

plug-in-identifier + "/" + local-identifier

This is now the challenge. Where to get the ID’s reqired? As described in the last post, it is possible to use inspection tools such as YARI – Yet Another RCP Inspector, to get this data.

By using the Yari SWT Inspector this information can easily be gathered. Prepare an outgoing change set in the pending changes view. Open the SWT Inspector and set it to mouse down capture mode. Then select the Complete action on the context menu entry. Disable capture mouse down and inspect the data captured.  This screenshot shows the data that was gathered.

YARI SWT Data CaptureThe interesting information is the ID of the action and the ID of the plugin. This data can be copied and pasted over to create the pattern.

The plugin Id is com.ibm.team.filesystem.ide.ui and the Id of the action to hide is com.ibm.team.filesystem.ui.changes.actions.CloseAction.

The pattern follow the rules of java.util.regex. The pattern rues are described here. Please note, that the period is a special character and needs to be escaped. The pattern we are looking for is therefore:

com\.ibm\.team\.filesystem\.ide\.ui/com\.ibm\.team\.filesystem\.ui\.changes\.actions\.CloseAction

The final plugin.xml looks as follows.

Resulting Plugin.xmlIf this plugin is deployed, the complete change set action does not appear any longer in the context menus, as long as the Activity does not get enabled, e.g. using the API.

Does this mechanism also work for the RTC Web UI? I am reasonably sure that this is not the case, unfortunately.

Summary

This allows to further modify the UI of the RTC Eclipse Client (or any other Eclipse based UI’s) and to easily hide UI elements. Since it is also possible to add your own UI elements this allows a fine grained modification especially in the context of extending RTC.

As always, I hope this content helps others out there to get their work done.

Advertisements

About rsjazz

Hi, my name is Ralph. I work for IBM and help colleagues and customers with adopting the Jazz technologies.
This entry was posted in Jazz, RTC, RTC Extensibility and tagged , , , . Bookmark the permalink.

3 Responses to Hiding UI Contributions in the RTC Eclipse Client

  1. Arne Bister says:

    Brilliant, thank you for finding this.

  2. Hina says:

    Hi,

    Thanks a lot for this post. However, I have a few queries :
    1. Can I hide a tab using Activities such that the tab is enabled only when a particular category is selected on the work item?
    2. If answer to above is yes, then the pattern would be the id of the tab that I wish to hide? And would I need to add this code snippet as is to Process Configuration or somewhere else? Can this be done using the UI?
    3. If answer to 1 is No, then can I hide the work item type ( like Task or Story) from the menu File -> New -> Work Item using Activities such that only my team area members can see it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s