KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > model > AntModelLabelProvider


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 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.ant.internal.ui.model;
12
13 import org.eclipse.jface.viewers.IColorProvider;
14 import org.eclipse.jface.viewers.LabelProvider;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.graphics.Color;
17 import org.eclipse.swt.graphics.Image;
18 import org.eclipse.swt.widgets.Display;
19
20
21 public class AntModelLabelProvider extends LabelProvider implements IColorProvider {
22
23     /* (non-Javadoc)
24      * @see org.eclipse.jface.viewers.ILabelProvider#getImage(Object)
25      */

26     public Image getImage(Object JavaDoc anElement) {
27         AntElementNode node = (AntElementNode)anElement;
28         return node.getImage();
29     }
30     
31     /* (non-Javadoc)
32      * @see org.eclipse.jface.viewers.ILabelProvider#getText(Object)
33      */

34     public String JavaDoc getText(Object JavaDoc node) {
35         AntElementNode element= (AntElementNode) node;
36         return element.getLabel();
37     }
38
39     public Color getForeground(Object JavaDoc node) {
40         if (node instanceof AntTargetNode && ((AntTargetNode)node).isDefaultTarget() ) {
41             return Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
42         }
43         
44         return null;
45     }
46
47     public Color getBackground(Object JavaDoc element) {
48         return null;
49     }
50 }
51
Popular Tags