Get project area list based on Repository
I'm working on an eclipse based application within which I'm developing a mechanism for users to open RTC work items. I would like the user to be able to select the project area he/she wants to open the work item against based on the repository they have logged into.
Can someone help me to point me in the right direction toget a list of project areas contained within a particular repository. Is this possible using the RTC API?
Currently working with packages within:
com.ibm.team
.repository
.workItem
Can someone help me to point me in the right direction to
Currently working with packages within:
com.ibm.team
.repository
.workItem
2 answers
I was able to figure this out today thanks to a post by "Marly" under a thread titled "Reading the list of project Area".
Here is the final code I will use for this function:
Unrelated... If anyone can advise how the list can be type checked to avoid the use of the suppressed warning, that would be appreciated.
Here is the final code I will use for this function:
@SuppressWarnings("unchecked")
public String [] getProjectAreaList() {
List<IProjectArea> projectAreas = null;
String [] toReturn;
IProcessItemService client = (IProcessItemService) teamRepository.getClientLibrary(IProcessItemService.class);
try {
projectAreas = (List<IProjectArea>) client.findAllProjectAreas(IProcessClientService.ALL_PROPERTIES, null);
} catch (TeamRepositoryException e) {
MyPlugin.println("Unable to obtain project areas list in getProjectAreasList:" + e + ":" + e.getMessage());
return null;
}
toReturn = new String[projectAreas.size()];
for (int i = 0; i < projectAreas.size(); i++)
toReturn[i] = projectAreas.get(i).getName();
return toReturn;
}
Unrelated... If anyone can advise how the list can be type checked to avoid the use of the suppressed warning, that would be appreciated.
I was able to figure this out today thanks to a post by "Marly" under a thread titled "Reading the list of project Area".
Here is the final code I will use for this function:
@SuppressWarnings("unchecked")
public String [] getProjectAreaList() {
List<IProjectArea> projectAreas = null;
String [] toReturn;
IProcessItemService client = (IProcessItemService) teamRepository.getClientLibrary(IProcessItemService.class);
try {
projectAreas = (List<IProjectArea>) client.findAllProjectAreas(IProcessClientService.ALL_PROPERTIES, null);
} catch (TeamRepositoryException e) {
MyPlugin.println("Unable to obtain project areas list in getProjectAreasList:" + e + ":" + e.getMessage());
return null;
}
toReturn = new String[projectAreas.size()];
for (int i = 0; i < projectAreas.size(); i++)
toReturn[i] = projectAreas.get(i).getName();
return toReturn;
}
Unrelated... If anyone can advise how the list can be type checked to avoid the use of the suppressed warning, that would be appreciated.
The code above is passing in a null progress monitor to the Process client library. This is strongly discouraged, because it will result in long-running network calls that can't be cancelled.
Since code like this in the Eclipse client can't be run in the UI thread, you should always be running it in some context that has a progress monitor. Either a Job or some background content provider functions which pass you a monitor.
- Jared