|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.carbide.cpp.internal.pi.wizards.ui.util; |
|
19 |
|
20 import org.eclipse.jface.viewers.ILabelProvider; |
|
21 import org.eclipse.jface.viewers.ILabelProviderListener; |
|
22 import org.eclipse.swt.graphics.Image; |
|
23 import org.eclipse.ui.ISharedImages; |
|
24 import org.eclipse.ui.PlatformUI; |
|
25 import org.eclipse.ui.model.WorkbenchLabelProvider; |
|
26 |
|
27 import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; |
|
28 |
|
29 public class PkgListTreeLabelProvider implements ILabelProvider { |
|
30 |
|
31 WorkbenchLabelProvider lp = new WorkbenchLabelProvider(); |
|
32 |
|
33 public Image getImage(Object element) { |
|
34 if (element instanceof IPkgEntry || element instanceof ICarbideBuildConfiguration) |
|
35 return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE); |
|
36 |
|
37 return lp.getImage(element); |
|
38 } |
|
39 |
|
40 public String getText(Object element) { |
|
41 |
|
42 if (element instanceof IPkgEntry) { |
|
43 String result = Messages.getString("PkgListTreeLabelProvider.sample.file") + ((IPkgEntry)element).getPkgFile(); //$NON-NLS-1$ |
|
44 if (((IPkgEntry)element).getSdk() != null) { |
|
45 result += Messages.getString("PkgListTreeLabelProvider.sdk") + ((IPkgEntry)element).getSdk().getUniqueId(); //$NON-NLS-1$ |
|
46 } |
|
47 return result; |
|
48 } else if (element instanceof ICarbideBuildConfiguration) { |
|
49 return ((ICarbideBuildConfiguration)element).getDisplayString(); |
|
50 } |
|
51 |
|
52 return lp.getText(element); |
|
53 |
|
54 } |
|
55 |
|
56 public void addListener(ILabelProviderListener listener) { |
|
57 lp.addListener(listener); |
|
58 } |
|
59 |
|
60 public void dispose() { |
|
61 lp.dispose(); |
|
62 } |
|
63 |
|
64 public boolean isLabelProperty(Object element, String property) { |
|
65 return lp.isLabelProperty(element, property); |
|
66 } |
|
67 |
|
68 public void removeListener(ILabelProviderListener listener) { |
|
69 lp.removeListener(listener); |
|
70 } |
|
71 |
|
72 } |