/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
public String getText(Object element) {
IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry)element;
switch (entry.getType()) {
case IRuntimeClasspathEntry.PROJECT:
IResource res = entry.getResource();
IJavaElement proj = JavaCore.create(res);
if(proj == null) {
return entry.getPath().lastSegment();
}
else {
return lp.getText(proj);
}
case IRuntimeClasspathEntry.ARCHIVE:
IPath path = entry.getPath();
if (path == null) {
return MessageFormat.format("Invalid path: {0}", new Object[]{"null"}); //$NON-NLS-1$
}
if (!path.isAbsolute() || !path.isValidPath(path.toString())) {
return MessageFormat.format("Invalid path: {0}", new Object[]{path.toOSString()});
}
String[] segments = path.segments();
StringBuffer displayPath = new StringBuffer();
if (segments.length > 0) {
displayPath.append(segments[segments.length - 1]);
displayPath.append(" - "); //$NON-NLS-1$
String device = path.getDevice();
if (device != null) {
displayPath.append(device);
}
displayPath.append(File.separator);
for (int i = 0; i < segments.length - 1; i++) {
displayPath.append(segments[i]).append(File.separator);
}
} else {
displayPath.append(path.toOSString());
}
return displayPath.toString();
case IRuntimeClasspathEntry.VARIABLE:
path = entry.getPath();
IPath srcPath = entry.getSourceAttachmentPath();
StringBuffer buf = new StringBuffer(path.toString());
if (srcPath != null) {
buf.append(" ["); //$NON-NLS-1$
buf.append(srcPath.toString());
IPath rootPath = entry.getSourceAttachmentRootPath();
if (rootPath != null) {
buf.append(IPath.SEPARATOR);
buf.append(rootPath.toString());
}
buf.append(']');
}
// append JRE name if we can compute it
if (path.equals(new Path(JavaRuntime.JRELIB_VARIABLE)) && fLaunchConfiguration != null) {
try {
IVMInstall vm = JavaRuntime.computeVMInstall(fLaunchConfiguration);
buf.append(" - "); //$NON-NLS-1$
buf.append(vm.getName());
} catch (CoreException e) {
}
}
return buf.toString();
case IRuntimeClasspathEntry.CONTAINER:
path = entry.getPath();
if (fLaunchConfiguration != null) {
try {
IJavaProject project = null;
try {
project = JavaRuntime.getJavaProject(fLaunchConfiguration);
} catch (CoreException e) {
}
if (project == null) {
} else {
IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), project);
if (container != null) {
if(container.getDescription().startsWith("Persisted container")){
return container.getPath().toString();
}else{
return container.getDescription();
}
}
}
} catch (CoreException e) {
}
}
return entry.getPath().toString();
case IRuntimeClasspathEntry.OTHER:
IRuntimeClasspathEntry delegate = entry;
if (entry instanceof ClasspathEntry) {
delegate = ((ClasspathEntry)entry).getDelegate();
}
String name = lp.getText(delegate);
if (name == null || name.length() == 0) {