Simantics/BrowseContext module documentation

NodeContext

data NodeContext

A context used to represent a single visible UI item.

getConstant :: NodeContext -> ConstantKey -> <Proc> a

Finds value with the specified key or null if there was no value for the key

BrowseContext

data BrowseContext

A browse context describes how a tree of nodes is presented in the user interface. It is modelled in an ontology as a set of contributions: which children and parents a node has, what its labels, images, tooltips and checked state are, how they are decorated, in what order the children are sorted, and which of the values can be modified. Each contribution names the node type it applies to.

This type is the loaded form of such a model. It is built from one or more browse context resources with createBrowseContext or toBrowseContextG; the contributions of those resources and of the subcontexts they include are merged into one context. The functions below then answer questions about a single node, which is given to them as a NodeContext.

createBrowseContext :: [Resource] -> <ReadGraph> BrowseContext

Creates a new BrowseContext for the given Collection of Resources.

browseContextChildren :: BrowseContext -> NodeContext -> <ReadGraph> Collection NodeContext

Returns the possible children of the given NodeContext parameter.

browseContextParents :: BrowseContext -> NodeContext -> <ReadGraph> Collection NodeContext

Returns the possible parents of the given NodeContext parameter.

browseContextLabel :: BrowseContext -> NodeContext -> <ReadGraph> Map.T String String

Finds labels for the given NodeContext parameter.

browseContextImage :: BrowseContext -> NodeContext -> <ReadGraph> Map.T String ImageDescriptor

Finds @link ImageDescriptors for the given NodeContext parameter.

browseContextCheckedState :: BrowseContext -> NodeContext -> <ReadGraph> CheckedState

Finds if the given NodeContext is checked or not.

browseContextLabelDecorator :: BrowseContext -> NodeContext -> <ReadGraph> LabelDecorator

Finds LabelDecorator for the given NodeContext parameter.

browseContextImageDecorator :: BrowseContext -> NodeContext -> <ReadGraph> ImageDecorator

Finds ImageDecorator for the given NodeContext parameter.

browseContextModifier :: BrowseContext -> NodeContext -> String -> <ReadGraph> Maybe Modifier

Finds Modifier for the given NodeContext parameter.

LabelDecorator

data LabelDecorator

An interface for decorating aesthetic properties of an UI item, including the label text, font, background color and foreground color.

decorateLabel :: LabelDecorator -> String -> String -> Integer -> <Proc> Maybe String

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

decorateFont :: LabelDecorator -> Maybe a -> String -> Integer -> <Proc> Maybe a

decorateFont decorator font column itemIndex gives the font of the label of the named column at index itemIndex within its node context, starting from the given font. The result is Nothing when the decorator does not decorate the font.

decorateForeground :: LabelDecorator -> a -> String -> Integer -> <Proc> a

decorateForeground decorator color column itemIndex gives the foreground color of the label of the named column at index itemIndex within its node context, starting from the given color. The result is a Java null when the decorator does not decorate the foreground, as the result type is not a Maybe.

decorateBackground :: LabelDecorator -> a -> String -> Integer -> <Proc> a

As decorateForeground but for the background color of the label.

Undocumented entities

CHECKED :: CheckedState

The node is checked.

GRAYED :: CheckedState

The node is grayed, that is, checked indirectly.

NOT_CHECKED :: CheckedState

The node is not checked.

buildWithInput :: a -> <Proc> NodeContext

Returns a node context whose only content is the given input object.

colorDescriptor :: (Double, Double, Double) -> <Proc> ColorDescriptor

Creates a color descriptor from red, green and blue components given in the range 0 to 1.

colorDescriptorAsHex :: ColorDescriptor -> <Proc> String

Returns the color of the descriptor as a #rrggbb hexadecimal string.

colorDescriptorAsTuple3 :: ColorDescriptor -> <Proc> (Double, Double, Double)

Returns the red, green and blue components of the color of the descriptor. Note that the components are the 0 to 255 values of the color, not the 0 to 1 values that colorDescriptor takes.

defaultFontDescriptor :: FontDescriptor
getNodeContextForResource :: Resource -> <Proc> NodeContext

Returns a node context whose input is the given resource. The node type of the resource is not resolved, so contributions that are bound to a node type do not match the result. Use getNodeContextWithTypeForResource when they should.

getNodeContextWithTypeForResource :: Resource -> <Proc,ReadGraph> NodeContext

As getNodeContextForResource but also resolves the node type of the resource into the context, so that the contributions of a browse context that are bound to a node type apply to it. Falls back to a plain input node context if the type cannot be resolved.

getValue :: Modifier -> <Proc> String

Returns the current value of the property the modifier edits.

instanceOfTest :: Variable -> <ReadGraph> Resource -> <ReadGraph> Boolean

The implementation of the test property of a MOD.InstanceOfTest. The argument is the variable of that property; the type to test against is read from the MOD.InstanceOfTest.HasType relation of the test resource. The returned function tells whether a resource is an instance of that type.

isValid :: Modifier -> String -> <Proc> Maybe String

Returns Nothing if the given value is acceptable for the property the modifier edits, or Just message explaining why it is not.

modify :: Modifier -> String -> <Proc> ()

Sets the property the modifier edits to the given value. The value should be checked with isValid first.

toBrowseContextG :: Vector String -> <ReadGraph> BrowseContext

Returns the browse context formed by the modelled browse contexts at the given URIs. The contributions of those browse contexts and of the subcontexts they include are collected into one context. The result is a Java null if none of the URIs names a resource.