It's all about the answers!

Ask a question

How to get RTC Component name from ProjectExplorer view


Suresh P (1166) | asked Sep 11 '13, 8:57 a.m.
retagged Dec 02 '13, 3:54 p.m. by David Lafreniere (4.8k7)

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


Comments
David Lafreniere commented Dec 02 '13, 3:54 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

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
Vijayakumar B (22610) | answered Oct 17 '13, 4:27 p.m.

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.

Your answer


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