X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.wiki.ui%2Fsrc%2Forg%2Fsimantics%2Fwiki%2Fui%2Feditor%2FWikiFontUtil.java;h=c6bd8a2039ed9d7e526eb635fcec5d72e45016de;hb=ca6df98771e959a66f108873b7c4e08e9a5df9e5;hp=f95a677468a8cb14a72bce6f15ea6e2e428f49ea;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/editor/WikiFontUtil.java b/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/editor/WikiFontUtil.java index f95a67746..c6bd8a203 100644 --- a/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/editor/WikiFontUtil.java +++ b/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/editor/WikiFontUtil.java @@ -1,56 +1,56 @@ -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); - } - }); - } - -} +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); + } + }); + } + +}