-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaneRegistry.js
56 lines (51 loc) · 1.83 KB
/
paneRegistry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* SOLID PANE REGISTRY
**
** Panes are regions of the outline view in which a particular subject is
** displayed in a particular way.
** Different paneRegistry about the same subject are typically stacked vertically.
** Panes may be used naked or with a pane selection header.
**
** The label() method has two functions: it determines whether the pane is
** relevant to a given subject, returning null if not.
** If it is relevant, then it returns a suitable tooltip for a control which selects the pane
*/
// create the unique UI module on which to attach paneRegistry (no, don't attach as UI dot paneRegistry any more)
// var UI = require('solid-ui') // Note we will add the paneRegistry register to this.
const paneRegistry = (module.exports = {})
paneRegistry.list = []
paneRegistry.paneForIcon = []
paneRegistry.paneForPredicate = []
paneRegistry.register = function (p, requireQueryButton) {
p.requireQueryButton = requireQueryButton
if (!p.name) {
console.log('*** No name for pane!')
return
}
console.log(' registering pane: ' + p.name)
if (!p.label) {
console.log('*** No label for pane!')
return
}
paneRegistry.list.push(p)
if (!(p.name in paneRegistry)) {
// don't overwrite methods
paneRegistry[p.name] = p
// console.log(' Indexing '+ p.name +' pane ...')
}
if (p.icon) {
paneRegistry.paneForIcon[p.icon] = p
}
if (p.predicates) {
for (const x in p.predicates) {
paneRegistry.paneForPredicate[x] = { pred: x, code: p.predicates[x] }
}
}
}
paneRegistry.byName = function (name) {
for (let i = 0; i < paneRegistry.list.length; i++) {
if (paneRegistry.list[i].name === name) return paneRegistry.list[i]
}
console.warn(`No view with name ${name} found in the registry of views (aka paneRegistry)`)
return null
}
// ENDS