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