Start the debugger through setting the url with "?DBGSESSID=1@clienthost:10001" in...
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / ui / ColorManager.java
1 /*
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
7  * 
8  * Contributors:
9  *         Igor Malinin - initial contribution
10  * 
11  * $Id: ColorManager.java,v 1.1 2004-09-02 18:26:49 jsurfer Exp $
12  */
13
14 package net.sourceforge.phpeclipse.ui;
15
16 import java.util.HashMap;
17 import java.util.Iterator;
18 import java.util.Map;
19
20 import org.eclipse.swt.graphics.Color;
21 import org.eclipse.swt.graphics.RGB;
22 import org.eclipse.swt.widgets.Display;
23
24 /**
25  * Color Manager.
26  * 
27  * @author Igor Malinin
28  */
29 public class ColorManager {
30         protected Map colors = new HashMap( 10 );
31
32         public void bindColor( String key, RGB rgb ) {
33                 Object value = colors.get( key );
34                 if ( value != null ) {
35                         throw new UnsupportedOperationException();
36                 }
37
38                 Color color = new Color( Display.getCurrent(), rgb );
39
40                 colors.put( key, color );
41         }
42
43         public void unbindColor( String key ) {
44                 Color color = (Color) colors.remove( key );
45                 if ( color != null ) {
46                         color.dispose();
47                 }
48         }
49
50         public Color getColor( String key ) {
51                 return (Color) colors.get( key );
52         }
53
54         public void dispose() {
55                 Iterator i = colors.values().iterator();
56                 while ( i.hasNext() ) {
57                         ((Color) i.next()).dispose();
58                 }
59         }
60 }