KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.search;
13
14 import org.eclipse.jdt.internal.ui.JavaPluginImages;
15 import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
16 import org.eclipse.swt.graphics.Image;
17
18 class OccurrencesSearchLabelProvider extends TextSearchLabelProvider {
19     
20     public OccurrencesSearchLabelProvider(AbstractTextSearchViewPage page) {
21         super(page);
22     }
23
24     protected String JavaDoc doGetText(Object JavaDoc element) {
25         JavaElementLine jel= (JavaElementLine) element;
26         return jel.getLineContents().replace('\t', ' ');
27     }
28     
29     public Image getImage(Object JavaDoc element) {
30         if (element instanceof OccurrencesGroupKey) {
31             OccurrencesGroupKey group= (OccurrencesGroupKey) element;
32             if (group.isVariable()) {
33                 if (group.isWriteAccess())
34                     return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_WRITEACCESS);
35                 else
36                     return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_READACCESS);
37             }
38             
39         } else if (element instanceof ExceptionOccurrencesGroupKey) {
40             ExceptionOccurrencesGroupKey group= (ExceptionOccurrencesGroupKey) element;
41             if (group.isException())
42                 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
43         }
44         
45         return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_OCCURRENCE);
46     }
47 }
48
Popular Tags