KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > javadocexport > JavadocLinkDialogLabelProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.javadocexport;
12
13 import java.net.URL JavaDoc;
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 JavaDoc getText(Object JavaDoc element) {
36         if (element instanceof JavadocLinkRef) {
37             JavadocLinkRef ref= (JavadocLinkRef) element;
38             URL JavaDoc url= ref.getURL();
39             String JavaDoc text= ref.getFullPath().lastSegment();
40             if (url != null) {
41                 Object JavaDoc[] args= new Object JavaDoc[] { 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 JavaDoc 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