01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.views.markers.internal;
11:
12: import org.eclipse.jface.resource.JFaceResources;
13: import org.eclipse.jface.viewers.IFontProvider;
14: import org.eclipse.jface.viewers.ITableLabelProvider;
15: import org.eclipse.jface.viewers.LabelProvider;
16: import org.eclipse.swt.graphics.Font;
17: import org.eclipse.swt.graphics.Image;
18:
19: /**
20: * The TableViewLabelProvider is the content provider for marker views.
21: *
22: */
23: public class TableViewLabelProvider extends LabelProvider implements
24: ITableLabelProvider, IFontProvider {
25:
26: IField[] fields;
27:
28: /**
29: * Create a neew instance of the receiver.
30: *
31: * @param fields
32: */
33: public TableViewLabelProvider(IField[] fields) {
34: this .fields = fields;
35: }
36:
37: /*
38: * (non-Javadoc)
39: *
40: * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object,
41: * int)
42: */
43: public Image getColumnImage(Object element, int columnIndex) {
44: if (fields == null || columnIndex < 0
45: || columnIndex >= fields.length) {
46: return null;
47: }
48: return fields[columnIndex].getImage(element);
49: }
50:
51: /*
52: * (non-Javadoc)
53: *
54: * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
55: * int)
56: */
57: public String getColumnText(Object element, int columnIndex) {
58: if (fields == null || columnIndex < 0
59: || columnIndex >= fields.length) {
60: return null;
61: }
62: return fields[columnIndex].getValue(element);
63: }
64:
65: public Font getFont(Object 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: }
|