Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get RTC Component name from ProjectExplorer view

Hi,

Im using RTC Eclipse Client v3.0.1.

I have loaded a Java project from RTC Server repository to my Eclipse Workspace. Now in projectExploer view, I can the RTC Component added to the project name as shown below:

<ProjectName> ( <RTC Repository> - <RTC Component>)

Can you let me know how to get the RTC component from ProjectExplorer view of a particular project  programmatically.

Thanks and Regards

Suri

0 votes

Comments

Here's some ideas (I have not tested this yet however).

Items in the package explorer are of type "org.eclipse.core.resources.IResource". (ex: IProject, IFolder, IFile)
If using the RTC SDK, you can try:

String componentName = null;
IResource resource = <get me from a node in the Package Explorer>
IShareable shareable = (IShareable) resource.getAdapter(IShareable.class);
if (shareable  != null) {
   IShare share = shareable.getShare(new NullProgressMonitor());
   if (share != null) {
      componentName = share.getSharingDescriptor().getComponentName();
   }     
}



One answer

Permanent link

I had the same requirement and here is what i did to get them.

Step 1: get the project explorer view part from that get the selection provider

Step 2: Get the tree from the selection provider and get the appropriate project that you need. All the projects will be a first level leaf in this tree.

Step 3: Get the TreeItem of the project on which you need to get the rtc component from.

              (TreeItem can be got either by getSelection or by searching the each treeitem for the project of your concern.

Step 4: Once the required tree item found, get the Text from the tree item and split the text. and get your rtc component name.

Code snippet for your help:

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

IWorkbenchPart viewpart  = page.findView("org.eclipse.ui.navigator.ProjectExplorer");

Tree tree = (Tree) ((TreeViewer) part.getSite().getSelectionProvider()).getControl();
TreeItem[] selTree = tree.getSelection();

choose the tree item that you need.

String decoratedName = treeItem.getText().split(" ");

String[] temp = decoratedName.split(" ");
if (temp.length < 2 || null == temp[1]) {
 return null;
}

String ComponentName =  temp[2].trim().replace(")", "");

(no exception handling shown above, please take care)

Hope this help.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,025
× 1,204
× 169

Question asked: Sep 11 '13, 8:57 a.m.

Question was seen: 6,737 times

Last updated: Dec 02 '13, 3:54 p.m.

Confirmation Cancel Confirm