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