1 11 package org.eclipse.jdt.internal.debug.ui.jres; 12 13 import java.net.URL ; 14 15 import org.eclipse.core.runtime.IPath; 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.core.runtime.Path; 18 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 19 import org.eclipse.jdt.internal.debug.ui.JDIImageDescriptor; 20 import org.eclipse.jdt.internal.debug.ui.jres.LibraryContentProvider.SubElement; 21 import org.eclipse.jdt.internal.ui.JavaPlugin; 22 import org.eclipse.jdt.internal.ui.JavaPluginImages; 23 import org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry; 24 import org.eclipse.jdt.ui.ISharedImages; 25 import org.eclipse.jdt.ui.JavaUI; 26 import org.eclipse.jface.resource.ImageDescriptor; 27 import org.eclipse.jface.viewers.LabelProvider; 28 import org.eclipse.swt.graphics.Image; 29 30 35 public class LibraryLabelProvider extends LabelProvider { 36 37 private ImageDescriptorRegistry fRegistry= JavaPlugin.getImageDescriptorRegistry(); 38 39 public Image getImage(Object element) { 40 if (element instanceof LibraryStandin) { 41 LibraryStandin library= (LibraryStandin) element; 42 IPath sourcePath= library.getSystemLibrarySourcePath(); 43 String key = null; 44 if (sourcePath != null && !Path.EMPTY.equals(sourcePath)) { 45 key = ISharedImages.IMG_OBJS_EXTERNAL_ARCHIVE_WITH_SOURCE; 46 } else { 47 key = ISharedImages.IMG_OBJS_EXTERNAL_ARCHIVE; 48 } 49 IStatus status = library.validate(); 50 if (!status.isOK()) { 51 ImageDescriptor base = JavaUI.getSharedImages().getImageDescriptor(key); 52 JDIImageDescriptor descriptor= new JDIImageDescriptor(base, JDIImageDescriptor.IS_OUT_OF_SYNCH); 53 return JDIDebugUIPlugin.getImageDescriptorRegistry().get(descriptor); 54 } 55 return JavaUI.getSharedImages().getImage(key); 56 } else if (element instanceof SubElement) { 57 if (((SubElement)element).getType() == SubElement.SOURCE_PATH) { 58 return fRegistry.get(JavaPluginImages.DESC_OBJS_SOURCE_ATTACH_ATTRIB); } 60 return fRegistry.get(JavaPluginImages.DESC_OBJS_JAVADOC_LOCATION_ATTRIB); } 62 return null; 63 } 64 65 public String getText(Object element) { 66 if (element instanceof LibraryStandin) { 67 return ((LibraryStandin)element).getSystemLibraryPath().toOSString(); 68 } else if (element instanceof SubElement) { 69 SubElement subElement= (SubElement) element; 70 StringBuffer text= new StringBuffer (); 71 if (subElement.getType() == SubElement.SOURCE_PATH) { 72 text.append(JREMessages.VMLibraryBlock_0); 73 IPath systemLibrarySourcePath= subElement.getParent().getSystemLibrarySourcePath(); 74 if (systemLibrarySourcePath != null && !Path.EMPTY.equals(systemLibrarySourcePath)) { 75 text.append(systemLibrarySourcePath.toOSString()); 76 } else { 77 text.append(JREMessages.VMLibraryBlock_1); 78 } 79 } else { 80 text.append(JREMessages.VMLibraryBlock_2); 81 URL javadocLocation= subElement.getParent().getJavadocLocation(); 82 if (javadocLocation != null) { 83 text.append(javadocLocation.toExternalForm()); 84 } else { 85 text.append(JREMessages.VMLibraryBlock_1); 86 } 87 } 88 return text.toString(); 89 } 90 return null; 91 } 92 93 } | Popular Tags |