13

Hiding UI Contributions in the RTC Eclipse Client

 3 years ago
source link: https://rsjazz.wordpress.com/2014/03/24/hiding-ui-contributions-in-the-rtc-eclipse-client/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Hiding UI Contributions in the RTC Eclipse Client

Posted on March 24, 2014

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 Capture
The 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.xml
If 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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK