1 /*******************************************************************************
2 * Copyright (c) 2000, 2009 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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.search;
13 import org.eclipse.jface.viewers.LabelProvider;
14 import org.eclipse.jface.viewers.StyledCellLabelProvider;
15 import org.eclipse.jface.viewers.StyledString;
17 import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
19 import org.eclipse.jdt.internal.corext.util.Messages;
22 public abstract class TextSearchLabelProvider extends LabelProvider {
24 private AbstractTextSearchViewPage fPage;
26 public TextSearchLabelProvider(AbstractTextSearchViewPage page) {
30 public AbstractTextSearchViewPage getPage() {
34 protected final StyledString getColoredLabelWithCounts(Object element, StyledString coloredName) {
35 String name= coloredName.getString();
36 String decorated= getLabelWithCounts(element, name);
37 if (decorated.length() > name.length()) {
38 StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.COUNTER_STYLER, coloredName);
43 protected final String getLabelWithCounts(Object element, String elementName) {
44 int matchCount= fPage.getInput().getMatchCount(element);
48 return Messages.format(SearchMessages.TextSearchLabelProvider_matchCountFormat, new String[] { elementName, String.valueOf(matchCount)});