intial source from ttp://www.sf.net/projects/wdte
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.js.ui / src / net / sourceforge / phpeclipse / js / ui / editors / JSColorManager.java
1 /*
2  * $RCSfile: JSColorManager.java,v $
3  *
4  * Copyright 2002
5  * CH-1700 Fribourg, Switzerland
6  * All rights reserved.
7  *
8  *========================================================================
9  * Modifications history
10  *========================================================================
11  * $Log: not supported by cvs2svn $
12  * Revision 1.1  2004/02/05 03:13:28  agfitzp
13  * Initial submission, outline view is broken due to refactoring
14  *
15  * Revision 1.1  2003/05/28 15:17:12  agfitzp
16  * net.sourceforge.phpeclipse.js.ui 0.0.1 code base
17  *
18  *========================================================================
19 */
20
21 package net.sourceforge.phpeclipse.js.ui.editors;
22
23 import java.util.HashMap;
24 import java.util.Iterator;
25 import java.util.Map;
26
27 import org.eclipse.swt.graphics.Color;
28 import org.eclipse.swt.graphics.RGB;
29 import org.eclipse.swt.widgets.Display;
30
31
32 /**
33  * 
34  *
35  * @author $Author: jsurfer $, $Date: 2004-09-02 18:23:49 $
36  *
37  * @version $Revision: 1.1 $
38  */
39 public class JSColorManager
40 {
41    protected Map fColorTable = new HashMap(10);
42
43    /**
44     *
45     */
46    public void dispose()
47    {
48       Iterator e = fColorTable.values().iterator();
49
50       while(e.hasNext())
51       {
52          ((Color)e.next()).dispose();
53       }
54    }
55
56    /**
57     *
58     *
59     * @param rgb 
60     *
61     * @return 
62     */
63    public Color getColor(RGB rgb)
64    {
65       Color color = (Color)fColorTable.get(rgb);
66
67       if(color == null)
68       {
69          color = new Color(Display.getCurrent(), rgb);
70          fColorTable.put(rgb, color);
71       }
72
73       return color;
74    }
75 }