Improved handling for right mouse click menu on file in Navigator:
[phpeclipse.git] / net.sourceforge.phpeclipse.webbrowser / src / net / sourceforge / phpeclipse / webbrowser / internal / BrowserTableLabelProvider.java
1 /**********************************************************************
2  * Copyright (c) 2003 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 - Initial API and implementation
10  **********************************************************************/
11 package net.sourceforge.phpeclipse.webbrowser.internal;
12
13 import net.sourceforge.phpeclipse.webbrowser.IExternalWebBrowser;
14 import net.sourceforge.phpeclipse.webbrowser.IInternalWebBrowser;
15 import net.sourceforge.phpeclipse.webbrowser.IWebBrowser;
16
17 import org.eclipse.jface.viewers.ILabelProviderListener;
18
19 import org.eclipse.swt.graphics.Image;
20 import org.eclipse.jface.viewers.ITableLabelProvider;
21 /**
22  * Web browser table label provider.
23  */
24 public class BrowserTableLabelProvider implements ITableLabelProvider {
25         /**
26          * BrowserTableLabelProvider constructor comment.
27          */
28         public BrowserTableLabelProvider() {
29                 super();
30         }
31
32         /**
33          * 
34          */
35         public void addListener(ILabelProviderListener listener) { }
36
37         /**
38          * 
39          */
40         public void dispose() { }
41
42         /**
43          * 
44          */
45         public Image getColumnImage(Object element, int columnIndex) {
46                 if (columnIndex == 0) {
47                         if (element instanceof IInternalWebBrowser)
48                                 return ImageResource.getImage(ImageResource.IMG_INTERNAL_BROWSER);
49                         else
50                                 return ImageResource.getImage(ImageResource.IMG_EXTERNAL_BROWSER);
51                 }
52                 return null;
53         }
54
55         /**
56          * Returns the label text for the given column of the given element.
57          *
58          * @param element the object representing the entire row, or
59          *   <code>null</code> indicating that no input object is set
60          *   in the viewer
61          * @param columnIndex the zero-based index of the column in which the label appears
62          */
63         public String getColumnText(Object element, int columnIndex) {
64                 IWebBrowser browser = (IWebBrowser)element;
65                 if (browser instanceof IExternalWebBrowser) {
66                         if (columnIndex == 0)
67                                 return notNull(((IExternalWebBrowser)browser).getName());
68                         else if (columnIndex == 1)
69                                 return notNull(((IExternalWebBrowser)browser).getLocation());
70                         else if (columnIndex == 2)
71                                 return notNull(((IExternalWebBrowser)browser).getParameters());
72                 } else if(browser instanceof IInternalWebBrowser) {
73                         if (columnIndex == 0)
74                                 return notNull(((IInternalWebBrowser)browser).getName());
75                 }
76                 return "";
77         }
78         
79         protected String notNull(String s) {
80                 if (s != null)
81                         return s;
82                 else
83                         return "";
84         }
85
86         /**
87          * 
88          */
89         public boolean isLabelProperty(Object element, String property) {
90                 return false;
91         }
92
93         /**
94          * 
95          */
96         public void removeListener(ILabelProviderListener listener) { }
97 }