Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 135344 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/draw2d/ColorConstants.java (-18 / +38 lines)
Lines 19-118 Link Here
19
 */
19
 */
20
public interface ColorConstants {
20
public interface ColorConstants {
21
21
22
class SystemColorFactory {
23
	private static Color getColor(final int which) {
24
		Display display = Display.getCurrent();
25
		if (display != null)
26
			return display.getSystemColor(which);
27
		display = Display.getDefault();
28
		final Color result[] = new Color[1];
29
		display.syncExec(new Runnable() {
30
			public void run() {
31
				synchronized (result) {
32
					result[0] = Display.getCurrent().getSystemColor(which);					
33
				}
34
			}
35
		});
36
		synchronized (result) {
37
			return result[0];
38
		}
39
	}
40
}
41
22
/**
42
/**
23
 * @see SWT#COLOR_WIDGET_HIGHLIGHT_SHADOW
43
 * @see SWT#COLOR_WIDGET_HIGHLIGHT_SHADOW
24
 */
44
 */
25
Color buttonLightest
45
Color buttonLightest
26
				= Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
46
				= SystemColorFactory.getColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
27
/**
47
/**
28
 * @see SWT#COLOR_WIDGET_BACKGROUND
48
 * @see SWT#COLOR_WIDGET_BACKGROUND
29
 */
49
 */
30
Color button
50
Color button
31
				= Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
51
				= SystemColorFactory.getColor(SWT.COLOR_WIDGET_BACKGROUND);
32
/**
52
/**
33
 * @see SWT#COLOR_WIDGET_NORMAL_SHADOW
53
 * @see SWT#COLOR_WIDGET_NORMAL_SHADOW
34
 */
54
 */
35
Color buttonDarker
55
Color buttonDarker
36
				= Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
56
				= SystemColorFactory.getColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
37
/**
57
/**
38
 * @see SWT#COLOR_WIDGET_DARK_SHADOW
58
 * @see SWT#COLOR_WIDGET_DARK_SHADOW
39
 */
59
 */
40
Color buttonDarkest           
60
Color buttonDarkest           
41
				= Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
61
				= SystemColorFactory.getColor(SWT.COLOR_WIDGET_DARK_SHADOW);
42
62
43
/**
63
/**
44
 * @see SWT#COLOR_LIST_BACKGROUND
64
 * @see SWT#COLOR_LIST_BACKGROUND
45
 */
65
 */
46
Color listBackground          
66
Color listBackground          
47
				= Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
67
				= SystemColorFactory.getColor(SWT.COLOR_LIST_BACKGROUND);
48
/**
68
/**
49
 * @see SWT#COLOR_LIST_FOREGROUND
69
 * @see SWT#COLOR_LIST_FOREGROUND
50
 */
70
 */
51
Color listForeground          
71
Color listForeground          
52
				= Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
72
				= SystemColorFactory.getColor(SWT.COLOR_LIST_FOREGROUND);
53
73
54
/**
74
/**
55
 * @see SWT#COLOR_WIDGET_BACKGROUND
75
 * @see SWT#COLOR_WIDGET_BACKGROUND
56
 */
76
 */
57
Color menuBackground          
77
Color menuBackground          
58
				= Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
78
				= SystemColorFactory.getColor(SWT.COLOR_WIDGET_BACKGROUND);
59
/**
79
/**
60
 * @see SWT#COLOR_WIDGET_FOREGROUND
80
 * @see SWT#COLOR_WIDGET_FOREGROUND
61
 */
81
 */
62
Color menuForeground          
82
Color menuForeground          
63
				= Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND);
83
				= SystemColorFactory.getColor(SWT.COLOR_WIDGET_FOREGROUND);
64
/**
84
/**
65
 * @see SWT#COLOR_LIST_SELECTION
85
 * @see SWT#COLOR_LIST_SELECTION
66
 */
86
 */
67
Color menuBackgroundSelected  
87
Color menuBackgroundSelected  
68
				= Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION);
88
				= SystemColorFactory.getColor(SWT.COLOR_LIST_SELECTION);
69
/**
89
/**
70
 * @see SWT#COLOR_LIST_SELECTION_TEXT
90
 * @see SWT#COLOR_LIST_SELECTION_TEXT
71
 */
91
 */
72
Color menuForegroundSelected  
92
Color menuForegroundSelected  
73
				= Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
93
				= SystemColorFactory.getColor(SWT.COLOR_LIST_SELECTION_TEXT);
74
94
75
/**
95
/**
76
 * @see SWT#COLOR_TITLE_BACKGROUND
96
 * @see SWT#COLOR_TITLE_BACKGROUND
77
 */
97
 */
