From 53e9b3dac5648f360cd91478d9e6e7a495631b08 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Fri, 5 May 2017 13:41:01 +0300 Subject: [PATCH] Fixed BrowseContext test code to work headlessly Previous code invoked JFaceResources.getDefaultFontDescriptor which eventually invoked Display.getCurrent which would assert out in a headless test environment. refs #7184 Change-Id: I59349b8845b8f41d96356764972abcac44d35022 --- .../scl/Simantics/Testing/ActionBrowseContext.scl | 2 +- .../scl/Simantics/Testing/BrowseContext.scl | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/ActionBrowseContext.scl b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/ActionBrowseContext.scl index b821fcc03..68479e225 100644 --- a/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/ActionBrowseContext.scl +++ b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/ActionBrowseContext.scl @@ -123,7 +123,7 @@ printActionDetails action = do @private decorateLabelStub :: LabelDecorator -> String -> String -> () 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 diff --git a/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl index d3890192e..3edb179fc 100644 --- a/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl +++ b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl @@ -76,13 +76,17 @@ importJava "org.eclipse.jface.resource.ImageDescriptor" where 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.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. -- 2.43.2