/********************************************************************** * Copyright (c) 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM - Initial API and implementation **********************************************************************/ package net.sourceforge.phpdt.monitor.ui.internal.view; import net.sourceforge.phpdt.monitor.core.IRequest; import net.sourceforge.phpdt.monitor.ui.internal.MonitorUIPlugin; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.swt.graphics.Image; /** * A label provider for the monitor server view. */ public class TreeLabelProvider implements ILabelProvider { /** * TreeLabelProvider constructor comment. */ public TreeLabelProvider() { super(); } /** * Adds a listener to this label provider. Label provider listeners are * informed about state changes that affect the rendering of the viewer * that uses this label provider. * * @param listener a label provider listener */ public void addListener(ILabelProviderListener listener) {} /** * Disposes of this label provider. *
* [Issue: This method should be changed to take a Viewer, * renamed and repurposed to disconnect a label provider from * a viewer. * ] *
*/ public void dispose() {} /** * Returns the image for the label of the given element for use * in the given viewer. * * @param element the element for which to provide the label image * @return the image used to label the element, ornull
* if these is no image for the given object
*/
public Image getImage(Object element) {
if (element instanceof IRequest)
return MonitorUIPlugin.getImage(MonitorUIPlugin.IMG_REQUEST_RESPONSE);
else
return MonitorUIPlugin.getImage(MonitorUIPlugin.IMG_HOST);
}
/**
* Returns the text for the label of the given element for use
* in the given viewer.
*
* @param viewer the viewer that displays the element
* @param element the element for which to provide the label text
* @return the text string used to label the element, or null
* if these is no text label for the given object
*/
public String getText(Object element) {
if (element instanceof IRequest) {
IRequest call = (IRequest) element;
return call.getLabel();
} else if (element instanceof Integer) {
Integer in = (Integer) element;
return "localhost:" + in.intValue();
} else
return element.toString();
}
/**
* Returns whether the label would be affected
* by a change to the given property of the given element.
* This can be used to optimize a non-structural viewer update.
* If the property mentioned in the update does not affect the label,
* then the viewer need not update the label.
*
* @param element the element
* @param property the property
* @return true
if the label would be affected,
* and false
if it would be unaffected
*/
public boolean isLabelProperty(Object element, String property) {
return false;
}
/**
* Removes a listener to this label provider.
* Has no affect if the listener is not registered.
*
* @param listener a label provider listener
*/
public void removeListener(ILabelProviderListener listener) {}
}