78
Color titleBackground         
98
Color titleBackground         
79
				= Display.getDefault().getSystemColor(SWT.COLOR_TITLE_BACKGROUND);
99
				= SystemColorFactory.getColor(SWT.COLOR_TITLE_BACKGROUND);
80
/**
100
/**
81
 * @see SWT#COLOR_TITLE_BACKGROUND_GRADIENT
101
 * @see SWT#COLOR_TITLE_BACKGROUND_GRADIENT
82
 */
102
 */
83
Color titleGradient           
103
Color titleGradient           
84
				= Display.getDefault().getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT);
104
				= SystemColorFactory.getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT);
85
/**
105
/**
86
 * @see SWT#COLOR_TITLE_FOREGROUND
106
 * @see SWT#COLOR_TITLE_FOREGROUND
87
 */
107
 */
88
Color titleForeground         
108
Color titleForeground         
89
				= Display.getDefault().getSystemColor(SWT.COLOR_TITLE_FOREGROUND);
109
				= SystemColorFactory.getColor(SWT.COLOR_TITLE_FOREGROUND);
90
/**
110
/**
91
 * @see SWT#COLOR_TITLE_INACTIVE_FOREGROUND
111
 * @see SWT#COLOR_TITLE_INACTIVE_FOREGROUND
92
 */
112
 */
93
Color titleInactiveForeground 
113
Color titleInactiveForeground 
94
				= Display.getDefault().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND);
114
				= SystemColorFactory.getColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND);
95
/**
115
/**
96
 * @see SWT#COLOR_TITLE_INACTIVE_FOREGROUND
116
 * @see SWT#COLOR_TITLE_INACTIVE_FOREGROUND
97
 */
117
 */
98
Color titleInactiveBackground 
118
Color titleInactiveBackground 
99
				= Display.getDefault().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND);
119
				= SystemColorFactory.getColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND);
100
/**
120
/**
101
 * @see SWT#COLOR_TITLE_INACTIVE_FOREGROUND
121
 * @see SWT#COLOR_TITLE_INACTIVE_FOREGROUND
102
 */
122
 */
103
Color titleInactiveGradient   
123
Color titleInactiveGradient   
104
				= Display.getDefault().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND);
124
				= SystemColorFactory.getColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND);
105
125
106
/**
126
/**
107
 * @see SWT#COLOR_INFO_FOREGROUND
127
 * @see SWT#COLOR_INFO_FOREGROUND
108
 */
128
 */
109
Color tooltipForeground       
129
Color tooltipForeground       
110
				= Display.getDefault().getSystemColor(SWT.COLOR_INFO_FOREGROUND);
130
				= SystemColorFactory.getColor(SWT.COLOR_INFO_FOREGROUND);
111
/**
131
/**
112
 * @see SWT#COLOR_INFO_BACKGROUND
132
 * @see SWT#COLOR_INFO_BACKGROUND
113
 */
133
 */
114
Color tooltipBackground       
134
Color tooltipBackground       
115
				= Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
135
				= SystemColorFactory.getColor(SWT.COLOR_INFO_BACKGROUND);
116
136
117
/*
137
/*
118
 * Misc. colors
138
 * Misc. colors
(-)src/org/eclipse/draw2d/test/ColorConstantTest.java (+53 lines)
Added Link Here
1
package org.eclipse.draw2d.test;
2
3
import junit.framework.TestCase;
4
5
import org.eclipse.swt.widgets.Display;
6
7
public class ColorConstantTest extends TestCase {
8
	/**
9
	 * @see TestCase#setUp()
10
	 */
11
	protected void setUp() throws Exception {
12
		super.setUp();
13
	}
14
15
	/**
16
	 * @see TestCase#tearDown()
17
	 */
18
	protected void tearDown() throws Exception {
19
		super.tearDown();
20
	}
21
22
	public void test_ColorConstantInit() {
23
		final Boolean result[] = new Boolean[2];
24
		result[0] = Boolean.FALSE;
25
		result[1] = Boolean.FALSE;
26
		
27
		Thread testThread = new Thread() {
28
			public void run() {
29
				try {
30
					Class.forName("org.eclipse.draw2d.ColorConstants");
31
					result[0] = Boolean.TRUE;
32
				} catch (Error e) {
33
					result[0] = Boolean.FALSE;
34
				} catch (Exception ex) {
35
					result[0] = Boolean.FALSE;
36
				}
37
				
38
				result[1] = Boolean.TRUE;
39
			}
40
		};
41
		
42
		testThread.start();
43
		
44
		while (!result[1].booleanValue()) {
45
            Display.getCurrent().readAndDispatch();
46
		}
47
48
		testThread.stop();
49
		
50
		assertTrue(result[0].booleanValue());
51
52
	}
53
}

Return to bug 135344