/
EyeAbstractInspector.class.st
247 lines (196 loc) · 5.79 KB
/
EyeAbstractInspector.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
"
I am the abstract superclass for all kind of inspectors
"
Class {
#name : #EyeAbstractInspector,
#superclass : #ComposablePresenter,
#traits : 'TInspectorActions',
#classTraits : 'TInspectorActions classTrait',
#instVars : [
'object',
'customMenuActions',
'text'
],
#category : #'Spec-Inspector-Base'
}
{ #category : #spec }
EyeAbstractInspector class >> debuggerSpec [
<spec:#default>
^ self inspectorSpec
]
{ #category : #spec }
EyeAbstractInspector class >> inspectorSpec [
<spec>
self subclassResponsibility
]
{ #category : #accessing }
EyeAbstractInspector class >> label [
"Override to return a proper label displayd in the inspector choice"
^ self name
]
{ #category : #accessing }
EyeAbstractInspector class >> taskbarIconName [
^#smallInspectItIcon
]
{ #category : #'event-handling' }
EyeAbstractInspector >> close [
"Override in sublcasses for special actions"
]
{ #category : #accessing }
EyeAbstractInspector >> customMenuActions [
^ customMenuActions ifNil: [ customMenuActions := [ ] ]
]
{ #category : #accessing }
EyeAbstractInspector >> customMenuActions: anObject [
customMenuActions := anObject
]
{ #category : #'event-handling' }
EyeAbstractInspector >> diveInto: anObject [
self owner ifNotNil: [ :navigator |
(navigator respondsTo: #diveInto:)
ifTrue: [ ^ navigator diveInto: anObject ] ].
self inspectInNewWindow: anObject.
]
{ #category : #actions }
EyeAbstractInspector >> diveIntoSelectedObject [
self selectedObjectDo: [ :anObject | self diveInto: anObject ]
]
{ #category : #testing }
EyeAbstractInspector >> hasSelectedObject [
^ self selectedElement isNotNil
]
{ #category : #initialization }
EyeAbstractInspector >> initialize [
"The inspected object will be stored in the valueObject object to be able to use WhenObjectChanged:"
object := nil asValueHolder.
super initialize.
]
{ #category : #initialization }
EyeAbstractInspector >> initializePresenter [
object whenChangedDo: [ self objectChanged ].
self text
whenBuiltDo: [ :w | w widget editingMode classOrMetaClass: self object class ].
self initializeShortcuts
]
{ #category : #initialization }
EyeAbstractInspector >> initializeShortcuts [
"override to add custom shortcuts to your model"
]
{ #category : #initialization }
EyeAbstractInspector >> initializeWidgets [
]
{ #category : #accessing }
EyeAbstractInspector >> inspect: anObject [
self object: anObject.
]
{ #category : #menu }
EyeAbstractInspector >> inspectionMenu: aMenu [
| menuModel |
self hasSelectedObject ifFalse: [ ^ aMenu ].
menuModel := self newMenu.
self inspectionSubMenu: menuModel.
self selectedElement inspectionMenu: menuModel.
aMenu addAllMorphs: (menuModel buildWithSpec: #popup) items.
^aMenu
]
{ #category : #menu }
EyeAbstractInspector >> inspectionSubMenu: aMenu [
aMenu addGroup: [:aGroup |
aGroup addItem: [ :item |
item
name: 'Inspect' translated;
action: [ self inspectSelectedObjectInNewWindow ];
shortcut: $i meta ].
aGroup addItem: [ :item |
item
name: 'Explore' translated;
action: [ self exploreSelectedObject ];
shortcut: $i meta shift ].
self customMenuActions cull: aMenu cull: aGroup.
]
]
{ #category : #api }
EyeAbstractInspector >> labelFor: anEyeElement error: error [
^ 'Error while accessing label of ', anEyeElement accessorCode printString
]
{ #category : #accessing }
EyeAbstractInspector >> object [
^ object value
]
{ #category : #accessing }
EyeAbstractInspector >> object: anObject [
object value: anObject
]
{ #category : #'event-handling' }
EyeAbstractInspector >> objectChanged [
"triggered when the inspected object is changed"
self subclassResponsibility
]
{ #category : #'event-handling' }
EyeAbstractInspector >> ownerChanged [
self
customMenuActions: self owner customMenuActions;
takeKeyboardFocus
]
{ #category : #menu }
EyeAbstractInspector >> refreshSubMenu: aMenu [
"Add a refresh button in the inspector. Not used anymore since there is this loop in initializeInspectorLoop."
aMenu
add: 'Refresh Inspector'
target: self
selector: #refresh.
aMenu addLine.
]
{ #category : #accessing }
EyeAbstractInspector >> selectedElement [
"return the currently selected object wrapper / eye-element"
^ self subclassResponsibility
]
{ #category : #accessing }
EyeAbstractInspector >> selectedElementDo: aBlock [
self selectedElement ifNotNil: aBlock
]
{ #category : #accessing }
EyeAbstractInspector >> selectedObject [
^ self subclassResponsibility
]
{ #category : #accessing }
EyeAbstractInspector >> selectedObjectDo: aBlock [
self selectedElement ifNotNil: [ :element |
aBlock value: element value ]
]
{ #category : #initialization }
EyeAbstractInspector >> shortCuts [
"Answers a dictionary of the shortcuts usable in EyeInspector"
|shortCuts|
shortCuts := Dictionary new.
shortCuts at: $d meta put: [ self diveIntoSelectedObject ].
shortCuts at: $i meta put: [ self inspectSelectedObjectInNewWindow ].
shortCuts at: $i meta shift put: [ self exploreSelectedObject ].
shortCuts at: $b meta put: [ self browseSelectedObject ].
shortCuts at: $h meta put: [ self browseSelectedObjectClassHierarchy ].
^shortCuts
]
{ #category : #accessing }
EyeAbstractInspector >> text [
^ text ifNil: [
text := self newCode.
text aboutToStyle: true. ]
]
{ #category : #accessing }
EyeAbstractInspector >> title [
^ self object class printString
]
{ #category : #accessing }
EyeAbstractInspector >> variants [
| variants defaultInspectorClass |
variants := OrderedCollection new.
defaultInspectorClass := self object class inspectorClass.
variants add: defaultInspectorClass.
"We only need the basic inspector if we modify something"
defaultInspectorClass = Object inspectorClass
ifFalse: [ variants add: EyeBasicInspector ].
variants add: EyeTreeInspector.
variants addAll: self object class additionalInspectorClasses.
^ variants
]