KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > WorkbenchColors


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.ui.internal;
12
13 import org.eclipse.swt.graphics.Color;
14 import org.eclipse.swt.widgets.Display;
15
16 /**
17  * This class manages the common workbench colors.
18  */

19 public class WorkbenchColors {
20     static private boolean init = false;
21
22     static private Color[] workbenchColors;
23
24     /**
25      * Dispose all color pre-allocated by the workbench.
26      */

27     private static void disposeWorkbenchColors() {
28         for (int i = 0; i < workbenchColors.length; i++) {
29             workbenchColors[i].dispose();
30         }
31         workbenchColors = null;
32     }
33
34     /**
35      * Initialize all colors used in the workbench in case the OS is using
36      * a 256 color palette making sure the workbench colors are allocated.
37      *
38      * This list comes from the designers.
39      */

40     private static void initWorkbenchColors(Display d) {
41         if (workbenchColors != null) {
42             return;
43         }
44
45         workbenchColors = new Color[] {
46         //Product pallet
47
new Color(d, 255, 255, 255), new Color(d, 255, 251, 240),
48                 new Color(d, 223, 223, 191), new Color(d, 223, 191, 191),
49                 new Color(d, 192, 220, 192), new Color(d, 192, 192, 192),
50                 new Color(d, 191, 191, 191), new Color(d, 191, 191, 159),
51                 new Color(d, 191, 159, 191), new Color(d, 160, 160, 164),
52                 new Color(d, 159, 159, 191), new Color(d, 159, 159, 159),
53                 new Color(d, 159, 159, 127), new Color(d, 159, 127, 159),
54                 new Color(d, 159, 127, 127), new Color(d, 128, 128, 128),
55                 new Color(d, 127, 159, 159), new Color(d, 127, 159, 127),
56                 new Color(d, 127, 127, 159), new Color(d, 127, 127, 127),
57                 new Color(d, 127, 127, 95), new Color(d, 127, 95, 127),
58                 new Color(d, 127, 95, 95), new Color(d, 95, 127, 127),
59                 new Color(d, 95, 127, 95), new Color(d, 95, 95, 127),
60                 new Color(d, 95, 95, 95), new Color(d, 95, 95, 63),
61                 new Color(d, 95, 63, 95), new Color(d, 95, 63, 63),
62                 new Color(d, 63, 95, 95), new Color(d, 63, 95, 63),
63                 new Color(d, 63, 63, 95), new Color(d, 0, 0, 0),
64                 //wizban pallet
65
new Color(d, 195, 204, 224), new Color(d, 214, 221, 235),
66                 new Color(d, 149, 168, 199), new Color(d, 128, 148, 178),
67                 new Color(d, 106, 128, 158), new Color(d, 255, 255, 255),
68                 new Color(d, 0, 0, 0), new Color(d, 0, 0, 0),
69                 //Perspective
70
new Color(d, 132, 130, 132), new Color(d, 143, 141, 138),
71                 new Color(d, 171, 168, 165),
72                 //PreferenceDialog and TitleAreaDialog
73
new Color(d, 230, 226, 221) };
74     }
75
76     /**
77      * Disposes of the colors. Ignore all
78      * system colors as they do not need
79      * to be disposed.
80      */

81     static public void shutdown() {
82         if (!init) {
83             return;
84         }
85         disposeWorkbenchColors();
86         init = false;
87     }
88
89     /**
90      * Initializes the colors.
91      */

92     static public void startup() {
93         if (init) {
94             return;
95         }
96
97         // Initialize the caches first.
98
init = true;
99
100         Display display = Display.getDefault();
101         initWorkbenchColors(display);
102     }
103
104 }
105
Popular Tags