* @param element
* @return label based on IResolve.getIdentifier
*/
public String getText( Object element ) {
if (element instanceof IResolve) {
IResolve resolve = (IResolve) element;
try {
if (resolve instanceof IGeoResource) {
IGeoResource resource = (IGeoResource) resolve;
String title = resource.getTitle();
// This provider should be non-blocking
// if (title == null) {
// IGeoResourceInfo info = resource.getInfo(new NullProgressMonitor());
// if(info != null) {
// title = info.getTitle();
// }
// }
ID id = resource.getID();
if(title == null) {
title = id.labelResource();
}
return title;
} else if (resolve instanceof IService) {
IService service = (IService) resolve;
ID id = service.getID();
String title = service.getTitle();
// if (title == null) {
// IServiceInfo info = service.getInfo(new NullProgressMonitor());
// if (info != null) {
// title = info.getTitle();
// }
// }
if (title == null) {
// we are going to fake something here
String name = id.toString();
name = name.replace('_', ' ');
name = name.replace("%20", " "); //$NON-NLS-1$ //$NON-NLS-2$
return name;
}
if (id.getTypeQualifier() != null) {
return title + "(" + id.getTypeQualifier() + ")";
} else {
return title;
}
} else if (resolve instanceof IProcess) {
IProcess proc = (IProcess) element;
return proc.getInfo(new NullProgressMonitor()).getTitle();
} else if (resolve instanceof ISearch) {
ISearch search = (ISearch) element;
return search.getInfo(new NullProgressMonitor()).getTitle();
} else if (resolve instanceof IResolveFolder) {
IResolveFolder folder = (IResolveFolder) element;
return folder.getID().toString();
} else {
return resolve.getID().toString();
}
} catch (IOException e) {
CatalogUIPlugin.trace("Error fetching the Title for the resource", e); //$NON-NLS-1$
}
}