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
9 * IBM - Initial API and implementation
10 **********************************************************************/
11 package net.sourceforge.phpdt.httpquery.preferences;
13 import net.sourceforge.phpdt.httpquery.config.IConfiguration;
15 import org.eclipse.jface.viewers.ILabelProviderListener;
16 import org.eclipse.jface.viewers.ITableLabelProvider;
17 import org.eclipse.swt.graphics.Image;
20 * Configuration table label provider.
22 public class ConfigurationTableLabelProvider implements ITableLabelProvider {
24 * ConfigurationTableLabelProvider constructor comment.
26 public ConfigurationTableLabelProvider() {
31 * Adds a listener to this label provider. Has no effect if an identical
32 * listener is already registered.
34 * Label provider listeners are informed about state changes that affect the
35 * rendering of the viewer that uses this label provider.
39 * a label provider listener
41 public void addListener(ILabelProviderListener listener) {
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.
51 public void dispose() {
55 * Returns the label image for the given column of the given element.
58 * the object representing the entire row, or <code>null</code>
59 * indicating that no input object is set in the viewer
61 * the zero-based index of the column in which the label appears
63 public Image getColumnImage(Object element, int columnIndex) {
68 * Returns the label text for the given column of the given element.
71 * the object representing the entire row, or <code>null</code>
72 * indicating that no input object is set in the viewer
74 * the zero-based index of the column in which the label appears
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();
90 protected String notNull(String s) {
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.
107 * @return <code>true</code> if the label would be affected, and
108 * <code>false</code> if it would be unaffected
110 public boolean isLabelProperty(Object element, String property) {
115 * Removes a listener to this label provider. Has no affect if an identical
116 * listener is not registered.
119 * a label provider listener
121 public void removeListener(ILabelProviderListener listener) {