KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > search > PluginSearchLabelProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.search;
12
13 import org.eclipse.jface.viewers.LabelProvider;
14 import org.eclipse.pde.core.plugin.IPluginBase;
15 import org.eclipse.pde.core.plugin.IPluginExtension;
16 import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
17 import org.eclipse.pde.core.plugin.IPluginImport;
18 import org.eclipse.pde.core.plugin.IPluginObject;
19 import org.eclipse.pde.internal.ui.*;
20 import org.eclipse.search.ui.ISearchResultViewEntry;
21 import org.eclipse.swt.graphics.Image;
22
23
24 public class PluginSearchLabelProvider extends LabelProvider {
25     
26     public PluginSearchLabelProvider() {
27         // Increment reference count for the global label provider
28
PDEPlugin.getDefault().getLabelProvider().connect(this);
29     }
30     
31     public void dispose() {
32         // Allow global label provider to release shared images, if needed.
33
PDEPlugin.getDefault().getLabelProvider().disconnect(this);
34         super.dispose();
35     }
36     
37     /**
38      * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
39      */

40     public Image getImage(Object JavaDoc element) {
41         if (element instanceof ISearchResultViewEntry) {
42             ISearchResultViewEntry entry = (ISearchResultViewEntry)element;
43             return PDEPlugin.getDefault().getLabelProvider().getImage((IPluginObject)entry.getGroupByKey());
44         }
45         return super.getImage(element);
46     }
47
48     
49     /**
50      * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
51      */

52     public String JavaDoc getText(Object JavaDoc element) {
53         if (element instanceof ISearchResultViewEntry) {
54             ISearchResultViewEntry entry = (ISearchResultViewEntry) element;
55
56             IPluginObject object = (IPluginObject)entry.getGroupByKey();
57             
58             if (object instanceof IPluginBase) {
59                 return ((IPluginBase)object).getId();
60             }
61             
62             if (object instanceof IPluginImport) {
63                 return ((IPluginImport)object).getId()
64                     + " - " //$NON-NLS-1$
65
+ object.getPluginModel().getPluginBase().getId();
66             }
67             
68             if (object instanceof IPluginExtension) {
69                 return ((IPluginExtension)object).getPoint()
70                      + " - " //$NON-NLS-1$
71
+ object.getPluginModel().getPluginBase().getId();
72             }
73             
74             if (object instanceof IPluginExtensionPoint) {
75                 return ((IPluginExtensionPoint)object).getFullId();
76             }
77         }
78         
79         return super.getText(element);
80     }
81     
82
83 }
84
Popular Tags