Project

General

Profile

Download (2.53 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.model;
11

    
12
import org.eclipse.jface.resource.ColorRegistry;
13
import org.eclipse.swt.graphics.Color;
14
import org.eclipse.swt.graphics.RGB;
15

    
16
import eu.etaxonomy.taxeditor.preference.Resources;
17

    
18
/**
19
 *
20
 * @author pplitzner
21
 * @since Nov 1, 2017
22
 *
23
 */
24
public class ColorResources {
25

    
26
	private static ColorResources instance;
27

    
28
	public static ColorResources getInstance(){
29
		if(instance == null){
30
			instance = new ColorResources();
31
		}
32
		return instance;
33
	}
34

    
35
	private static ColorRegistry colorRegistry;
36

    
37
	public ColorRegistry getColorRegistry() {
38
        if (colorRegistry == null) {
39
            colorRegistry = new ColorRegistry();
40
            initializeColorRegistry(colorRegistry);
41
        }
42
        return colorRegistry;
43
    }
44

    
45
	public static Color getColor(String key){
46
	    return getInstance().getColorRegistry().get(key);
47
	}
48

    
49
	protected void initializeColorRegistry(ColorRegistry registry) {
50
	    registerColor(registry, Resources.COLOR_COMPOSITE_BACKGROUND, 255,255,255);
51
	    registerColor(registry, Resources.COLOR_CONTROL_BACKGROUND, 220, 220, 220);
52
	    registerColor(registry, Resources.COLOR_CONTROL_SELECTED, 210, 210, 210);
53
	    registerColor(registry, Resources.COLOR_CONTROL_SELECTED_FOCUS, 232,242,254);
54
		registerColor(registry, Resources.COLOR_COMPOSITE_IRRELEVANT, 241,139,18);
55
		registerColor(registry, Resources.SEARCH_VIEW_FOREGROUND, 192, 192, 192);
56
		registerColor(registry, Resources.SEARCH_VIEW_FOCUS, 0, 0, 0);
57
		registerColor(registry, Resources.COLOR_LIST_BACKGROUND, 150,150,150);
58
		registerColor(registry, Resources.COLOR_FONT_DEFAULT, 0,0,0);
59
		registerColor(registry, Resources.COLOR_TEXT_DISABLED, 150,150,150);
60
		registerColor(registry, Resources.COLOR_TEXT_DISABLED_BACKGROUND, 230,230,230);
61
		registerColor(registry, Resources.COLOR_DRAG_ENTER, 185,255,133);
62
		registerColor(registry, Resources.COLOR_LIST_EVEN, 255,255,255);
63
		registerColor(registry, Resources.COLOR_LIST_ODD, 230,230,230);
64
		registerColor(registry, Resources.COLOR_PARSE_ERROR, 255,0,0);
65
		registerColor(registry, Resources.COLOR_DISABLED_EDITOR, 105,114,124);
66
		registerColor(registry, Resources.COLOR_EDITOR_ERROR, 255,0,0);
67
	}
68

    
69
	private void registerColor(ColorRegistry registry, String key,
70
	        int red, int green, int blue) {
71
	    registry.put(key, new RGB(red, green, blue));
72
	}
73
}
(7-7/40)