-package org.simantics.wiki.ui.editor;\r
-\r
-import org.eclipse.jface.resource.FontDescriptor;\r
-import org.eclipse.jface.resource.FontRegistry;\r
-import org.eclipse.jface.resource.ResourceManager;\r
-import org.eclipse.jface.util.IPropertyChangeListener;\r
-import org.eclipse.jface.util.PropertyChangeEvent;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Font;\r
-import org.eclipse.swt.graphics.FontData;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Event;\r
-import org.eclipse.swt.widgets.Listener;\r
-import org.simantics.g2d.utils.FontHelper;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public final class WikiFontUtil {\r
-\r
- /**\r
- * ID for wiki source text font.\r
- */\r
- public static final String SOURCE_FONT_ID = "org.simantics.wiki.sourcefont";\r
-\r
- /**\r
- * @param resourceManager a resource manager for handling font allocations\r
- * @param control the control to attach the font to\r
- * @param fontRegistryId registry id of font to use for control\r
- */\r
- public static void attachControlFontToRegistry(\r
- final ResourceManager resourceManager,\r
- final Control control,\r
- String fontRegistryId)\r
- {\r
- final FontRegistry fontRegistry = FontHelper.getCurrentThemeFontRegistry();\r
- final IPropertyChangeListener fontRegistryListener = new IPropertyChangeListener() {\r
- @Override\r
- public void propertyChange(PropertyChangeEvent event) {\r
- FontData[] fdn = ((FontData[]) event.getNewValue());\r
- FontDescriptor fd = FontDescriptor.createFrom(fdn);\r
- control.setFont((Font) resourceManager.get(fd));\r
- }\r
- };\r
- fontRegistry.addListener(fontRegistryListener);\r
- FontDescriptor fd = fontRegistry.getDescriptor(fontRegistryId);\r
- control.setFont((Font) resourceManager.get(fd));\r
- control.addListener(SWT.Dispose, new Listener() {\r
- @Override\r
- public void handleEvent(Event event) {\r
- fontRegistry.removeListener(fontRegistryListener);\r
- }\r
- });\r
- }\r
-\r
-}\r
+package org.simantics.wiki.ui.editor;
+
+import org.eclipse.jface.resource.FontDescriptor;
+import org.eclipse.jface.resource.FontRegistry;
+import org.eclipse.jface.resource.ResourceManager;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.simantics.g2d.utils.FontHelper;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public final class WikiFontUtil {
+
+ /**
+ * ID for wiki source text font.
+ */
+ public static final String SOURCE_FONT_ID = "org.simantics.wiki.sourcefont";
+
+ /**
+ * @param resourceManager a resource manager for handling font allocations
+ * @param control the control to attach the font to
+ * @param fontRegistryId registry id of font to use for control
+ */
+ public static void attachControlFontToRegistry(
+ final ResourceManager resourceManager,
+ final Control control,
+ String fontRegistryId)
+ {
+ final FontRegistry fontRegistry = FontHelper.getCurrentThemeFontRegistry();
+ final IPropertyChangeListener fontRegistryListener = new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ FontData[] fdn = ((FontData[]) event.getNewValue());
+ FontDescriptor fd = FontDescriptor.createFrom(fdn);
+ control.setFont((Font) resourceManager.get(fd));
+ }
+ };
+ fontRegistry.addListener(fontRegistryListener);
+ FontDescriptor fd = fontRegistry.getDescriptor(fontRegistryId);
+ control.setFont((Font) resourceManager.get(fd));
+ control.addListener(SWT.Dispose, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ fontRegistry.removeListener(fontRegistryListener);
+ }
+ });
+ }
+
+}