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 Eq Action where
\r
24 a == b = compareWithComparator ACTION_COMPARATOR a b == 0
\r
26 instance Ord Action where
\r
27 compare = compareWithComparator ACTION_COMPARATOR
\r
29 importJava "org.simantics.browsing.ui.model.actions.IActionCategory" where
\r
31 Interface for storing Actions with ActionCategories
\r
33 data IActionCategory
\r
37 Gives the label of the ActionCategory e.g. `New` or `Edit`
\r
39 getIActionCateogryLabel :: IActionCategory -> <Proc> String
\r
41 @JavaName getPriority
\r
43 Gives the priority of the current ActionCategory
\r
45 getIActionCategoryPriority :: IActionCategory -> <Proc> Double
\r
49 Boolean value indicating if the category has submenu or not
\r
51 isIActionCategorySubmenu :: IActionCategory -> <Proc> Boolean
\r
53 importJava "org.simantics.browsing.ui.model.actions.ActionBrowseContext" where
\r
55 ActionBrowseContext holds all contributions related to given set of action browse contexts.
\r
57 data ActionBrowseContext
\r
60 Gets all the actions for the given NodeContext
\r
62 getActions :: ActionBrowseContext -> NodeContext -> [NodeContext] -> <ReadGraph> Map.T IActionCategory [Action]
\r
64 create :: [Resource] -> <ReadGraph> ActionBrowseContext
\r
66 importJava "org.simantics.browsing.ui.model.browsecontexts.BrowseContexts" where
\r
67 toActionBrowseContextG :: Vector String -> <ReadGraph> ActionBrowseContext
\r
70 Creates a new ActionBrowseContext for the given Collection of Resources.
\r
72 createActionBrowseContext :: [Resource] -> <ReadGraph> ActionBrowseContext
\r
73 createActionBrowseContext resource = do
\r
77 Test function for browsing whole BrowseContext for all NodeContexts recursively. Also goes through ActionBrowseContexts
\r
79 browseAllContext :: BrowseContext -> NodeContext -> <Proc> ()
\r
80 browseAllContext browse node = do
\r
81 children = syncRead $ \_ -> browseContextChildren browse node
\r
82 lista = collectionToList children
\r
85 all = browseAllContext browse
\r
87 browseDeepImpl browse node
\r
88 else browseDeepImpl browse node
\r
91 browseDeepImpl :: BrowseContext -> NodeContext -> <Proc> ()
\r
92 browseDeepImpl browse node = do
\r
93 labeldecorator = syncRead $ \_ -> browseContextLabelDecorator browse node
\r
94 stubbi = decorateLabelStub labeldecorator
\r
95 labels = syncRead $ \_ -> browseContextLabel browse node
\r
96 Map.iter(\k v -> (stubbi k v)) labels
\r
97 images = syncRead $ \_ -> browseContextImage browse node
\r
98 state = syncRead $ \_ -> browseContextCheckedState browse node
\r
99 imagedecorator = syncRead $ \_ -> browseContextImageDecorator browse node
\r
100 res = getConstant node BuiltinKeys.INPUT
\r
101 actioncontext = syncRead $ \_ -> createActionBrowseContext [PROJECT.ProjectActionContext]
\r
102 actions = syncRead $ \_ -> getActions actioncontext node [node]
\r
103 Map.iter (\k v -> do
\r
104 laabel = getIActionCateogryLabel k
\r
105 prioo = getIActionCategoryPriority k
\r
106 subm = isIActionCategorySubmenu k
\r
107 //print (laabel + " " + (show prioo) + " " + (show subm))
\r
108 iter printActionDetails (sort v)
\r
110 modifier = syncRead $ \_ -> browseContextModifier browse node "single"
\r
111 match modifier with
\r
114 val = getValue modif
\r
115 valid = isValid modif val
\r
119 printActionDetails :: Action -> <Proc> ()
\r
120 printActionDetails action = do
\r
121 teext = getActionText action
\r
122 iid = getActionId action
\r
123 //print ("-- " + teext + " (" + iid + ")")
\r
127 decorateLabelStub :: LabelDecorator -> String -> String -> <Proc> ()
\r
128 decorateLabelStub decorator key value = do
\r
129 fontti = decorateFont decorator getDefaultFontDescriptor key 0
\r
130 fontti = decorateBackground decorator Nothing key 0
\r
131 fontti = decorateForeground decorator Nothing key 0
\r
132 laabeli = decorateLabel decorator value key 0
\r