ref #7044 Migrate font theme
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 2 Nov 2017 08:21:24 +0000 (09:21 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 2 Nov 2017 08:21:24 +0000 (09:21 +0100)
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/FontResources.java [new file with mode: 0644]

index 16cc2f631c121a1909e9b05839da75801d0f3127..f7851a544cc5a808bb671955f3c63c58c2372291 100755 (executable)
             name="%wizard.name.17">
       </wizard>
    </extension>
-<extension
-            point="org.eclipse.ui.themes">
-         <themeElementCategory
-               id="eu.etaxonomy.taxeditor.preferences.themeElementCategory"
-               label="%themeElementCategory.label">
-            <description>
-               %themeElementCategory.description
-            </description>
-         </themeElementCategory>
-         <themeElementCategory
-               id="eu.etaxonomy.taxeditor.preferences.themeElementCategory.detailsView"
-               label="%themeElementCategory.label.0"
-               parentId="eu.etaxonomy.taxeditor.preferences.themeElementCategory">
-            <description>
-               %themeElementCategory.description.0
-            </description>
-         </themeElementCategory>
-         <themeElementCategory
-               id="eu.etaxonomy.taxeditor.preferences.themeElementCategory.nameEditor"
-               label="%themeElementCategory.label.1"
-               parentId="eu.etaxonomy.taxeditor.preferences.themeElementCategory">
-            <description>
-               %themeElementCategory.description.1
-            </description>
-         </themeElementCategory>
-         <fontDefinition
-               categoryId="eu.etaxonomy.taxeditor.preferences.themeElementCategory.nameEditor"
-               id="eu.etaxonomy.taxeditor.preferences.fontDefinition.nameEditor.accepted"
-               label="%fontDefinition.label"
-               value="Georgia-regular-12">
-         </fontDefinition>
-         <fontDefinition
-               categoryId="eu.etaxonomy.taxeditor.preferences.themeElementCategory.nameEditor"
-               id="eu.etaxonomy.taxeditor.preferences.fontDefinition.nameEditor.synonym"
-               label="%fontDefinition.label.0"
-               value="Georgia-regular-10">
-         </fontDefinition>
-         <fontDefinition
-               categoryId="eu.etaxonomy.taxeditor.preferences.themeElementCategory.nameEditor"
-               id="eu.etaxonomy.taxeditor.preferences.fontDefinition.nameEditor.misapplication"
-               label="%fontDefinition.label.1"
-               value="Georgia-regular-10">
-         </fontDefinition>
-         <fontDefinition
-               categoryId="eu.etaxonomy.taxeditor.preferences.themeElementCategory.nameEditor"
-               id="eu.etaxonomy.taxeditor.preferences.fontDefinition.nameEditor.concept"
-               label="%fontDefinition.label.2"
-               value="Georgia-regular-10">
-         </fontDefinition>
-         <fontDefinition
-               categoryId="eu.etaxonomy.taxeditor.preferences.themeElementCategory.nameEditor"
-               id="eu.etaxonomy.taxeditor.preferences.fontDefinition.nameEditor.default"
-               label="%fontDefinition.label.3"
-               value="Georgia-regular-10">
-         </fontDefinition>
-         <themeElementCategory
-               id="eu.etaxonomy.taxeditor.preferences.themeElementCategory.searchView"
-               label="%themeElementCategory.label.2"
-               parentId="eu.etaxonomy.taxeditor.preferences.themeElementCategory">
-            <description>
-               %themeElementCategory.description.2
-            </description>
-         </themeElementCategory>
-         <fontDefinition
-               categoryId="eu.etaxonomy.taxeditor.preferences.themeElementCategory.searchView"
-               id="eu.etaxonomy.taxeditor.preferences.fontDefinition.searchView.accepted"
-               isEditable="true"
-               label="%fontDefinition.label.4"
-               value="Arial-regular-10">
-            <description>
-               %fontDefinition.description
-            </description>
-         </fontDefinition>
-         <fontDefinition
-               categoryId="eu.etaxonomy.taxeditor.preferences.themeElementCategory.searchView"
-               id="eu.etaxonomy.taxeditor.preferences.fontDefinition.searchView.synonym"
-               isEditable="true"
-               label="%fontDefinition.label.5"
-               value="Arial-italic-10">
-         <description>
-            %fontDefinition.description.0
-         </description>
-      </fontDefinition>
-      <fontDefinition
-            categoryId="eu.etaxonomy.taxeditor.preferences.themeElementCategory.searchView"
-            id="eu.etaxonomy.taxeditor.preferences.fontDefinition.searchView.other"
-            isEditable="true"
-            label="%fontDefinition.label.6"
-            value="Lucida Grande-regular-11">
-         <description>
-            %fontDefinition.description.1
-         </description>
-      </fontDefinition>
-      </extension>
 <extension
       point="org.eclipse.core.expressions.propertyTesters">
    <propertyTester
index ade7a53326b7e5fbc9a6eaf8854081e7243c27c5..863b692580e9b8df31fd5171849185a5cee20aba 100644 (file)
@@ -48,7 +48,6 @@ import org.eclipse.e4.ui.di.UISynchronize;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.e4.ui.workbench.modeling.EPartService;
 import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.resource.FontRegistry;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.swt.graphics.Color;
@@ -128,19 +127,8 @@ public abstract class AbstractUtility {
         return themeManager.getCurrentTheme();
     }
 
-    /**
-     * Fonts registered to the plugin may be obtained with the Eclipse themeing
-     * functionality. Thus fonts are chooseable by the user via
-     * Preferences->General->Appearance->Colors and Fonts
-     *
-     * @return the FontRegistry for the current theme
-     */
-    public static FontRegistry getFontRegistry() {
-        return getCurrentTheme().getFontRegistry();
-    }
-
     public static Font getFont(String symbolicName) {
-        return getFontRegistry().get(symbolicName);
+        return FontResources.getFont(symbolicName);
     }
 
     public static Color getColor(String symbolicName) {
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/FontResources.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/FontResources.java
new file mode 100644 (file)
index 0000000..ec80270
--- /dev/null
@@ -0,0 +1,64 @@
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.model;
+
+import org.eclipse.jface.resource.FontRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+
+import eu.etaxonomy.taxeditor.preference.Resources;
+
+/**
+ *
+ * @author pplitzner
+ * @since Nov 1, 2017
+ *
+ */
+public class FontResources {
+
+       private static FontResources instance;
+
+       public static FontResources getInstance(){
+               if(instance == null){
+                       instance = new FontResources();
+               }
+               return instance;
+       }
+
+       private static FontRegistry fontRegistry;
+
+       public FontRegistry getFontRegistry() {
+        if (fontRegistry == null) {
+            fontRegistry = new FontRegistry();
+            initializeFontRegistry(fontRegistry);
+        }
+        return fontRegistry;
+    }
+
+       public static Font getFont(String key){
+           return getInstance().getFontRegistry().get(key);
+       }
+
+       protected void initializeFontRegistry(FontRegistry registry) {
+           registerFont(registry, Resources.ACCEPTED_TAXON_FONT, "Georgia", 12, SWT.NORMAL);
+           registerFont(registry, Resources.SYNONYM_FONT, "Georgia", 10, SWT.NORMAL);
+           registerFont(registry, Resources.MISAPPLIEDNAME_FONT, "Georgia", 10, SWT.NORMAL);
+           registerFont(registry, Resources.CONCEPT_FONT, "Georgia", 10, SWT.NORMAL);
+           registerFont(registry, Resources.FONT_DEFAULT_PROMPT, "Georgia", 10, SWT.NORMAL);
+               registerFont(registry, Resources.FONT_SEARCH_VIEW_ACCEPTED, "Arial", 10, SWT.NORMAL);
+               registerFont(registry, Resources.FONT_SEARCH_VIEW_SYNONYM, "Arial", 10, SWT.ITALIC);
+               registerFont(registry, Resources.FONT_SEARCH_VIEW_OTHER, "Lucida Grande", 11, SWT.NORMAL);
+       }
+
+    private void registerFont(FontRegistry registry, String key, String name, int height, int style) {
+        registry.put(key, new FontData[]{new FontData(name, height, style)});
+    }
+}