IBM Rational Synergy for Eclipse Interface

Programmer’s Guide

Introduction

The IBM® Rational® Synergy for Eclipse Interface provides many extension points that can be used to further extend the capability of the Integration. The integration itself has been written by using its own extension points.

This document is written for the plug-in writers who wish to use the extension points provided by the integration and add additional features to the integration.

Please refer to the section Reference for integration's javadoc.

Architecture

This Integration consists of seven eclipse plug-ins. The plug-ins can be categorized into UI and non-UI plug-ins.

Non UI Plug-ins

Util Plug-in

Connection Plug-in

Core Plug-in

Team Plug-in

Mylyn UI Plug-in

UI Plug-ins

Help Plug-in

UI Plug-in

Extension Plug-in

Mylyn Core Plug-in

The diagram below describes the dependencies among the plug-ins. It also indicates the relationship between extension plug-in and extender plug-in.

Role of Plug-ins

This section explains what role each of the plug-ins plays in the integration.

·          Util Plug-in is used to provide common classes and interfaces used by rest of the plug-ins.

·          Connection Plug-in interacts with IBM Rational Synergy databases. It is responsible for managing sessions and hides the details from the rest of plug-ins. You will never have to use this plug-in.

·          Core Plug-in provides classes and functions used to communicate with IBM Rational Synergy. It uses Connection Plug-in internally. You would use this plug-in to establish connection with IBM Rational Synergy databases and make function calls to access or modify data.

·          Help Plug-in extends Eclipse’s extension points to add online help and context sensitive help for the integration. You will never have to use this plug-in.

·          Team Plug-in extends Eclipse’s extension points to add Team feature to the Integration. This plug-in provides extension point for project set export and import.

·          UI Plug-in extends Eclipse’s extension points to add various views, toolbars and menus. This plug-in provides many extension-points to add actions to views and override the integration’s label decorator.

·          Extension Plug-in extends the extension points provided by the Integration. Most of the functionality of the Integration is contained in this plug-in.

-          Mylyn Core Plugin extends the Eclipse Mylyn core extension points to handle communication between Eclipse Mylyn and IBM Rational Synergy.

-          Mylyn UI Plugin extends the Eclipse Mylyn UI extension points to add IBM Rational Synergy repository specific functionality to the Mylyn views.

 

Data Model

All the views provided by the Integration use the same model. A model works as data provider to the views. The actions in all the views provided by Integration use this model to get contextual data.

The picture below represents the class diagram of the classes involved in model:

 

 

Working with a Connection

To interact with IBM Rational Synergy you need to have the name of the Connection. A Connection uniquely represents a IBM Rational Synergy database.

The code segment below iterates through the list of available connections.

 

 

HashMap map = CorePlugin.getDefault().getConnectionMap();    

for (Iterator it = map.values().iterator(); it.hasNext();)

{

   CMSRegisteredConnectionNew connection = (CMSRegisteredConnectionNew) it.next();                      

   if(connection!=null)

   {

          String connectionName = connection. connectionName;

          // Do something

   }

}

           

 

Getting an Instance of CMApi

To make any call to get data from a IBM Rational Synergy database, you need to have an instance of com.telelogic.synergy.integration.core.cmsessions.CMApi

The following code will get an instance of CMApi for a given Connection connectionName. If the password for this Connection is blank, It will prompt for a password.

 

CMApi api = null;

try

{

   api = UIPlugin.getCCMObject(connectionName);

}catch(CmsException e)

{

   UIPlugin.logMessage(e.toString(),this.getClass().getName(), Message.ERROR);

   UIPlugin.reportMessage(e.toString(),Message.ERROR);

   return false;

} 

 

 

The following code will also get an instance of CMApi for a given Connection connectionName. However, it will not prompt if the password for Connection is blank, because the CorePlugin does not have GUI components. 

 

CMApi api = null;

api = CorePlugin.getCCMObject(connectionName); 

 

Writing to Console

The following code will allow you to write Strings to the Eclipse Console, identified as an Error, Warning, or Information.

 

