7bcdd21461ace82d5000a991403cf311abf1f5f2
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / editors / ColorManager.java
1 package net.sourceforge.phpeclipse.editors;
2
3 import java.util.HashMap;
4 import java.util.Iterator;
5 import java.util.Map;
6
7 import org.eclipse.swt.graphics.Color;
8 import org.eclipse.swt.graphics.RGB;
9 import org.eclipse.swt.widgets.Display;
10
11 public class ColorManager
12 {
13
14         protected Map fColorTable = new HashMap(10);
15
16         public void dispose()
17         {
18                 Iterator e = fColorTable.values().iterator();
19                 while (e.hasNext())
20                          ((Color) e.next()).dispose();
21         }
22         public Color getColor(RGB rgb)
23         {
24                 Color color = (Color) fColorTable.get(rgb);
25                 if (color == null)
26                 {
27                         color = new Color(Display.getCurrent(), rgb);
28                         fColorTable.put(rgb, color);
29                 }
30                 return color;
31         }
32 }