01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.examples.templateeditor.editors;
11:
12: import java.util.HashMap;
13: import java.util.Iterator;
14: import java.util.Map;
15:
16: import org.eclipse.swt.graphics.Color;
17: import org.eclipse.swt.graphics.RGB;
18: import org.eclipse.swt.widgets.Display;
19:
20: public class ColorManager {
21:
22: protected Map fColorTable = new HashMap(10);
23:
24: public void dispose() {
25: Iterator e = fColorTable.values().iterator();
26: while (e.hasNext())
27: ((Color) e.next()).dispose();
28: }
29:
30: public Color getColor(RGB rgb) {
31: Color color = (Color) fColorTable.get(rgb);
32: if (color == null) {
33: color = new Color(Display.getCurrent(), rgb);
34: fColorTable.put(rgb, color);
35: }
36: return color;
37: }
38: }
|