/
EyeTreeInspector.class.st
150 lines (127 loc) · 3.61 KB
/
EyeTreeInspector.class.st
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
"
I am a tree inspector that takes the EyeElements from the default inspectors and displays them in a tree.
"
Class {
#name : #EyeTreeInspector,
#superclass : #EyeAbstractInspector,
#instVars : [
'tree'
],
#category : #'Spec-Inspector-Base'
}
{ #category : #spec }
EyeTreeInspector class >> inspectorSpec [
<spec>
^ SpecLayout composed
newRow: #tree bottom: 0.3;
addHSplitter;
newRow: #text top: 0.7;
yourself
]
{ #category : #accessing }
EyeTreeInspector class >> label [
^ 'Tree Inspector'
]
{ #category : #api }
EyeTreeInspector >> childrenFor: anEyeElement [
^ self childrenForObject: anEyeElement value
]
{ #category : #api }
EyeTreeInspector >> childrenForObject: anObject [
^ (EyeInspector inspector: anObject) elements
select: [ :element | element shouldShowInTree ]
]
{ #category : #'event-handling' }
EyeTreeInspector >> elementChanged [
self text doItReceiver: self selectedElement value.
self text adapter
ifNotNil: [ :w |
w widget editingMode
classOrMetaClass: self selectedElement value class ]
]
{ #category : #api }
EyeTreeInspector >> expandRoots [
self tree expandRoots
]
{ #category : #api }
EyeTreeInspector >> iconFor: anEyeElement [
anEyeElement withErrorsDo: [ :error |
^ self iconFor: anEyeElement error: error ].
^ [ anEyeElement icon ]
on: Error do: [ :error |
self iconFor: anEyeElement error: error ]
]
{ #category : #api }
EyeTreeInspector >> iconFor: anEyeElement error: error [
^ self iconNamed: #smallWarningIcon
]
{ #category : #initialization }
EyeTreeInspector >> initializeShortcuts [
"initialize the inspector' shortcuts with the dictionary defined in self shortCuts"
self shortCuts keysAndValuesDo: [ :key :value |
self tree bindKeyCombination: key toAction: value ]
]
{ #category : #menu }
EyeTreeInspector >> inspectionMenu: aMenu [
self hasSelectedObject ifFalse: [ ^ aMenu ].
self inspectionSubMenu: aMenu.
self selectedElement inspectionMenu: aMenu.
^aMenu.
]
{ #category : #api }
EyeTreeInspector >> labelFor: anEyeElement [
"Take care of errors that might occur during label access"
^ [ anEyeElement longLabel ]
on: Error do: [ :error |
anEyeElement label, ': ', (self labelFor: anEyeElement error: error) ]
]
{ #category : #'event-handling' }
EyeTreeInspector >> objectChanged [
self text doItReceiver: self object.
self text adapter
ifNotNil: [ :w | w editingMode classOrMetaClass: self object class ].
self tree
roots: self roots;
expandRoots
]
{ #category : #'event-handling' }
EyeTreeInspector >> ownerChanged [
super ownerChanged.
self expandRoots.
]
{ #category : #accessing }
EyeTreeInspector >> roots [
^ { RootEyeElement host: self object }
]
{ #category : #accessing }
EyeTreeInspector >> selectedElement [
self tree hasSelectedItem
ifFalse: [ ^ nil ].
^ self tree selectedItem content
]
{ #category : #'smartSuggestions - support' }
EyeTreeInspector >> selectedMessage [
^ nil
]
{ #category : #accessing }
EyeTreeInspector >> selectedObject [
^self selectedElement value
]
{ #category : #'private-focus' }
EyeTreeInspector >> takeKeyboardFocus [
^ self tree takeKeyboardFocus
]
{ #category : #accessing }
EyeTreeInspector >> tree [
^ tree
ifNil: [ tree := self instantiate: TreePresenter.
tree whenBuiltDo: [ self initializeShortcuts ].
tree
whenSelectedItemChanged: [ :item | item ifNotNil: [ self elementChanged ] ];
childrenBlock: [ :anObject | self childrenFor: anObject ];
iconBlock: [ :treeNode | self iconFor: treeNode ];
displayBlock: [ :anObject | self labelFor: anObject ];
menu: [ :menu | self inspectionMenu: menu ];
doubleClick: [ self diveInto: self selectedObject ];
yourself ]
]