1 11 package org.eclipse.jdt.internal.ui.javadocexport; 12 13 import java.net.URL ; 14 15 import org.eclipse.swt.graphics.Image; 16 17 import org.eclipse.jface.resource.ImageDescriptor; 18 import org.eclipse.jface.viewers.LabelProvider; 19 20 import org.eclipse.ui.PlatformUI; 21 import org.eclipse.ui.ide.IDE; 22 23 import org.eclipse.jdt.internal.corext.util.Messages; 24 25 import org.eclipse.jdt.ui.ISharedImages; 26 import org.eclipse.jdt.ui.JavaElementImageDescriptor; 27 import org.eclipse.jdt.ui.JavaUI; 28 29 import org.eclipse.jdt.internal.ui.JavaPlugin; 30 import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider; 31 32 33 public class JavadocLinkDialogLabelProvider extends LabelProvider { 34 35 public String getText(Object element) { 36 if (element instanceof JavadocLinkRef) { 37 JavadocLinkRef ref= (JavadocLinkRef) element; 38 URL url= ref.getURL(); 39 String text= ref.getFullPath().lastSegment(); 40 if (url != null) { 41 Object [] args= new Object [] { text, url.toExternalForm() }; 42 return Messages.format(JavadocExportMessages.JavadocLinkDialogLabelProvider_configuredentry, args); 43 } else { 44 return Messages.format(JavadocExportMessages.JavadocLinkDialogLabelProvider_notconfiguredentry, text); 45 } 46 } 47 return super.getText(element); 48 } 49 50 public Image getImage(Object element) { 51 if (element instanceof JavadocLinkRef) { 52 JavadocLinkRef ref= (JavadocLinkRef) element; 53 ImageDescriptor desc; 54 if (ref.isProjectRef()) { 55 desc= PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT); 56 } else { 57 desc= JavaUI.getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_JAR); 58 } 59 if (ref.getURL() == null) { 60 return JavaPlugin.getImageDescriptorRegistry().get(new JavaElementImageDescriptor(desc, JavaElementImageDescriptor.WARNING, JavaElementImageProvider.SMALL_SIZE)); 61 } 62 return JavaPlugin.getImageDescriptorRegistry().get(desc); 63 } 64 return null; 65 } 66 67 } 68 | Popular Tags |