]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/ColorManager.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / editor / ColorManager.java
1 package org.simantics.scl.ui.editor;
2
3 import java.util.HashMap;
4
5 import org.eclipse.swt.graphics.Color;
6 import org.eclipse.swt.graphics.RGB;
7 import org.eclipse.swt.widgets.Display;
8
9 public class ColorManager {
10
11         protected HashMap<RGB, Color> colorTable = new HashMap<RGB, Color>();
12
13         public void dispose() {
14                 for(Color c : colorTable.values())
15                         c.dispose();
16                 colorTable.clear();
17         }
18         
19         public Color get(RGB rgb) {
20                 Color color = colorTable.get(rgb);
21                 if (color == null) {
22                         color = new Color(Display.getCurrent(), rgb);
23                         colorTable.put(rgb, color);
24                 }
25                 return color;
26         }
27         
28 }