UIPlugin.reportMessage(messageString,Message.ERROR);   // Error, written in red color

UIPlugin.reportMessage(messageString,Message.WARNING); // Warning written in blue color

UIPlugin.reportMessage(messageString,Message.INFORMATION); // Message written in black color

 

 

Forcing a Default Task

Some IBM Rational Synergy operations require a default task. The following code segment can be used to enforce a default task.

int forcetask=0; 

Display.getDefault().syncExec(new Runnable(){

   public void run() {    

          while forcetask ==0){

              try{

                     forcetask =  UIPlugin.forceDefTask(connectionName);

              }catch(CmsException e){

                     UIPlugin.logMessage(e.toString(), this.getClass().getName(), Message.ERROR);     

                     forcetask =-1;

                     return;

              }     

          }                                                 

   }

});          

if(forcetask==-1) return ;

 

 

Refreshing Team Status and IBM Rational Synergy views

Some team operations change the team status of files and folders. The following code illustrates how to refresh the team status of resources.

 

   final IResource []resset = {res}; //res represents an IResource to

   be refreshed

 

   final ArrayList<IResource> lowlist = UIPlugin.getLowestLevelResources(

   resset);

 

   Display.getDefault().syncExec(new Runnable(){

          public void run()

          {

              ArrayList clist = new ArrayList();

              clist.add(connectionName); // Add all the connections to

              be refreshed

  

          // Refresh Task View   

          CMSTaskView tview = UIPlugin.getTaskViewInstance();

          if(tview=!null && tview.getViewer().getContentProvider()!=null)

              for(int i=0; i< clist.size();i++){

                     String conName = (String) clist.get(i);

                     tview.refreshConnection(conName);

              }

          }

          // Refresh History View

          CMSHistoryView hview = UIPlugin.getHistoryViewInstance();

          if(hview!=null && hview.getViewer().getContentProvider()!=null)

          {

              IResource lres = hview.getCurrentResource();

              if(lres!=null){

                     hview.showHistory(lres);  

              }

          }

  

          // Refresh Repository View

          CMSRepositoryView rview = UIPlugin.getRepositoryViewInstance();

          if(rview!=null &&  rview.getViewer().getContentProvider()!=null)

          {

              for(int i=0; i< clist.size();i++)

              {

                     String conName = (String) clist.get(i);

                    rview.refreshConnection(conName);

              }

          }

 

          // Refresh CR View

          CMSRepositoryView cview = UIPlugin.getChangeRequestViewInstance();

          if(cview!=null &&  cview.getViewer().getContentProvider()!=null)

          {

              for(int i=0; i< clist.size();i++)

              {

                     String conName = (String) clist.get(i);

                     cview.refreshConnection(conName);

              }

          } 

                                                                                            UIPlugin.refreshResource((IResource[])lowlist.toArray(

          new IResource[lowlist.size()]));                                       

          }

    });  

 

 

How to Get Preference Data

While writing a plug-in for the integration you may need to know the current settings of the Team Preference for IBM Rational Synergy. The static data member preference of class com.telelogic.synergy.integration.ui.UIPlugin stores the values of preference settings. This data member is always up to date.

The code segment below demonstrates how to use this variable.

 

PreferenceDefaultData2 tempdata = UIPlugin.preferencenew ;

// The variable tempdata should be not be stored. It is temporary.

Refer to javadoc for description of members of class PreferenceDefaultData

 

 

How to Get Projects Controlled by IBM Rational Synergy

The code segment below demonstrates how to get list of workspace projects controlled by IBM Rational Synergy Team provider.

IProject wrkprojects[] = UIPlugin.getWorkspace().getRoot().getProjects();

ArrayList  plist = new ArrayList();

for(int m=0;m<wrkprojects.length;m++){

   IProject prj = wrkprojects[m];       

   CMSRepositoryProvider provider = (CMSRepositoryProvider)

                    RepositoryProvider.getProvider(

                               prj,  TeamPlugin.getTypeId());

    //TeamPlugin is from package com.telelogic.synergy.integration.team

   if(provider==null)

          continue;

   plist.add(prj);                                          

}