Helios-Inspector.st 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. Smalltalk createPackage: 'Helios-Inspector'!
  2. HLNavigationListWidget subclass: #HLInspectorDisplayWidget
  3. instanceVariableNames: 'model'
  4. package: 'Helios-Inspector'!
  5. !HLInspectorDisplayWidget methodsFor: 'accessing'!
  6. model
  7. ^ model
  8. !
  9. model: aModel
  10. model := aModel
  11. ! !
  12. !HLInspectorDisplayWidget methodsFor: 'rendering'!
  13. renderContentOn: html
  14. html div with: self selectionDisplayString
  15. !
  16. selectionDisplayString
  17. |selection|
  18. selection := model selection.
  19. ^ (model variables includesKey: selection)
  20. ifTrue:[ (model instVarObjectAt: selection) printString ]
  21. ifFalse:[ '' ]
  22. ! !
  23. Object subclass: #HLInspectorModel
  24. instanceVariableNames: 'announcer environment inspectee code variables label selection'
  25. package: 'Helios-Inspector'!
  26. !HLInspectorModel methodsFor: 'accessing'!
  27. announcer
  28. ^ announcer ifNil: [ announcer := Announcer new ]
  29. !
  30. code
  31. "Answers the code model working for this workspace model"
  32. ^ code ifNil:[ code := HLCodeModel on: self environment ]
  33. !
  34. environment
  35. ^ environment ifNil: [ HLManager current environment ]
  36. !
  37. environment: anEnvironment
  38. environment := anEnvironment
  39. !
  40. inspectee
  41. ^ inspectee
  42. !
  43. inspectee: anObject
  44. inspectee := anObject
  45. !
  46. label
  47. ^ label ifNil: [ self inspectee printString ]
  48. !
  49. label: aString
  50. label := aString
  51. !
  52. selectedInstVarObject
  53. ^ self instVarObjectAt: self selection
  54. !
  55. selection
  56. ^ selection ifNil:[ '' ]
  57. !
  58. selection: anObject
  59. selection := anObject.
  60. self announcer announce: (HLInstanceVariableSelected on: selection)
  61. !
  62. variables
  63. ^ variables ifNil: [ Dictionary new ]
  64. !
  65. variables: aCollection
  66. variables := aCollection
  67. ! !
  68. !HLInspectorModel methodsFor: 'actions'!
  69. inspect: anObject on: anInspector
  70. inspectee := anObject.
  71. variables := #().
  72. inspectee inspectOn: anInspector
  73. !
  74. instVarObjectAt: anInstVarName
  75. ^ self variables at: anInstVarName
  76. !
  77. selectedInstVar: anInstVarName
  78. self selection: anInstVarName
  79. !
  80. subscribe: aWidget
  81. aWidget subscribeTo: self announcer
  82. ! !
  83. !HLInspectorModel class methodsFor: 'actions'!
  84. on: anEnvironment
  85. ^ self new
  86. environment: anEnvironment;
  87. yourself
  88. ! !
  89. HLNavigationListWidget subclass: #HLInspectorVariablesWidget
  90. instanceVariableNames: 'announcer model list diveButton'
  91. package: 'Helios-Inspector'!
  92. !HLInspectorVariablesWidget methodsFor: 'accessing'!
  93. announcer
  94. ^ announcer ifNil:[ announcer := Announcer new ]
  95. !
  96. label
  97. ^ self model label
  98. !
  99. model
  100. ^ model
  101. !
  102. model: aModel
  103. model := aModel
  104. !
  105. selection
  106. ^ model selection
  107. !
  108. variables
  109. ^ self model variables keys
  110. ! !
  111. !HLInspectorVariablesWidget methodsFor: 'actions'!
  112. refresh
  113. self variables = self items ifFalse: [
  114. self resetItems.
  115. super refresh ]
  116. !
  117. resetItems
  118. items := nil
  119. ! !
  120. !HLInspectorVariablesWidget methodsFor: 'defaults'!
  121. defaultItems
  122. ^ self variables
  123. ! !
  124. !HLInspectorVariablesWidget methodsFor: 'reactions'!
  125. selectItem: anObject
  126. super selectItem: anObject.
  127. self model selectedInstVar: anObject
  128. ! !
  129. !HLInspectorVariablesWidget methodsFor: 'rendering'!
  130. renderButtonsOn: html
  131. diveButton := html button
  132. class: 'btn';
  133. with: 'Dive';
  134. onClick: [ self announcer announce: HLDiveRequested new ]
  135. !
  136. renderContentOn: html
  137. self renderHeadOn: html.
  138. super renderContentOn: html
  139. !
  140. renderHeadOn: html
  141. html div
  142. class: 'list-label';
  143. with: self label
  144. ! !
  145. HLWidget subclass: #HLInspectorWidget
  146. instanceVariableNames: 'model variablesWidget displayWidget codeWidget'
  147. package: 'Helios-Inspector'!
  148. !HLInspectorWidget methodsFor: 'accessing'!
  149. codeWidget
  150. ^ codeWidget ifNil: [
  151. codeWidget := HLCodeWidget new
  152. model: model code;
  153. receiver: model inspectee;
  154. yourself ]
  155. !
  156. displayWidget
  157. ^ displayWidget ifNil: [
  158. displayWidget := HLInspectorDisplayWidget new
  159. model: self model;
  160. yourself ]
  161. !
  162. initialize
  163. super initialize.
  164. self register
  165. !
  166. inspectee
  167. ^ self model inspectee
  168. !
  169. inspectee: anObject
  170. self model inspectee: anObject
  171. !
  172. label
  173. ^ self model label
  174. !
  175. model
  176. ^ model ifNil: [
  177. self model: HLInspectorModel new.
  178. model ]
  179. !
  180. model: aModel
  181. model := aModel.
  182. self codeWidget model: aModel code.
  183. self
  184. observeCodeWidget;
  185. observeVariablesWidget;
  186. observeModel
  187. !
  188. tabLabel
  189. ^ 'Inspector'
  190. !
  191. variablesWidget
  192. ^ variablesWidget ifNil: [
  193. variablesWidget := HLInspectorVariablesWidget new
  194. model: self model;
  195. yourself ]
  196. ! !
  197. !HLInspectorWidget methodsFor: 'actions'!
  198. inspect: anObject
  199. self model inspect: anObject on: self.
  200. self codeWidget receiver: anObject.
  201. self
  202. refreshVariablesWidget;
  203. refreshDisplayWidget
  204. !
  205. observeCodeWidget
  206. self codeWidget announcer
  207. on: HLDoItExecuted
  208. do: [ self onDoneIt ]
  209. !
  210. observeModel
  211. self model announcer
  212. on: HLInstanceVariableSelected
  213. send: #onInstanceVariableSelected
  214. to: self
  215. !
  216. observeVariablesWidget
  217. self variablesWidget announcer
  218. on: HLDiveRequested do:[ self onDive ]
  219. !
  220. refresh
  221. self inspect: self inspectee
  222. !
  223. refreshDisplayWidget
  224. self displayWidget refresh
  225. !
  226. refreshVariablesWidget
  227. self variablesWidget refresh
  228. !
  229. setLabel: aString
  230. self model label: aString
  231. !
  232. setVariables: aDictionary
  233. self model variables: aDictionary
  234. ! !
  235. !HLInspectorWidget methodsFor: 'reactions'!
  236. onDive
  237. HLInspector new
  238. inspect: self model selectedInstVarObject;
  239. openAsTab
  240. !
  241. onDoneIt
  242. self refresh
  243. !
  244. onInspectIt
  245. !
  246. onInstanceVariableSelected
  247. self refreshDisplayWidget
  248. !
  249. onPrintIt
  250. ! !
  251. !HLInspectorWidget methodsFor: 'registration'!
  252. register
  253. HLInspector register: self
  254. !
  255. unregister
  256. super unregister.
  257. HLInspector unregister: self
  258. ! !
  259. !HLInspectorWidget methodsFor: 'rendering'!
  260. renderContentOn: html
  261. html with: (HLHorizontalSplitter
  262. with: (HLVerticalSplitter
  263. with: self variablesWidget
  264. with: self displayWidget)
  265. with: self codeWidget)
  266. ! !
  267. HLInspectorWidget subclass: #HLInspector
  268. instanceVariableNames: ''
  269. package: 'Helios-Inspector'!
  270. !HLInspector methodsFor: 'rendering'!
  271. renderContentOn: html
  272. html with: (HLContainer with: (HLHorizontalSplitter
  273. with: (HLVerticalSplitter
  274. with: self variablesWidget
  275. with: self displayWidget)
  276. with: self codeWidget)).
  277. self variablesWidget focus
  278. ! !
  279. HLInspector class instanceVariableNames: 'inspectors'!
  280. !HLInspector class methodsFor: 'accessing'!
  281. inspectors
  282. ^ inspectors ifNil: [ inspectors := OrderedCollection new ]
  283. !
  284. tabClass
  285. ^ 'inspector'
  286. !
  287. tabLabel
  288. ^ 'Inspector'
  289. !
  290. tabPriority
  291. ^ 10
  292. ! !
  293. !HLInspector class methodsFor: 'actions'!
  294. inspect: anObject
  295. self new
  296. openAsTab;
  297. inspect: anObject
  298. ! !
  299. !HLInspector class methodsFor: 'initialization'!
  300. initialize
  301. super initialize.
  302. self watchChanges
  303. !
  304. watchChanges
  305. [ self inspectors do: [ :each | each refresh ] ]
  306. valueWithInterval: 500
  307. ! !
  308. !HLInspector class methodsFor: 'registration'!
  309. register: anInspector
  310. self inspectors add: anInspector
  311. !
  312. unregister: anInspector
  313. self inspectors remove: anInspector
  314. ! !
  315. !HLInspector class methodsFor: 'testing'!
  316. canBeOpenAsTab
  317. ^ false
  318. ! !