01: /*******************************************************************************
02: * Copyright (c) 2006 IBM Corporation.
03: * Licensed Material - Property of IBM. All rights reserved.
04: * US Government Users Restricted Rights - Use, duplication or disclosure
05: * restricted by GSA ADP Schedule Contract with IBM Corp.
06: *
07: * Contributors:
08: * IBM Corporation - initial API and implementation
09: *******************************************************************************/package org.eclipse.ui.examples.navigator;
10:
11: import org.eclipse.jface.viewers.ILabelProvider;
12: import org.eclipse.jface.viewers.LabelProvider;
13: import org.eclipse.swt.graphics.Image;
14: import org.eclipse.ui.ISharedImages;
15: import org.eclipse.ui.PlatformUI;
16: import org.eclipse.ui.navigator.IDescriptionProvider;
17:
18: /**
19: * Provides a label and icon for objects of type {@link PropertiesTreeData}.
20: * @since 3.2
21: */
22: public class PropertiesLabelProvider extends LabelProvider implements
23: ILabelProvider, IDescriptionProvider {
24:
25: public Image getImage(Object element) {
26: if (element instanceof PropertiesTreeData)
27: return PlatformUI.getWorkbench().getSharedImages()
28: .getImage(ISharedImages.IMG_OBJS_INFO_TSK);
29: return null;
30: }
31:
32: public String getText(Object element) {
33: if (element instanceof PropertiesTreeData) {
34: PropertiesTreeData data = (PropertiesTreeData) element;
35: return data.getName() + "= " + data.getValue(); //$NON-NLS-1$
36: }
37: return null;
38: }
39:
40: public String getDescription(Object anElement) {
41: if (anElement instanceof PropertiesTreeData) {
42: PropertiesTreeData data = (PropertiesTreeData) anElement;
43: return "Property: " + data.getName(); //$NON-NLS-1$
44: }
45: return null;
46: }
47:
48: }
|