KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > sourcelookup > SourceElementLabelProvider


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.debug.internal.ui.sourcelookup;
12
13 import org.eclipse.core.resources.IResource;
14 import org.eclipse.jface.viewers.ILabelProvider;
15 import org.eclipse.jface.viewers.LabelProvider;
16 import org.eclipse.swt.graphics.Image;
17 import org.eclipse.ui.model.WorkbenchLabelProvider;
18
19 /**
20  * A label provider for source elements.
21  *
22  * @since 3.0
23  */

24 public class SourceElementLabelProvider extends LabelProvider {
25     
26     private ILabelProvider fLabelProvider = null;
27     
28     
29     
30     private ILabelProvider getWorkbenchLabelProvider() {
31         if (fLabelProvider == null) {
32             fLabelProvider = new WorkbenchLabelProvider();
33         }
34         return fLabelProvider;
35     }
36     
37     /* (non-Javadoc)
38      * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
39      */

40     public void dispose() {
41         super.dispose();
42         if (fLabelProvider != null) {
43             fLabelProvider.dispose();
44         }
45     }
46     /* (non-Javadoc)
47      * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
48      */

49     public Image getImage(Object JavaDoc element) {
50         return getWorkbenchLabelProvider().getImage(element);
51     }
52     /* (non-Javadoc)
53      * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
54      */

55     public String JavaDoc getText(Object JavaDoc element) {
56         if (element instanceof IResource) {
57             return SourceElementWorkbenchAdapter.getQualifiedName(((IResource)element).getFullPath());
58         }
59         return getWorkbenchLabelProvider().getText(element);
60     }
61 }
62
Popular Tags