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
.store
.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 public class Resources
{
33 private static Resources instance
;
35 public static Resources
getInstance(){
37 instance
= new Resources();
43 /* ***************************************************************************************
45 ************************************************************************************** */
46 public static final String CODE_PREFERENCE
= "code";
47 //public static final NomenclaturalCode CODE_PREFERENCE_ICBN = NomenclaturalCode.ICBN();
48 //public static final NomenclaturalCode CODE_PREFERENCE_ICZN = NomenclaturalCode.ICZN();
49 //public static final NomenclaturalCode DEFAULT_CODE_PREFERENCE = CODE_PREFERENCE_ICZN;
50 public static final String CODE_PREFERENCE_ICBN
= "ICBN";
51 public static final String CODE_PREFERENCE_ICZN
= "ICZN";
52 public static final String DEFAULT_CODE_PREFERENCE
= CODE_PREFERENCE_ICBN
;
53 public static final String INITIALIZED
= "initialized";
54 public static final String INITIALIZE_W_TESTDATA
= "init_w_testdata";
56 /* ***************************************************************************************
58 ************************************************************************************** */
59 public static final String MISAPPLIED_NAME
= "misappliedname";
60 public static final String BASIONYM
= "basionym";
61 public static final String SYNONYM
= "synonym";
62 public static final String HOMOTYPIC_SYNONYM
= "homotypic_synonym";
63 public static final String HETEROTYPIC_SYNONYM
= "heterotypic_synonym";
64 public static final String NAMERELATION
= "namerelation";
65 public static final String TAXON
= "taxon";
66 public static final String HOMOTYPIC_GROUP
= "homotypicgroup";
67 public static final String QUICK_NAME_TAXON
= "quick_name_taxon";
68 public static final String PROPERTY_SHEET_CHANGE
= "property_sheet_change";
69 public static final String REFRESH_NAMEVIEWER
= "refresh_name_viewer";
71 /* ***************************************************************************************
73 ************************************************************************************** */
74 public static final String MENU_ITEM_ITALICS_FONT
= "menu_item_italics_font";
75 public static final String ACCEPTED_TAXON_FONT
= "accepted_taxon_font";
76 public static final String SYNONYM_FONT
= "synonym_font";
77 public static final String MISAPPLIEDNAME_FONT
= "misappliedname_font";
78 public static final String CONCEPT_FONT
= "concept_font";
79 public static final String DATASOURCE_FONT
= "datasource_font";
80 public static final String CHOOSE_NAME_TEXT_FONT
= "choose_name_text_font";
81 public static final String FONT_DEFAULT_PROMPT
= "default_prompt_font";
83 /* ***************************************************************************************
85 ************************************************************************************** */
86 public static final String COLOR_COMPOSITE_BACKGROUND
= "group_gray_background_color";
87 public static final String PROP_SHEET_RED
= "property_sheet_red";
88 public static final String SEARCH_VIEW_FOREGROUND
= "search_view_foreground";
89 public static final String SEARCH_VIEW_FOCUS
= "search_view_focus";
90 public static final String COLOR_COMPOSITE_SELECTED
= "color_list_selection";
91 public static final String COLOR_LIST_BACKGROUND
= "color_list_background";
93 /* ***************************************************************************************
95 ************************************************************************************** */
96 public static final String FEATURE_PREFERENCE
= "feature_preference";
97 public static final String RANK_PREFERENCE
= "rank_preference";
100 /***************************************************************************
102 **************************************************************************/
103 private FontRegistry fontRegistry
;
105 private FontRegistry
getFontRegistry() {
106 if (fontRegistry
== null) {
107 fontRegistry
= new FontRegistry(Display
.getCurrent());
109 fontRegistry
.put(DATASOURCE_FONT
,
110 new FontData
[] { new FontData("Arial", 8, SWT
.NONE
) });
111 fontRegistry
.put(MENU_ITEM_ITALICS_FONT
,
112 new FontData
[] { new FontData("Arial", 9, SWT
.ITALIC
) });
113 fontRegistry
.put(ACCEPTED_TAXON_FONT
,
114 new FontData
[] { new FontData("Georgia", 12, SWT
.NONE
) });
115 fontRegistry
.put(SYNONYM_FONT
,
116 new FontData
[] { new FontData("Georgia", 10, SWT
.NONE
) });
117 fontRegistry
.put(MISAPPLIEDNAME_FONT
,
118 new FontData
[] { new FontData("Georgia", 10, SWT
.NONE
) });
119 fontRegistry
.put(CONCEPT_FONT
,
120 new FontData
[] { new FontData("Georgia", 10, SWT
.NONE
) });
121 fontRegistry
.put(CHOOSE_NAME_TEXT_FONT
,
122 new FontData
[] { new FontData("Arial", 12, SWT
.BOLD
) });
123 fontRegistry
.put(FONT_DEFAULT_PROMPT
,
124 new FontData
[] { new FontData("Georgia", 10, SWT
.ITALIC
) });
129 public static Font
getFont(String key
) {
130 return getInstance().getFontRegistry().get(key
);
136 public static Font
italicizeFont(Font font
) {
137 FontData fontData
= font
.getFontData()[0];
138 fontData
.setStyle(fontData
.getStyle() | SWT
.ITALIC
);
139 Font italFont
= new Font(Display
.getDefault(), fontData
);
142 String fontName
= "italic";
143 Set
<?
> keySet
= getInstance().getFontRegistry().getKeySet();
144 while (keySet
.contains(fontName
+ i
)) {
147 getInstance().getFontRegistry().put(fontName
+ i
, italFont
.getFontData());
152 /***************************************************************************
154 **************************************************************************/
155 private static HashMap
<String
, Color
> colorRegistry
;
157 public static Color
getColor(String key
) {
158 return getInstance().getColorRegistry().get(key
);
161 private HashMap
<String
, Color
> getColorRegistry() {
162 if (colorRegistry
== null) {
163 colorRegistry
= new HashMap
<String
, Color
>();
165 RGB currentLineRGB
= PreferenceConverter
.getColor(
166 EditorsUI
.getPreferenceStore(), "currentLineColor");
167 Color currentLineColor
= new Color(null, currentLineRGB
);
169 colorRegistry
.put(COLOR_COMPOSITE_BACKGROUND
,
170 new Color(null, 250, 250, 250));
171 colorRegistry
.put(PROP_SHEET_RED
,
172 new Color(null, 255, 0, 0));
173 colorRegistry
.put(SEARCH_VIEW_FOREGROUND
,
174 new Color(null, 192, 192, 192));
175 colorRegistry
.put(SEARCH_VIEW_FOCUS
,
176 new Color(null, 0, 0, 0));
177 // colorRegistry.put(COLOR_COMPOSITE_SELECTED,
178 // Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION));
179 colorRegistry
.put(COLOR_COMPOSITE_SELECTED
,
181 colorRegistry
.put(COLOR_LIST_BACKGROUND
,
182 Display
.getDefault().getSystemColor(SWT
.COLOR_LIST_BACKGROUND
));
184 EditorsUI
.getPreferenceStore();
185 return colorRegistry
;