KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > DebugViewInterimLabelProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.debug.internal.ui.views;
12
13 import org.eclipse.debug.ui.IDebugModelPresentation;
14 import org.eclipse.jface.viewers.IColorProvider;
15 import org.eclipse.jface.viewers.IFontProvider;
16 import org.eclipse.jface.viewers.ILabelProvider;
17 import org.eclipse.jface.viewers.ILabelProviderListener;
18 import org.eclipse.swt.graphics.Color;
19 import org.eclipse.swt.graphics.Font;
20 import org.eclipse.swt.graphics.Image;
21
22 /**
23  * A label provider that provide interim text labels. When queried for text, the label provider
24  * returns a default string ("<pending...>"). When queried for images, the label provider
25  * queries a debug model presentation. This label provider is intended to be passed to
26  * a <code>DebugViewDecoratingLabelProvider</code>.
27  */

28 public class DebugViewInterimLabelProvider implements ILabelProvider, IColorProvider, IFontProvider {
29
30     /**
31      * The text label returned by this label provider (value: "...").
32      */

33     public final static String JavaDoc PENDING_LABEL= "..."; //$NON-NLS-1$
34

35     /**
36      * The debug model presentation used for computing images.
37      */

38     protected IDebugModelPresentation presentation;
39
40     /**
41      * Creates a new interim label provider with the given model presentation.
42      *
43      * @param presentation the model presentation to use for computing images
44      */

45     public DebugViewInterimLabelProvider(IDebugModelPresentation presentation) {
46         this.presentation= presentation;
47     }
48     
49     /**
50      * Returns the debug model presentation used by this label provider
51      * to compute images.
52      *
53      * @return this label provider's model presentation
54      */

55     public IDebugModelPresentation getPresentation() {
56         return presentation;
57     }
58     /* (non-Javadoc)
59      * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
60      */

61     public Image getImage(Object JavaDoc element) {
62         return presentation.getImage(element);
63     }
64     /* (non-Javadoc)
65      * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
66      */

67     public String JavaDoc getText(Object JavaDoc element) {
68         return DebugViewInterimLabelProvider.PENDING_LABEL;
69     }
70     /* (non-Javadoc)
71      * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
72      */

73     public void addListener(ILabelProviderListener listener) {
74         presentation.addListener(listener);
75     }
76     /* (non-Javadoc)
77      * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
78      */

79     public void dispose() {
80         presentation.dispose();
81     }
82     /* (non-Javadoc)
83      * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
84      */

85     public boolean isLabelProperty(Object JavaDoc element, String JavaDoc property) {
86         return presentation.isLabelProperty(element, property);
87     }
88     /* (non-Javadoc)
89      * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
90      */

91     public void removeListener(ILabelProviderListener listener) {
92         presentation.removeListener(listener);
93     }
94
95     /* (non-Javadoc)
96      * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
97      */

98     public Color getForeground(Object JavaDoc element) {
99         if (presentation instanceof IColorProvider) {
100             IColorProvider colorProvider = (IColorProvider) presentation;
101             return colorProvider.getForeground(element);
102         }
103         return null;
104     }
105
106     /* (non-Javadoc)
107      * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
108      */

109     public Color getBackground(Object JavaDoc element) {
110         if (presentation instanceof IColorProvider) {
111             IColorProvider colorProvider = (IColorProvider) presentation;
112             return colorProvider.getBackground(element);
113         }
114         return null;
115     }
116
117     /* (non-Javadoc)
118      * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
119      */

120     public Font getFont(Object JavaDoc element) {
121         if (presentation instanceof IFontProvider) {
122             IFontProvider fontProvider = (IFontProvider) presentation;
123             return fontProvider.getFont(element);
124         }
125         return null;
126     }
127 }
128
Popular Tags