2 * Copyright (c) 2002-2004 Widespace, OU and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://solareclipse.sourceforge.net/legal/cpl-v10.html
9 * Igor Malinin - initial contribution
11 * $Id: ColorManager.java,v 1.1 2004-09-02 18:26:49 jsurfer Exp $
14 package net.sourceforge.phpeclipse.ui;
16 import java.util.HashMap;
17 import java.util.Iterator;
20 import org.eclipse.swt.graphics.Color;
21 import org.eclipse.swt.graphics.RGB;
22 import org.eclipse.swt.widgets.Display;
27 * @author Igor Malinin
29 public class ColorManager {
30 protected Map colors = new HashMap( 10 );
32 public void bindColor( String key, RGB rgb ) {
33 Object value = colors.get( key );
34 if ( value != null ) {
35 throw new UnsupportedOperationException();
38 Color color = new Color( Display.getCurrent(), rgb );
40 colors.put( key, color );
43 public void unbindColor( String key ) {
44 Color color = (Color) colors.remove( key );
45 if ( color != null ) {
50 public Color getColor( String key ) {
51 return (Color) colors.get( key );
54 public void dispose() {
55 Iterator i = colors.values().iterator();
56 while ( i.hasNext() ) {
57 ((Color) i.next()).dispose();