KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > synchronize > DecoratingColorLabelProvider


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 package org.eclipse.team.internal.ui.synchronize;
12
13 import org.eclipse.jface.viewers.DecoratingLabelProvider;
14 import org.eclipse.jface.viewers.IColorProvider;
15 import org.eclipse.jface.viewers.IFontProvider;
16 import org.eclipse.jface.viewers.ILabelDecorator;
17 import org.eclipse.jface.viewers.ILabelProvider;
18 import org.eclipse.swt.graphics.Color;
19 import org.eclipse.swt.graphics.Font;
20
21 /**
22  * Decorating label provider that supports multiple decorators that are font and color decorators.
23  *
24  * @since 3.0
25  */

26 public class DecoratingColorLabelProvider extends DecoratingLabelProvider implements IColorProvider, IFontProvider {
27
28     public DecoratingColorLabelProvider(ILabelProvider provider, ILabelDecorator[] decorators) {
29         super(provider, new MultiLabelDecorator(decorators));
30     }
31
32     /*
33      * (non-Javadoc)
34      * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
35      */

36     public Color getForeground(Object JavaDoc element) {
37         ILabelProvider p = getLabelProvider();
38         if (p instanceof IColorProvider) {
39             return ((IColorProvider) p).getForeground(element);
40         }
41         return null;
42     }
43
44     /*
45      * (non-Javadoc)
46      * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
47      */

48     public Color getBackground(Object JavaDoc element) {
49         ILabelProvider p = getLabelProvider();
50         if (p instanceof IColorProvider) {
51             return ((IColorProvider) p).getBackground(element);
52         }
53         return null;
54     }
55     
56     /* (non-Javadoc)
57      * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
58      */

59     public Font getFont(Object JavaDoc element) {
60         ILabelProvider p = getLabelProvider();
61         if (p instanceof IFontProvider) {
62             return ((IFontProvider) p).getFont(element);
63         }
64         return null;
65     }
66 }
67
Popular Tags