1 11 package org.eclipse.ant.internal.ui.model; 12 13 14 import java.util.HashMap ; 15 import java.util.Iterator ; 16 import java.util.Map ; 17 18 import org.eclipse.jface.text.source.ISharedTextColors; 19 import org.eclipse.swt.graphics.Color; 20 import org.eclipse.swt.graphics.RGB; 21 import org.eclipse.swt.widgets.Display; 22 23 26 public class ColorManager implements ISharedTextColors { 27 28 private static ColorManager fgColorManager; 29 30 private ColorManager() { 31 } 32 33 public static ColorManager getDefault() { 34 if (fgColorManager == null) { 35 fgColorManager= new ColorManager(); 36 } 37 return fgColorManager; 38 } 39 40 protected Map fColorTable= new HashMap (10); 41 42 public Color getColor(RGB rgb) { 43 Color color= (Color) fColorTable.get(rgb); 44 if (color == null) { 45 color= new Color(Display.getCurrent(), rgb); 46 fColorTable.put(rgb, color); 47 } 48 return color; 49 } 50 51 public void dispose() { 52 Iterator e= fColorTable.values().iterator(); 53 while (e.hasNext()) { 54 ((Color) e.next()).dispose(); 55 } 56 } 57 } 58 59 60 | Popular Tags |