KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > visualcontent > ui > repositorypropertylist > ViewLabelProvider


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.repositorypropertylist;
19
20 import javax.jcr.Repository;
21
22 import org.eclipse.jface.viewers.ITableLabelProvider;
23 import org.eclipse.jface.viewers.LabelProvider;
24 import org.eclipse.swt.graphics.Image;
25 import org.eclipse.ui.ISharedImages;
26 import org.eclipse.ui.PlatformUI;
27
28 class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
29     /**
30      *
31      */

32     private final RepositoryPropertyList list;
33
34     /**
35      * @param list
36      */

37     ViewLabelProvider(RepositoryPropertyList aList) {
38         list = aList;
39     }
40
41     public String JavaDoc getColumnText(Object JavaDoc obj, int index) {
42         String JavaDoc key = (String JavaDoc) obj;
43         Repository repository = list.getRepository();
44         String JavaDoc label = (index==0) ? key : repository.getDescriptor(key);
45         return label;
46     }
47
48     public Image getColumnImage(Object JavaDoc obj, int index) {
49         return getImage(obj);
50     }
51
52     public Image getImage(Object JavaDoc obj) {
53         return PlatformUI.getWorkbench().getSharedImages().getImage(
54                 ISharedImages.IMG_OBJ_ELEMENT);
55     }
56 }
Popular Tags