X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fscl%2FSimantics%2FTesting%2FBrowseContext.scl;fp=bundles%2Forg.simantics.modeling.ui%2Fscl%2FSimantics%2FTesting%2FBrowseContext.scl;h=485f886c6d04a5af72f7d7f0ebc726c56bf0d29c;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl new file mode 100644 index 000000000..485f886c6 --- /dev/null +++ b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl @@ -0,0 +1,120 @@ +import "Simantics/DB" +import "Map" as Map +import "Simantics/Testing/BuiltinKeys" + +importJava "org.simantics.browsing.ui.model.browsecontexts.BrowseContext" where + """ + BrowseContext holds all contributions related to given set of browse contexts. + """ + data BrowseContext + + @JavaName getChildren + """ + Returns the possible children of the given NodeContext parameter. + """ + browseContextChildren :: BrowseContext -> NodeContext -> Collection NodeContext + + @JavaName getParents + """ + Returns the possible parents of the given NodeContext parameter. + """ + browseContextParents:: BrowseContext -> NodeContext -> Collection NodeContext + + @JavaName getLabel + """ + Finds labels for the given NodeContext parameter. + """ + browseContextLabel :: BrowseContext -> NodeContext -> Map.T String String + + @JavaName getImage + """ + Finds @link ImageDescriptors for the given NodeContext parameter. + """ + browseContextImage :: BrowseContext -> NodeContext -> Map.T String ImageDescriptor + + @JavaName getCheckedState + """ + Finds if the given NodeContext is checked or not. + """ + browseContextCheckedState :: BrowseContext -> NodeContext -> CheckedState + + @JavaName getLabelDecorator + """ + Finds LabelDecorator for the given NodeContext parameter. + """ + browseContextLabelDecorator :: BrowseContext -> NodeContext -> LabelDecorator + + @JavaName getImageDecorator + """ + Finds ImageDecorator for the given NodeContext parameter. + """ + browseContextImageDecorator :: BrowseContext -> NodeContext -> ImageDecorator + + @JavaName getModifier + """ + Finds Modifier for the given NodeContext parameter. + """ + browseContextModifier :: BrowseContext -> NodeContext -> String -> Maybe Modifier + + @private + create :: [Resource] -> BrowseContext + +importJava "org.simantics.browsing.ui.NodeContext" where + """ + A context used to represent a single visible UI item. + """ + data NodeContext + + """ + Finds value with the specified key or null if there was no value for the key + """ + getConstant :: NodeContext -> ConstantKey -> a + +importJava "org.eclipse.jface.resource.ImageDescriptor" where + data ImageDescriptor + +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.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. + """ + data LabelDecorator + + """ + Decorates the given label with the name of the UI column which the label is for and the index of this label within its parenting INodeContext. + Returns the decorated Label + """ + decorateLabel :: LabelDecorator -> String -> String -> Integer -> String + decorateForeground :: LabelDecorator -> a -> String -> Integer -> a + decorateBackground :: LabelDecorator -> a -> String -> Integer -> a + decorateFont :: LabelDecorator -> a -> String -> Integer -> a + +importJava "org.simantics.browsing.ui.CheckedState" where + data CheckedState + +importJava "org.simantics.browsing.ui.content.Labeler$Modifier" where + data Modifier + + getValue :: Modifier -> String + isValid :: Modifier -> String -> String + +importJava "org.simantics.browsing.ui.model.browsecontexts.BrowseContexts" where + toBrowseContextG :: Vector String -> BrowseContext + getNodeContextForResource :: Resource -> NodeContext + +""" +Creates a new BrowseContext for the given Collection of Resources. +""" +createBrowseContext :: [Resource] -> BrowseContext +createBrowseContext resource = do + create resource +