KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > viewers > LabelRequestMonitor


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.debug.internal.ui.viewers;
12
13 import org.eclipse.debug.internal.ui.viewers.provisional.ILabelRequestMonitor;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.swt.graphics.FontData;
16 import org.eclipse.swt.graphics.RGB;
17 import org.eclipse.swt.widgets.Widget;
18
19 /**
20  * Implementation of an <code>ILabelRequestMonitor</code>. Collects label
21  * attributes from an asynchronous label adapter.
22  * <p>
23  * Not intended to be subclassed or instantiated by clients. For use speficially
24  * with <code>AsynchronousViewer</code>.
25  * </p>
26  *
27  * @since 3.2
28  */

29 class LabelRequestMonitor extends AsynchronousRequestMonitor implements ILabelRequestMonitor {
30
31     /**
32      * Retrieved label text. Only <code>null</code> if cancelled or failed.
33      */

34     private String JavaDoc[] fLabels;
35
36     /**
37      * Retrieved image descriptor or <code>null</code>
38      */

39     private ImageDescriptor[] fImageDescriptors;
40
41     /**
42      * Retrieved font data or <code>null</code>
43      */

44     private FontData[] fFontDatas;
45
46     /**
47      * Retieved colors or <code>null</code>
48      */

49     private RGB[] fForegrounds;
50     private RGB[] fBackgrounds;
51
52     /**
53      * Cosntructs a request to upate the label of the given node in the give
54      * model.
55      *
56      * @param node node to update
57      * @param model model containing the node
58      */

59     public LabelRequestMonitor(ModelNode node, AsynchronousModel model) {
60         super(node, model);
61     }
62
63     /*
64      * (non-Javadoc)
65      *
66      * @see org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor#performUpdate()
67      */

68     protected void performUpdate() {
69         AsynchronousViewer viewer = getModel().getViewer();
70         Widget widget = viewer.findItem(getNode());
71         if (widget != null && !widget.isDisposed()) {
72             viewer.setLabels(widget, fLabels, fImageDescriptors);
73             viewer.setColors(widget, fForegrounds, fBackgrounds);
74             viewer.setFonts(widget, fFontDatas);
75         }
76     }
77
78     /*
79      * (non-Javadoc)
80      *
81      * @see org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor#contains(org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor)
82      */

83     protected boolean contains(AsynchronousRequestMonitor update) {
84         return update instanceof LabelRequestMonitor && update.getNode() == getNode();
85     }
86
87     /*
88      * (non-Javadoc)
89      *
90      * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setLabel(java.lang.String)
91      */

92     public void setLabels(String JavaDoc[] text) {
93         fLabels = text;
94     }
95
96     /*
97      * (non-Javadoc)
98      *
99      * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setFontData(org.eclipse.swt.graphics.FontData)
100      */

101     public void setFontDatas(FontData[] fontData) {
102         fFontDatas = fontData;
103     }
104
105     /*
106      * (non-Javadoc)
107      *
108      * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
109      */

110     public void setImageDescriptors(ImageDescriptor[] image) {
111         fImageDescriptors = image;
112     }
113
114     /*
115      * (non-Javadoc)
116      *
117      * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setForeground(org.eclipse.swt.graphics.RGB)
118      */

119     public void setForegrounds(RGB[] foreground) {
120         fForegrounds = foreground;
121     }
122
123     /*
124      * (non-Javadoc)
125      *
126      * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setBackground(org.eclipse.swt.graphics.RGB)
127      */

128     public void setBackgrounds(RGB[] background) {
129         fBackgrounds = background;
130     }
131     
132     protected RGB[] getBackgrounds() {
133         return fBackgrounds;
134     }
135     
136     protected RGB[] getForegrounds() {
137         return fForegrounds;
138     }
139     
140     protected FontData[] getFontDatas() {
141         return fFontDatas;
142     }
143     
144     protected String JavaDoc[] getLabels() {
145         return fLabels;
146     }
147     
148     protected ImageDescriptor[] getImageDescriptors() {
149         return fImageDescriptors;
150     }
151
152 }
153
Popular Tags