KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > refactoring > nls > search > NLSSearchResultLabelProvider2


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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
12 package org.eclipse.jdt.internal.ui.refactoring.nls.search;
13
14 import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
15
16 import org.eclipse.jdt.internal.corext.util.Messages;
17
18 import org.eclipse.jdt.ui.JavaElementLabels;
19
20 import org.eclipse.swt.graphics.Image;
21
22 import org.eclipse.jdt.internal.ui.search.TextSearchLabelProvider;
23 import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
24
25
26 class NLSSearchResultLabelProvider2 extends TextSearchLabelProvider {
27     
28     private AppearanceAwareLabelProvider fLabelProvider;
29     
30     public NLSSearchResultLabelProvider2(AbstractTextSearchViewPage page) {
31         super(page);
32         fLabelProvider= new AppearanceAwareLabelProvider(JavaElementLabels.ALL_POST_QUALIFIED, 0);
33     }
34     
35     /*
36      * @see org.eclipse.jdt.internal.ui.search.TextSearchLabelProvider#doGetText(java.lang.Object)
37      */

38     protected String JavaDoc doGetText(Object JavaDoc element) {
39         if (element instanceof FileEntry) {
40             FileEntry fileEntry= (FileEntry) element;
41             return fileEntry.getMessage();
42         } else if (element instanceof CompilationUnitEntry) {
43             return ((CompilationUnitEntry)element).getMessage();
44         } else {
45             return Messages.format(NLSSearchMessages.NLSSearchResultLabelProvider2_undefinedKeys, fLabelProvider.getText(element));
46         }
47     }
48     
49     /*
50      * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
51      */

52     public Image getImage(Object JavaDoc element) {
53         if (element instanceof FileEntry)
54             element= ((FileEntry) element).getPropertiesFile();
55         if (element instanceof CompilationUnitEntry)
56             element= ((CompilationUnitEntry)element).getCompilationUnit();
57         
58         return fLabelProvider.getImage(element);
59     }
60     
61     /*
62      * @see org.eclipse.jface.viewers.LabelProvider#dispose()
63      */

64     public void dispose() {
65         fLabelProvider.dispose();
66         fLabelProvider= null;
67         super.dispose();
68     }
69 }
70
Popular Tags