4 include "Simantics/Testing/BuiltinKeys" as BuiltinKeys
5 import "Simantics/Testing/BrowseContext"
6 import "Simantics/Ontologies"
8 importJava "org.eclipse.jface.action.Action" where
12 getActionText :: Action -> <Proc> String
15 getActionId :: Action -> <Proc> String
17 importJava "org.simantics.modeling.ui.actions.ModeledActions" where
19 Comparator for comparing Actions together. Handy for sorting
21 ACTION_COMPARATOR :: Comparator Action
23 instance Ord Action where
24 compare = compareWithComparator ACTION_COMPARATOR
26 importJava "org.simantics.browsing.ui.model.actions.IActionCategory" where
28 Interface for storing Actions with ActionCategories
34 Gives the label of the ActionCategory e.g. `New` or `Edit`
36 getIActionCateogryLabel :: IActionCategory -> <Proc> String
40 Gives the priority of the current ActionCategory
42 getIActionCategoryPriority :: IActionCategory -> <Proc> Double
46 Boolean value indicating if the category has submenu or not
48 isIActionCategorySubmenu :: IActionCategory -> <Proc> Boolean
50 importJava "org.simantics.browsing.ui.model.actions.ActionBrowseContext" where
52 ActionBrowseContext holds all contributions related to given set of action browse contexts.
54 data ActionBrowseContext
57 Gets all the actions for the given NodeContext
59 getActions :: ActionBrowseContext -> NodeContext -> [NodeContext] -> <ReadGraph> Map.T IActionCategory [Action]
61 create :: [Resource] -> <ReadGraph> ActionBrowseContext
63 importJava "org.simantics.browsing.ui.model.browsecontexts.BrowseContexts" where
64 toActionBrowseContextG :: Vector String -> <ReadGraph> ActionBrowseContext
67 Creates a new ActionBrowseContext for the given Collection of Resources.
69 createActionBrowseContext :: [Resource] -> <ReadGraph> ActionBrowseContext
70 createActionBrowseContext resource = do
74 Test function for browsing whole BrowseContext for all NodeContexts recursively. Also goes through ActionBrowseContexts
76 browseAllContext :: BrowseContext -> NodeContext -> <Proc> ()
77 browseAllContext browse node = do
78 children = syncRead $ \_ -> browseContextChildren browse node
79 lista = collectionToList children
82 all = browseAllContext browse
84 browseDeepImpl browse node
85 else browseDeepImpl browse node
88 browseDeepImpl :: BrowseContext -> NodeContext -> <Proc> ()
89 browseDeepImpl browse node = do
90 labeldecorator = syncRead $ \_ -> browseContextLabelDecorator browse node
91 stubbi = decorateLabelStub labeldecorator
92 labels = syncRead $ \_ -> browseContextLabel browse node
93 Map.iter(\k v -> (stubbi k v)) labels
94 images = syncRead $ \_ -> browseContextImage browse node
95 state = syncRead $ \_ -> browseContextCheckedState browse node
96 imagedecorator = syncRead $ \_ -> browseContextImageDecorator browse node
97 res = getConstant node BuiltinKeys.INPUT
98 actioncontext = syncRead $ \_ -> createActionBrowseContext [PROJECT.ProjectActionContext]
99 actions = syncRead $ \_ -> getActions actioncontext node [node]
101 laabel = getIActionCateogryLabel k
102 prioo = getIActionCategoryPriority k
103 subm = isIActionCategorySubmenu k
104 //print (laabel + " " + (show prioo) + " " + (show subm))
105 iter printActionDetails (sort v)
107 modifier = syncRead $ \_ -> browseContextModifier browse node "single"
112 valid = isValid modif val
116 printActionDetails :: Action -> <Proc> ()
117 printActionDetails action = do
118 teext = getActionText action
119 iid = getActionId action
120 //print ("-- " + teext + " (" + iid + ")")
124 decorateLabelStub :: LabelDecorator -> String -> String -> <Proc> ()
125 decorateLabelStub decorator key value = do
126 fontti = match decorateFont decorator (Just defaultFontDescriptor) key 0 with
129 fontti = decorateBackground decorator Nothing key 0
130 fontti = decorateForeground decorator Nothing key 0
131 laabeli = decorateLabel decorator value key 0