Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9d7a3b2bf4dacdb20e6b0a25a26982c1fe0fcdca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*******************************************************************************
 * Copyright (c) 2005, 2006 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.viewers;

import org.eclipse.debug.internal.ui.viewers.provisional.ILabelRequestMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Widget;

/**
 * Implementation of an <code>ILabelRequestMonitor</code>. Collects label
 * attributes from an asynchronous label adapter.
 * <p>
 * Not intended to be subclassed or instantiated by clients. For use speficially
 * with <code>AsynchronousViewer</code>.
 * </p>
 *
 * @since 3.2
 */
class LabelRequestMonitor extends AsynchronousRequestMonitor implements ILabelRequestMonitor {

	/**
	 * Retrieved label text. Only <code>null</code> if cancelled or failed.
	 */
	private String[] fLabels;

	/**
	 * Retrieved image descriptor or <code>null</code>
	 */
	private ImageDescriptor[] fImageDescriptors;

	/**
	 * Retrieved font data or <code>null</code>
	 */
	private FontData[] fFontDatas;

	/**
	 * Retieved colors or <code>null</code>
	 */
	private RGB[] fForegrounds;
	private RGB[] fBackgrounds;

	/**
	 * Cosntructs a request to upate the label of the given node in the give
	 * model.
	 *
	 * @param node node to update
	 * @param model model containing the node
	 */
	public LabelRequestMonitor(ModelNode node, AsynchronousModel model) {
		super(node, model);
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor#performUpdate()
	 */
	@Override
	protected void performUpdate() {
		AsynchronousViewer viewer = getModel().getViewer();
		Widget widget = viewer.findItem(getNode());
		if (widget != null && !widget.isDisposed()) {
    		viewer.setLabels(widget, fLabels, fImageDescriptors);
    		viewer.setColors(widget, fForegrounds, fBackgrounds);
    		viewer.setFonts(widget, fFontDatas);
        }
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor#contains(org.eclipse.debug.ui.viewers.AsynchronousRequestMonitor)
	 */
	@Override
	protected boolean contains(AsynchronousRequestMonitor update) {
		return update instanceof LabelRequestMonitor && update.getNode() == getNode();
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setLabel(java.lang.String)
	 */
	@Override
	public void setLabels(String[] text) {
		fLabels = text;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setFontData(org.eclipse.swt.graphics.FontData)
	 */
	@Override
	public void setFontDatas(FontData[] fontData) {
		fFontDatas = fontData;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
	 */
	@Override
	public void setImageDescriptors(ImageDescriptor[] image) {
		fImageDescriptors = image;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setForeground(org.eclipse.swt.graphics.RGB)
	 */
	@Override
	public void setForegrounds(RGB[] foreground) {
		fForegrounds = foreground;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.debug.ui.viewers.ILabelRequestMonitor#setBackground(org.eclipse.swt.graphics.RGB)
	 */
	@Override
	public void setBackgrounds(RGB[] background) {
		fBackgrounds = background;
	}

	protected RGB[] getBackgrounds() {
		return fBackgrounds;
	}

	protected RGB[] getForegrounds() {
		return fForegrounds;
	}

	protected FontData[] getFontDatas() {
		return fFontDatas;
	}

	protected String[] getLabels() {
		return fLabels;
	}

	protected ImageDescriptor[] getImageDescriptors() {
		return fImageDescriptors;
	}

}

Back to the top