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