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 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.
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.
The new activityPatternBinding requires a pattern to map to the UI element. The pattern format is
plug-in-identifier + "/" + local-identifier
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.
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:
The final plugin.xml looks as follows.
Does this mechanism also work for the RTC Web UI? I am reasonably sure that this is not the case, unfortunately.
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.