A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.phphelp / src / net / sourceforge / phpdt / httpquery / preferences / ConfigurationTableLabelProvider.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.phpdt.httpquery.preferences;
12
13 import net.sourceforge.phpdt.httpquery.config.IConfiguration;
14
15 import org.eclipse.jface.viewers.ILabelProviderListener;
16 import org.eclipse.jface.viewers.ITableLabelProvider;
17 import org.eclipse.swt.graphics.Image;
18
19 /**
20  * Configuration table label provider.
21  */
22 public class ConfigurationTableLabelProvider implements ITableLabelProvider {
23         /**
24          * ConfigurationTableLabelProvider constructor comment.
25          */
26         public ConfigurationTableLabelProvider() {
27                 super();
28         }
29
30         /**
31          * Adds a listener to this label provider. Has no effect if an identical
32          * listener is already registered.
33          * <p>
34          * Label provider listeners are informed about state changes that affect the
35          * rendering of the viewer that uses this label provider.
36          * </p>
37          * 
38          * @param listener
39          *            a label provider listener
40          */
41         public void addListener(ILabelProviderListener listener) {
42         }
43
44         /**
45          * Disposes of this label provider. When a label provider is attached to a
46          * viewer, the viewer will automatically call this method when the viewer is
47          * being closed. When label providers are used outside of the context of a
48          * viewer, it is the client's responsibility to ensure that this method is
49          * called when the provider is no longer needed.
50          */
51         public void dispose() {
52         }
53
54         /**
55          * Returns the label image for the given column of the given element.
56          * 
57          * @param element
58          *            the object representing the entire row, or <code>null</code>
59          *            indicating that no input object is set in the viewer
60          * @param columnIndex
61          *            the zero-based index of the column in which the label appears
62          */
63         public Image getColumnImage(Object element, int columnIndex) {
64                 return null;
65         }
66
67         /**
68          * Returns the label text for the given column of the given element.
69          * 
70          * @param element
71          *            the object representing the entire row, or <code>null</code>
72          *            indicating that no input object is set in the viewer
73          * @param columnIndex
74          *            the zero-based index of the column in which the label appears
75          */
76         public String getColumnText(Object element, int columnIndex) {
77                 IConfiguration configuration = (IConfiguration) element;
78                 if (columnIndex == 0) {
79                         return configuration.getName();
80                 } else if (columnIndex == 1)
81                         return configuration.getType();
82                 // else if (columnIndex == 2)
83                 // return configuration.getUser();
84                 else if (columnIndex == 2)
85                         return configuration.getURL();
86                 else
87                         return "X";
88         }
89
90         protected String notNull(String s) {
91                 if (s != null)
92                         return s;
93                 else
94                         return "";
95         }
96
97         /**
98          * Returns whether the label would be affected by a change to the given
99          * property of the given element. This can be used to optimize a
100          * non-structural viewer update. If the property mentioned in the update
101          * does not affect the label, then the viewer need not update the label.
102          * 
103          * @param element
104          *            the element
105          * @param property
106          *            the property
107          * @return <code>true</code> if the label would be affected, and
108          *         <code>false</code> if it would be unaffected
109          */
110         public boolean isLabelProperty(Object element, String property) {
111                 return false;
112         }
113
114         /**
115          * Removes a listener to this label provider. Has no affect if an identical
116          * listener is not registered.
117          * 
118          * @param listener
119          *            a label provider listener
120          */
121         public void removeListener(ILabelProviderListener listener) {
122         }
123 }