|
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 "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.testfw.codegen.ui.util; |
|
19 |
|
20 import org.eclipse.jface.viewers.ITreeContentProvider; |
|
21 import org.eclipse.jface.viewers.LabelProvider; |
|
22 import org.eclipse.jface.viewers.Viewer; |
|
23 import org.eclipse.swt.graphics.Image; |
|
24 import org.eclipse.ui.ISharedImages; |
|
25 import org.eclipse.ui.PlatformUI; |
|
26 |
|
27 public class PathNodeTreeContentLabelProvoder extends LabelProvider implements |
|
28 ITreeContentProvider { |
|
29 |
|
30 private final Object NO_CHILDREN[]; |
|
31 |
|
32 public PathNodeTreeContentLabelProvoder() { |
|
33 super(); |
|
34 NO_CHILDREN = new Object[0]; |
|
35 } |
|
36 |
|
37 public Object[] getChildren(Object obj) { |
|
38 if (obj instanceof PathNode) |
|
39 return ((PathNode) obj).getChildren(); |
|
40 else |
|
41 return NO_CHILDREN; |
|
42 } |
|
43 |
|
44 public Object getParent(Object obj) { |
|
45 if (obj instanceof PathNode) |
|
46 return ((PathNode) obj).getParent(); |
|
47 else |
|
48 return null; |
|
49 } |
|
50 |
|
51 public boolean hasChildren(Object obj) { |
|
52 if (obj instanceof PathNode) |
|
53 return ((PathNode) obj).getChildren().length > 0; |
|
54 else |
|
55 return false; |
|
56 } |
|
57 |
|
58 public Object[] getElements(Object obj) { |
|
59 if (obj instanceof PathNode) { |
|
60 return ((PathNode) obj).getChildren(); |
|
61 } |
|
62 return NO_CHILDREN; |
|
63 } |
|
64 |
|
65 public void dispose() { |
|
66 } |
|
67 |
|
68 public void inputChanged(Viewer viewer, Object obj, Object obj1) { |
|
69 } |
|
70 |
|
71 @SuppressWarnings("deprecation") |
|
72 public Image getImage(Object obj) { |
|
73 if (obj instanceof PathNode) { |
|
74 PathNode node = (PathNode) obj; |
|
75 if (node.getData() != null) { |
|
76 return PlatformUI.getWorkbench().getSharedImages().getImage( |
|
77 ISharedImages.IMG_OBJ_FILE); |
|
78 } |
|
79 if (node.getParent().getParent() == null) { |
|
80 return PlatformUI.getWorkbench().getSharedImages().getImage( |
|
81 ISharedImages.IMG_OBJ_PROJECT); |
|
82 } else { |
|
83 return PlatformUI.getWorkbench().getSharedImages().getImage( |
|
84 ISharedImages.IMG_OBJ_FOLDER); |
|
85 } |
|
86 } |
|
87 return null; |
|
88 } |
|
89 |
|
90 public String getText(Object obj) { |
|
91 if (obj instanceof PathNode) |
|
92 return ((PathNode) obj).getName(); |
|
93 return null; |
|
94 } |
|
95 } |