KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > visualcontent > ui > nodetree > NodeTreeLabelProvider


1 /**
2  * VC Browser - Visualizes the content of a JSR 170 compatible repository
3  * Copyright (C) 2006 Sandro Böhme
4  *
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.visualcontent.ui.nodetree;
19
20 import javax.jcr.Node;
21 import javax.jcr.RepositoryException;
22 import javax.jcr.UnsupportedRepositoryOperationException;
23
24 import org.eclipse.jface.viewers.LabelProvider;
25 import org.eclipse.swt.graphics.Image;
26 import org.eclipse.ui.ISharedImages;
27 import org.eclipse.ui.PlatformUI;
28
29 class NodeTreeLabelProvider extends LabelProvider {
30
31
32     /**
33      *
34      */

35     private final NodeTreeViewPart nodeTreeLabelProvider;
36
37     /**
38      * @param tree
39      */

40     NodeTreeLabelProvider(NodeTreeViewPart tree) {
41         nodeTreeLabelProvider = tree;
42     }
43
44     public String JavaDoc getText(Object JavaDoc obj) {
45         if (obj instanceof Node) {
46             Node node = (Node) obj;
47             try {
48                 String JavaDoc text = node.getName() + "["
49                         + node.getPrimaryNodeType().getName() + "]";
50                 return text;
51             } catch (UnsupportedRepositoryOperationException e) {
52                 e.printStackTrace();
53             } catch (RepositoryException e) {
54                 e.printStackTrace();
55             }
56         }
57         return obj.toString();
58     }
59
60     public Image getImage(Object JavaDoc obj) {
61         String JavaDoc imageKey = ISharedImages.IMG_OBJ_ELEMENT;
62         return PlatformUI.getWorkbench().getSharedImages().getImage(
63                 imageKey);
64     }
65 }
Popular Tags