Helios-Inspector.st 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. Smalltalk current createPackage: 'Helios-Inspector' properties: #{}!
  2. HLWidget subclass: #HLInspector
  3. instanceVariableNames: 'model variables display code label'
  4. package: 'Helios-Inspector'!
  5. !HLInspector methodsFor: 'accessing'!
  6. code
  7. ^ code ifNil:[self initializeCode]
  8. !
  9. display
  10. ^ display ifNil:[self initializeDisplay]
  11. !
  12. inspectee
  13. ^ self model inspectee
  14. !
  15. inspectee: anObject
  16. self model inspectee: anObject
  17. !
  18. label
  19. ^ label ifNil:[self initializeLabel]
  20. !
  21. model
  22. ^ model ifNil:[self initializeModel]
  23. !
  24. model: aModel
  25. model := aModel.
  26. self code model: aModel code.
  27. self observeCode.
  28. !
  29. tabLabel
  30. ^ self label
  31. !
  32. variables
  33. ^ variables ifNil:[self initializeVariables]
  34. ! !
  35. !HLInspector methodsFor: 'actions'!
  36. ensureModel
  37. "Sends the #model: initialization message if needed."
  38. model ifNil:[
  39. self model: self model.
  40. self observeVariables]
  41. !
  42. inspect: anObject
  43. self model inspect: anObject on: self
  44. !
  45. makeCode
  46. ^ HLCodeWidget new
  47. model: model code;
  48. doItReaction: [self refresh];
  49. yourself.
  50. !
  51. makeDisplay
  52. ^ HLInspectorDisplay new
  53. model: self model;
  54. yourself
  55. !
  56. makeVariables
  57. ^ HLInspectorVariables new
  58. model: self model;
  59. yourself
  60. !
  61. observeCode
  62. !
  63. observeVariables
  64. self variables announcer
  65. on: HLRefreshRequested do:[:ann| self onRefresh];
  66. on: HLInstanceVariableSelected do:[:ann| self onInstanceVariableSelected];
  67. yourself
  68. !
  69. open
  70. HLManager current addTab: (HLTab on: self labelled: self tabLabel)
  71. !
  72. refresh
  73. self
  74. inspect: self inspectee;
  75. refreshVariables;
  76. refreshDisplay
  77. !
  78. refreshDisplay
  79. self display refresh
  80. !
  81. refreshVariables
  82. self variables refresh
  83. !
  84. setLabel: aString
  85. label := aString
  86. !
  87. setVariables: aDictionary
  88. self model variables: aDictionary
  89. ! !
  90. !HLInspector methodsFor: 'initialization'!
  91. initializeCode
  92. ^ code := self makeCode.
  93. !
  94. initializeDisplay
  95. ^ display := self makeDisplay
  96. !
  97. initializeLabel
  98. ^ label := model inspectee printString
  99. !
  100. initializeModel
  101. ^ model := HLInspectorModel new
  102. !
  103. initializeVariables
  104. ^ variables := self makeVariables
  105. ! !
  106. !HLInspector methodsFor: 'reactions'!
  107. onDoIt
  108. !
  109. onInspectIt
  110. !
  111. onInstanceVariableSelected
  112. self halt.
  113. !
  114. onPrintIt
  115. !
  116. onRefresh
  117. self refresh
  118. ! !
  119. !HLInspector methodsFor: 'rendering'!
  120. renderContentOn: html
  121. self ensureModel.
  122. html with: (HLContainer with: (HLHorizontalSplitter
  123. with: (HLVerticalSplitter
  124. with: self variables
  125. with: self display)
  126. with: self code))
  127. ! !
  128. !HLInspector class methodsFor: 'accessing'!
  129. tabLabel
  130. ^ 'Inspector'
  131. !
  132. tabPriority
  133. ^ 10
  134. ! !
  135. !HLInspector class methodsFor: 'testing'!
  136. canBeOpenAsTab
  137. ^ false
  138. ! !
  139. HLNavigationListWidget subclass: #HLInspectorDisplay
  140. instanceVariableNames: 'model'
  141. package: 'Helios-Inspector'!
  142. !HLInspectorDisplay methodsFor: 'accessing'!
  143. model
  144. ^ model
  145. !
  146. model: aModel
  147. model := aModel
  148. ! !
  149. !HLInspectorDisplay methodsFor: 'rendering'!
  150. renderContentOn: html
  151. html div with: model selection printString
  152. ! !
  153. Object subclass: #HLInspectorModel
  154. instanceVariableNames: 'announcer environment inspectee code variables selection'
  155. package: 'Helios-Inspector'!
  156. !HLInspectorModel methodsFor: 'accessing'!
  157. announcer
  158. ^ announcer ifNil: [ self initializeAnnouncer ]
  159. !
  160. code
  161. "Answers the code model working for this workspace model"
  162. ^ code ifNil:[self initializeCode]
  163. !
  164. environment
  165. ^ environment ifNil: [ self initializeEnvironment]
  166. !
  167. environment: anEnvironment
  168. environment := anEnvironment
  169. !
  170. inspectee
  171. ^ inspectee
  172. !
  173. inspectee: anObject
  174. inspectee := anObject
  175. !
  176. selection
  177. ^ selection ifNil:[self initializeSelection]
  178. !
  179. selection: anObject
  180. selection := anObject
  181. !
  182. variables
  183. ^ variables
  184. !
  185. variables: aCollection
  186. variables := aCollection
  187. ! !
  188. !HLInspectorModel methodsFor: 'actions'!
  189. beLocal
  190. self initializeEnvironment
  191. !
  192. beRemoteOn: anIPAddress port: aPort
  193. "to-do"
  194. "environment := HLRemoteEnvironment on: anIPAddress port: aPort
  195. ...kind of stuff"
  196. !
  197. inspect: anObject on: anInspector
  198. inspectee := anObject.
  199. variables := #().
  200. inspectee inspectOn: anInspector
  201. !
  202. subscribe: aWidget
  203. aWidget subscribeTo: self announcer
  204. ! !
  205. !HLInspectorModel methodsFor: 'initialization'!
  206. initializeAnnouncer
  207. ^ announcer := Announcer new
  208. !
  209. initializeCode
  210. ^ code := HLCodeModel on: self environment
  211. !
  212. initializeEnvironment
  213. ^ environment := HLLocalEnvironment new
  214. !
  215. initializeSelection
  216. ^ selection := self inspectee
  217. ! !
  218. !HLInspectorModel methodsFor: 'reactions'!
  219. onKeyDown: anEvent
  220. <if(anEvent.ctrlKey) {
  221. if(anEvent.keyCode === 80) { //ctrl+p
  222. self._printIt();
  223. anEvent.preventDefault();
  224. return false;
  225. }
  226. if(anEvent.keyCode === 68) { //ctrl+d
  227. self._doIt();
  228. anEvent.preventDefault();
  229. return false;
  230. }
  231. if(anEvent.keyCode === 73) { //ctrl+i
  232. self._inspectIt();
  233. anEvent.preventDefault();
  234. return false;
  235. }
  236. }>
  237. ! !
  238. !HLInspectorModel class methodsFor: 'actions'!
  239. on: anEnvironment
  240. ^ self new
  241. environment: anEnvironment;
  242. yourself
  243. ! !
  244. HLNavigationListWidget subclass: #HLInspectorVariables
  245. instanceVariableNames: 'announcer model list diveButton'
  246. package: 'Helios-Inspector'!
  247. !HLInspectorVariables methodsFor: 'accessing'!
  248. announcer
  249. ^ announcer ifNil:[self initializeAnnouncer]
  250. !
  251. model
  252. ^ model
  253. !
  254. model: aModel
  255. model := aModel
  256. !
  257. selection
  258. ^ model selection
  259. !
  260. variables
  261. ^ model variables
  262. ! !
  263. !HLInspectorVariables methodsFor: 'actions'!
  264. refresh
  265. self resetItems.
  266. super refresh
  267. !
  268. resetItems
  269. items := nil
  270. ! !
  271. !HLInspectorVariables methodsFor: 'initialization'!
  272. initializeAnnouncer
  273. ^ announcer := Announcer new
  274. !
  275. initializeItems
  276. ^ items := self model variables keys
  277. ! !
  278. !HLInspectorVariables methodsFor: 'rendering'!
  279. renderButtonsOn: html
  280. html button
  281. class: 'btn';
  282. with: 'Refresh';
  283. onClick: [self announcer announce: HLRefreshRequested new].
  284. diveButton := html button
  285. class: 'btn';
  286. with: 'Dive';
  287. onClick: [self announcer announce: HLDiveRequested new]
  288. ! !