KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > search > TextSearchLabelProvider


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.jdt.internal.ui.search;
12
13 import org.eclipse.jface.viewers.LabelProvider;
14
15 import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
16
17 import org.eclipse.jdt.internal.corext.util.Messages;
18
19 public abstract class TextSearchLabelProvider extends LabelProvider {
20
21     private AbstractTextSearchViewPage fPage;
22     private String JavaDoc fMatchCountFormat;
23
24     public TextSearchLabelProvider(AbstractTextSearchViewPage page) {
25         fPage= page;
26         fMatchCountFormat= SearchMessages.TextSearchLabelProvider_matchCountFormat;
27     }
28     
29     public final String JavaDoc getText(Object JavaDoc element) {
30         int matchCount= fPage.getInput().getMatchCount(element);
31         String JavaDoc text= doGetText(element);
32         if (matchCount < 2)
33             return text;
34         else {
35             return Messages.format(fMatchCountFormat, new Object JavaDoc[] { text, new Integer JavaDoc(matchCount) });
36         }
37     }
38
39     protected abstract String JavaDoc doGetText(Object JavaDoc element);
40 }
41
Popular Tags