Method: dispose()

1: /*
2: * #%~
3: * org.overture.ide.ui
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.ui.editor.syntax;
23:
24: import java.util.HashMap;
25: import java.util.Iterator;
26: import java.util.Map;
27:
28: import org.eclipse.swt.graphics.Color;
29: import org.eclipse.swt.graphics.RGB;
30: import org.eclipse.swt.widgets.Display;
31:
32: public class VdmColorProvider {
33:         
34:         public static final RGB MULTI_LINE_COMMENT = new RGB(128, 0, 0);
35:         public static final RGB SINGLE_LINE_COMMENT = new RGB(63, 127, 95);
36:         public static final RGB KEYWORD = new RGB(127, 0, 85);
37:         public static final RGB TYPE = new RGB(0, 0, 128);
38:         public static final RGB STRING = new RGB(42, 0, 255);
39:         public static final RGB DEFAULT = new RGB(0, 0, 0);
40:         public static final RGB VDMDOC_KEYWORD = new RGB(0, 128, 0);
41:         public static final RGB VDMDOC_TAG = new RGB(128, 128, 128);
42:         public static final RGB VDMDOC_LINK = new RGB(128, 128, 128);
43:         public static final RGB VDMDOC_DEFAULT = new RGB(0, 128, 128);
44:         public static final RGB LATEX = new RGB(153,180,209);
45:         
46:         protected static Map<RGB, Color> fColorTable = new HashMap<RGB, Color>(10);
47:
48:         public void dispose() {
49:                 Iterator<Color> e = fColorTable.values().iterator();
50:•                while (e.hasNext())
51:                         ((Color) e.next()).dispose();
52:         }
53:
54:         public Color getColor(RGB rgb) {
55:                 Color color = (Color) fColorTable.get(rgb);
56:                 if (color == null) {
57:                         color = new Color(Display.getCurrent(), rgb);
58:                         fColorTable.put(rgb, color);
59:                 }
60:                 return color;
61:         }
62: }