]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Fixed BrowseContext test code to work headlessly 83/483/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 5 May 2017 10:41:01 +0000 (13:41 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 5 May 2017 10:57:13 +0000 (13:57 +0300)
Previous code invoked JFaceResources.getDefaultFontDescriptor which
eventually invoked Display.getCurrent which would assert out in a
headless test environment.

refs #7184

Change-Id: I59349b8845b8f41d96356764972abcac44d35022

bundles/org.simantics.modeling.ui/scl/Simantics/Testing/ActionBrowseContext.scl
bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl

index b821fcc03f10b5105ff5de01d4ce45dd3aed102a..68479e2257737de3cd95b5ab175b91b9df4e6801 100644 (file)
@@ -123,7 +123,7 @@ printActionDetails action = do
 @private
 decorateLabelStub :: LabelDecorator -> String -> String -> <Proc> ()
 decorateLabelStub decorator key value = do
 @private
 decorateLabelStub :: LabelDecorator -> String -> String -> <Proc> ()
 decorateLabelStub decorator key value = do
-    fontti = match decorateFont decorator (Just getDefaultFontDescriptor) key 0 with
+    fontti = match decorateFont decorator (Just defaultFontDescriptor) key 0 with
       Nothing -> ""
       Just font -> ""
     fontti = decorateBackground decorator Nothing key 0
       Nothing -> ""
       Just font -> ""
     fontti = decorateBackground decorator Nothing key 0
index d3890192e711495363cff0b7ac6517cdc191f8f1..3edb179fc295adc3c7ac223a70f04e49f857ad45 100644 (file)
@@ -76,13 +76,17 @@ importJava "org.eclipse.jface.resource.ImageDescriptor" where
 importJava "org.simantics.browsing.ui.content.ImageDecorator" where
     data ImageDecorator
 
 importJava "org.simantics.browsing.ui.content.ImageDecorator" where
     data ImageDecorator
 
-importJava "org.eclipse.jface.resource.JFaceResources" where
-    getDefaultFontDescriptor :: FontDescriptor
-
 importJava "org.eclipse.jface.resource.DeviceResourceDescriptor" where
     data FontDescriptor
     data ColorDescriptor
 
 importJava "org.eclipse.jface.resource.DeviceResourceDescriptor" where
     data FontDescriptor
     data ColorDescriptor
 
+importJava "org.eclipse.jface.resource.FontDescriptor" where
+    @private
+    @JavaName createFrom
+    createFontDescriptorFrom :: String -> Integer -> Integer -> FontDescriptor
+
+defaultFontDescriptor = createFontDescriptorFrom "Arial" 12 0 
+
 importJava "org.simantics.browsing.ui.content.LabelDecorator" where
     """
     An interface for decorating aesthetic properties of an UI item, including the label text, font, background color and foreground color.
 importJava "org.simantics.browsing.ui.content.LabelDecorator" where
     """
     An interface for decorating aesthetic properties of an UI item, including the label text, font, background color and foreground color.