KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > markers > internal > TableViewLabelProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.views.markers.internal;
13
14 import org.eclipse.jface.resource.JFaceResources;
15 import org.eclipse.jface.viewers.IFontProvider;
16 import org.eclipse.jface.viewers.ITableLabelProvider;
17 import org.eclipse.jface.viewers.LabelProvider;
18 import org.eclipse.swt.graphics.Font;
19 import org.eclipse.swt.graphics.Image;
20
21 /**
22  * The TableViewLabelProvider is the content provider for marker views.
23  *
24  */

25 public class TableViewLabelProvider extends LabelProvider implements
26         ITableLabelProvider, IFontProvider {
27
28     IField[] fields;
29
30     /**
31      * Create a neew instance of the receiver.
32      *
33      * @param fields
34      */

35     public TableViewLabelProvider(IField[] fields) {
36         this.fields = fields;
37     }
38
39     /*
40      * (non-Javadoc)
41      *
42      * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object,
43      * int)
44      */

45     public Image getColumnImage(Object JavaDoc element, int columnIndex) {
46         if (fields == null || columnIndex < 0 || columnIndex >= fields.length) {
47             return null;
48         }
49         return fields[columnIndex].getImage(element);
50     }
51
52     /*
53      * (non-Javadoc)
54      *
55      * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
56      * int)
57      */

58     public String JavaDoc getColumnText(Object JavaDoc element, int columnIndex) {
59         if (fields == null || columnIndex < 0 || columnIndex >= fields.length) {
60             return null;
61         }
62         return fields[columnIndex].getValue(element);
63     }
64
65     public Font getFont(Object JavaDoc element) {
66         MarkerNode node = (MarkerNode) element;
67         if (node.isConcrete()) {
68             return null;
69         }
70         return JFaceResources.getFontRegistry().getBold(
71                 JFaceResources.DEFAULT_FONT);
72     }
73
74 }
75
Popular Tags