2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.model
;
12 import java
.util
.HashMap
;
15 import org
.eclipse
.jface
.preference
.PreferenceConverter
;
16 import org
.eclipse
.jface
.resource
.FontRegistry
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.graphics
.Color
;
19 import org
.eclipse
.swt
.graphics
.Font
;
20 import org
.eclipse
.swt
.graphics
.FontData
;
21 import org
.eclipse
.swt
.graphics
.RGB
;
22 import org
.eclipse
.swt
.widgets
.Display
;
23 import org
.eclipse
.ui
.editors
.text
.EditorsUI
;
31 * @deprecated migrate to org.eclipse.ui.themes or at least handle this a little bit more eclipse like
33 public class Resources
{
35 private static Resources instance
;
37 public static Resources
getInstance(){
39 instance
= new Resources();
45 /* ***************************************************************************************
47 ************************************************************************************** */
48 public static final String CODE_PREFERENCE
= "code";
49 //public static final NomenclaturalCode CODE_PREFERENCE_ICBN = NomenclaturalCode.ICBN();
50 //public static final NomenclaturalCode CODE_PREFERENCE_ICZN = NomenclaturalCode.ICZN();
51 //public static final NomenclaturalCode DEFAULT_CODE_PREFERENCE = CODE_PREFERENCE_ICZN;
52 public static final String CODE_PREFERENCE_ICBN
= "ICBN";
53 public static final String CODE_PREFERENCE_ICZN
= "ICZN";
54 public static final String DEFAULT_CODE_PREFERENCE
= CODE_PREFERENCE_ICBN
;
55 public static final String INITIALIZED
= "initialized";
56 public static final String INITIALIZE_W_TESTDATA
= "init_w_testdata";
58 /* ***************************************************************************************
60 ************************************************************************************** */
61 public static final String MISAPPLIED_NAME
= "misappliedname";
62 public static final String BASIONYM
= "basionym";
63 public static final String SYNONYM
= "synonym";
64 public static final String HOMOTYPIC_SYNONYM
= "homotypic_synonym";
65 public static final String HETEROTYPIC_SYNONYM
= "heterotypic_synonym";
66 public static final String NAMERELATION
= "namerelation";
67 public static final String TAXON
= "taxon";
68 public static final String HOMOTYPIC_GROUP
= "homotypicgroup";
69 public static final String QUICK_NAME_TAXON
= "quick_name_taxon";
70 public static final String PROPERTY_SHEET_CHANGE
= "property_sheet_change";
71 public static final String REFRESH_NAMEVIEWER
= "refresh_name_viewer";
73 /* ***************************************************************************************
75 ************************************************************************************** */
76 public static final String MENU_ITEM_ITALICS_FONT
= "menu_item_italics_font";
77 public static final String ACCEPTED_TAXON_FONT
= "accepted_taxon_font";
78 public static final String SYNONYM_FONT
= "synonym_font";
79 public static final String MISAPPLIEDNAME_FONT
= "misappliedname_font";
80 public static final String CONCEPT_FONT
= "concept_font";
81 public static final String DATASOURCE_FONT
= "datasource_font";
82 public static final String CHOOSE_NAME_TEXT_FONT
= "choose_name_text_font";
83 public static final String FONT_DEFAULT_PROMPT
= "default_prompt_font";
85 /* ***************************************************************************************
87 ************************************************************************************** */
88 public static final String COLOR_COMPOSITE_BACKGROUND
= "group_gray_background_color";
89 public static final String PROP_SHEET_RED
= "property_sheet_red";
90 public static final String SEARCH_VIEW_FOREGROUND
= "search_view_foreground";
91 public static final String SEARCH_VIEW_FOCUS
= "search_view_focus";
92 public static final String COLOR_COMPOSITE_SELECTED
= "color_list_selection";
93 public static final String COLOR_LIST_BACKGROUND
= "color_list_background";
96 /***************************************************************************
98 **************************************************************************/
99 private FontRegistry fontRegistry
;
101 private FontRegistry
getFontRegistry() {
102 if (fontRegistry
== null) {
103 fontRegistry
= new FontRegistry(Display
.getCurrent());
105 fontRegistry
.put(DATASOURCE_FONT
,
106 new FontData
[] { new FontData("Arial", 8, SWT
.NONE
) });
107 fontRegistry
.put(MENU_ITEM_ITALICS_FONT
,
108 new FontData
[] { new FontData("Arial", 9, SWT
.ITALIC
) });
109 fontRegistry
.put(ACCEPTED_TAXON_FONT
,
110 new FontData
[] { new FontData("Georgia", 12, SWT
.NONE
) });
111 fontRegistry
.put(SYNONYM_FONT
,
112 new FontData
[] { new FontData("Georgia", 10, SWT
.NONE
) });
113 fontRegistry
.put(MISAPPLIEDNAME_FONT
,
114 new FontData
[] { new FontData("Georgia", 10, SWT
.NONE
) });
115 fontRegistry
.put(CONCEPT_FONT
,
116 new FontData
[] { new FontData("Georgia", 10, SWT
.NONE
) });
117 fontRegistry
.put(CHOOSE_NAME_TEXT_FONT
,
118 new FontData
[] { new FontData("Arial", 12, SWT
.BOLD
) });
119 fontRegistry
.put(FONT_DEFAULT_PROMPT
,
120 new FontData
[] { new FontData("Georgia", 10, SWT
.ITALIC
) });
125 public static Font
getFont(String key
) {
126 return getInstance().getFontRegistry().get(key
);
132 public static Font
italicizeFont(Font font
) {
133 FontData fontData
= font
.getFontData()[0];
134 fontData
.setStyle(fontData
.getStyle() | SWT
.ITALIC
);
135 Font italFont
= new Font(Display
.getDefault(), fontData
);
138 String fontName
= "italic";
139 Set
<?
> keySet
= getInstance().getFontRegistry().getKeySet();
140 while (keySet
.contains(fontName
+ i
)) {
143 getInstance().getFontRegistry().put(fontName
+ i
, italFont
.getFontData());
148 /***************************************************************************
150 **************************************************************************/
151 private static HashMap
<String
, Color
> colorRegistry
;
153 public static Color
getColor(String key
) {
154 return getInstance().getColorRegistry().get(key
);
157 private HashMap
<String
, Color
> getColorRegistry() {
158 if (colorRegistry
== null) {
159 colorRegistry
= new HashMap
<String
, Color
>();
161 RGB currentLineRGB
= PreferenceConverter
.getColor(
162 EditorsUI
.getPreferenceStore(), "currentLineColor");
163 Color currentLineColor
= new Color(null, currentLineRGB
);
165 colorRegistry
.put(COLOR_COMPOSITE_BACKGROUND
,
166 new Color(null, 250, 250, 250));
167 colorRegistry
.put(PROP_SHEET_RED
,
168 new Color(null, 255, 0, 0));
169 colorRegistry
.put(SEARCH_VIEW_FOREGROUND
,
170 new Color(null, 192, 192, 192));
171 colorRegistry
.put(SEARCH_VIEW_FOCUS
,
172 new Color(null, 0, 0, 0));
173 // colorRegistry.put(COLOR_COMPOSITE_SELECTED,
174 // Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION));
175 colorRegistry
.put(COLOR_COMPOSITE_SELECTED
,
177 colorRegistry
.put(COLOR_LIST_BACKGROUND
,
178 Display
.getDefault().getSystemColor(SWT
.COLOR_LIST_BACKGROUND
));
180 EditorsUI
.getPreferenceStore();
181 return colorRegistry
;