01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.dialogs;
11:
12: import org.eclipse.core.runtime.Assert;
13: import org.eclipse.jface.resource.ImageDescriptor;
14: import org.eclipse.jface.resource.JFaceResources;
15: import org.eclipse.jface.resource.LocalResourceManager;
16: import org.eclipse.jface.resource.ResourceManager;
17: import org.eclipse.jface.viewers.LabelProvider;
18: import org.eclipse.swt.graphics.Image;
19: import org.eclipse.ui.IWorkingSet;
20:
21: public class WorkingSetLabelProvider extends LabelProvider {
22: private ResourceManager images;
23:
24: /**
25: * Create a new instance of the receiver.
26: */
27: public WorkingSetLabelProvider() {
28: images = new LocalResourceManager(JFaceResources.getResources());
29: }
30:
31: public void dispose() {
32: images.dispose();
33:
34: super .dispose();
35: }
36:
37: public Image getImage(Object object) {
38: Assert.isTrue(object instanceof IWorkingSet);
39: IWorkingSet workingSet = (IWorkingSet) object;
40: ImageDescriptor imageDescriptor = workingSet
41: .getImageDescriptor();
42:
43: if (imageDescriptor == null) {
44: return null;
45: }
46:
47: Image icon = (Image) images.get(imageDescriptor);
48: return icon;
49: }
50:
51: public String getText(Object object) {
52: Assert.isTrue(object instanceof IWorkingSet);
53: IWorkingSet workingSet = (IWorkingSet) object;
54: return workingSet.getLabel();
55: }
56: }
|