1 11 package org.eclipse.pde.internal.ui.search; 12 13 import org.eclipse.jdt.core.IJavaElement; 14 import org.eclipse.jdt.core.IType; 15 import org.eclipse.jdt.ui.JavaElementLabelProvider; 16 import org.eclipse.pde.core.plugin.IPluginExtensionPoint; 17 import org.eclipse.pde.internal.ui.*; 18 import org.eclipse.search.ui.ISearchResultViewEntry; 19 import org.eclipse.swt.graphics.Image; 20 21 22 public class DependencyExtentLabelProvider extends JavaElementLabelProvider { 23 24 public Image getImage(Object element) { 25 if (element instanceof ISearchResultViewEntry) { 26 ISearchResultViewEntry entry = (ISearchResultViewEntry) element; 27 element = entry.getGroupByKey(); 28 } 29 if (element instanceof IPluginExtensionPoint) 30 return PDEPlugin.getDefault().getLabelProvider().getImage( 31 (IPluginExtensionPoint) element); 32 33 return super.getImage(element); 34 } 35 36 public String getText(Object element) { 37 if (element instanceof ISearchResultViewEntry) { 38 ISearchResultViewEntry entry = (ISearchResultViewEntry) element; 39 element = entry.getGroupByKey(); 40 } 41 if (element instanceof IPluginExtensionPoint) { 42 return ((IPluginExtensionPoint) element) 43 .getPluginModel() 44 .getPluginBase() 45 .getId() 46 + "." + ((IPluginExtensionPoint) element).getId(); 48 } else if (element instanceof IJavaElement) { 49 IJavaElement javaElement = (IJavaElement) element; 50 String text = 51 super.getText(javaElement) 52 + " - " + javaElement 54 .getAncestor(IJavaElement.PACKAGE_FRAGMENT) 55 .getElementName(); 56 if (!(javaElement instanceof IType)) { 57 IJavaElement ancestor = javaElement.getAncestor(IJavaElement.TYPE); 58 if (ancestor == null) 59 ancestor = javaElement.getAncestor(IJavaElement.CLASS_FILE); 60 if (ancestor == null) 61 ancestor = javaElement.getAncestor(IJavaElement.COMPILATION_UNIT); 62 if (ancestor != null) 63 text += "." + ancestor.getElementName(); } 65 return text; 66 } 67 return super.getText(element); 68 } 69 } 70 | Popular Tags |