]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/search/OccurrencesSearchLabelProvider.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / search / OccurrencesSearchLabelProvider.java
CommitLineData
1b2798f6
EK
1/*******************************************************************************
2 * Copyright (c) 2000, 2011 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
12package org.eclipse.jdt.internal.ui.search;
13
14import org.eclipse.swt.graphics.Image;
15
16import org.eclipse.jface.viewers.StyledString;
17import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
18
19import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
20
21import org.eclipse.jdt.internal.corext.util.Messages;
22
23import org.eclipse.jdt.internal.ui.JavaPluginImages;
24
25class OccurrencesSearchLabelProvider extends TextSearchLabelProvider implements IStyledLabelProvider {
26
27 public OccurrencesSearchLabelProvider(AbstractTextSearchViewPage page) {
28 super(page);
29 }
30
31 /* (non-Javadoc)
32 * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
33 */
34 @Override
35 public String getText(Object element) {
36 return getLabelWithCounts(element, internalGetText(element));
37 }
38
39 String getLineNumberLabel(JavaElementLine element) {
40 return Messages.format(SearchMessages.OccurrencesSearchLabelProvider_line_number, new Integer(element.getLine()));
41 }
42
43 private String internalGetText(Object element) {
44 JavaElementLine jel= (JavaElementLine) element;
45 return jel.generated_4416462867979027888(this);
46 }
47
48 private StyledString internalGetRichText(Object element) {
49 JavaElementLine jel= (JavaElementLine) element;
50
51 return jel.generated_739450509809147788(this);
52 }
53
54 @Override
55 public Image getImage(Object element) {
56 if (element instanceof JavaElementLine) {
57 int flags= ((JavaElementLine) element).getFlags();
58 if ((flags & IOccurrencesFinder.F_WRITE_OCCURRENCE) != 0) {
59 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_WRITEACCESS);
60 }
61 if ((flags & IOccurrencesFinder.F_READ_OCCURRENCE) != 0) {
62 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_READACCESS);
63 }
64 if ((flags & IOccurrencesFinder.F_EXCEPTION_DECLARATION) != 0) {
65 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
66 }
67 }
68 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_OCCURRENCE);
69 }
70
71 /* (non-Javadoc)
72 * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
73 */
74 public StyledString getStyledText(Object element) {
75 return getColoredLabelWithCounts(element, internalGetRichText(element));
76 }
77}