KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search > internal > ui > SearchResultLabelProvider


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 package org.eclipse.search.internal.ui;
12
13 import org.eclipse.swt.graphics.Image;
14
15 import org.eclipse.jface.viewers.ILabelProvider;
16 import org.eclipse.jface.viewers.ILabelProviderListener;
17 import org.eclipse.jface.viewers.LabelProvider;
18
19 import org.eclipse.ui.PlatformUI;
20
21 import org.eclipse.search.ui.ISearchResultViewEntry;
22
23 /**
24  * @deprecated old search
25  */

26 class SearchResultLabelProvider extends LabelProvider {
27     
28     private static final String JavaDoc MATCHES_POSTFIX= " " + SearchMessages.SearchResultView_matches + ")"; //$NON-NLS-1$ //$NON-NLS-2$
29

30     private ILabelProvider fLabelProvider;
31
32     
33     SearchResultLabelProvider(ILabelProvider provider) {
34         fLabelProvider= provider;
35     }
36
37     public String JavaDoc getText(Object JavaDoc element) {
38         StringBuffer JavaDoc buf= new StringBuffer JavaDoc(getLabelProvider().getText(element));
39         int count= ((ISearchResultViewEntry)element).getMatchCount();
40         if (count > 1) {
41             buf.append(" ("); //$NON-NLS-1$
42
buf.append(count);
43             buf.append(MATCHES_POSTFIX);
44         }
45         return buf.toString();
46     }
47     
48     public Image getImage(Object JavaDoc element) {
49         return fLabelProvider.getImage(element);
50     }
51     
52     // Don't dispose since label providers are reused.
53
public void dispose() {
54     }
55
56     ILabelProvider getLabelProvider() {
57         return fLabelProvider;
58     }
59
60     public void addListener(ILabelProviderListener listener) {
61         super.addListener(listener);
62         fLabelProvider.addListener(listener);
63         PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator().addListener(listener);
64     }
65
66     public boolean isLabelProperty(Object JavaDoc element, String JavaDoc property) {
67         return fLabelProvider.isLabelProperty(element, property);
68     }
69
70     public void removeListener(ILabelProviderListener listener) {
71         super.removeListener(listener);
72         fLabelProvider.removeListener(listener);
73         PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator().removeListener(listener);
74     }
75 }
76
Popular Tags