Helios-Inspector.st 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. Smalltalk current createPackage: 'Helios-Inspector' properties: #{}!
  2. HLWidget subclass: #HLInspector
  3. instanceVariableNames: 'model variables display code'
  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. model
  19. ^ model ifNil:[self initializeModel]
  20. !
  21. model: aModel
  22. model := aModel.
  23. self code model: aModel code.
  24. self observeCode.
  25. !
  26. tabLabel
  27. ^ model inspectee printString
  28. !
  29. variables
  30. ^ variables ifNil:[self initializeVariables]
  31. ! !
  32. !HLInspector methodsFor: 'actions'!
  33. ensureModel
  34. "Sends the #model: initialization message if needed."
  35. model ifNil:[
  36. self model: self model]
  37. !
  38. inspect: anObject
  39. self model inspectee: anObject
  40. !
  41. makeCode
  42. ^ HLCodeWidget new
  43. model: model code;
  44. doItReaction: [self refresh];
  45. yourself.
  46. !
  47. makeDisplay
  48. ^ HLInspectorDisplay new
  49. model: self model;
  50. yourself
  51. !
  52. makeVariables
  53. ^ HLInspectorVariables new
  54. model: self model;
  55. yourself
  56. !
  57. observeCode
  58. !
  59. open
  60. HLManager current addTab: (HLTab on: self labelled: self tabLabel)
  61. !
  62. refresh
  63. self
  64. inspect: self inspectee;
  65. updateVariablesList;
  66. updateValueTextarea
  67. ! !
  68. !HLInspector methodsFor: 'initialization'!
  69. initializeCode
  70. ^ code := self makeCode.
  71. !
  72. initializeDisplay
  73. ^ display := self makeDisplay
  74. !
  75. initializeModel
  76. ^ model := HLInspectorModel new
  77. !
  78. initializeVariables
  79. ^ variables := self makeVariables
  80. ! !
  81. !HLInspector methodsFor: 'reactions'!
  82. onDoIt
  83. !
  84. onInspectIt
  85. !
  86. onPrintIt
  87. ! !
  88. !HLInspector methodsFor: 'rendering'!
  89. renderContentOn: html
  90. self ensureModel.
  91. html with: (HLContainer with: (HLHorizontalSplitter
  92. with: (HLVerticalSplitter
  93. with: self variables
  94. with: self display)
  95. with: self code))
  96. ! !
  97. !HLInspector class methodsFor: 'accessing'!
  98. tabLabel
  99. ^ 'Inspector'
  100. !
  101. tabPriority
  102. ^ 10
  103. ! !
  104. !HLInspector class methodsFor: 'testing'!
  105. canBeOpenAsTab
  106. ^ false
  107. ! !
  108. HLNavigationListWidget subclass: #HLInspectorDisplay
  109. instanceVariableNames: 'model'
  110. package: 'Helios-Inspector'!
  111. !HLInspectorDisplay methodsFor: 'accessing'!
  112. model
  113. ^ model
  114. !
  115. model: aModel
  116. model := aModel
  117. ! !
  118. !HLInspectorDisplay methodsFor: 'rendering'!
  119. renderContentOn: html
  120. html div with: 'display'
  121. ! !
  122. Object subclass: #HLInspectorModel
  123. instanceVariableNames: 'announcer environment inspectee code variables selection'
  124. package: 'Helios-Inspector'!
  125. !HLInspectorModel methodsFor: 'accessing'!
  126. announcer
  127. ^ announcer ifNil: [ self initializeAnnouncer ]
  128. !
  129. code
  130. "Answers the code model working for this workspace model"
  131. ^ code ifNil:[self initializeCode]
  132. !
  133. environment
  134. ^ environment ifNil: [ self initializeEnvironment]
  135. !
  136. environment: anEnvironment
  137. environment := anEnvironment
  138. !
  139. inspectee
  140. ^ inspectee
  141. !
  142. inspectee: anObject
  143. inspectee := anObject
  144. !
  145. selection
  146. ^ selection ifNil:[self initializeSelection]
  147. !
  148. selection: anObject
  149. selection := anObject
  150. ! !
  151. !HLInspectorModel methodsFor: 'actions'!
  152. beLocal
  153. self initializeEnvironment
  154. !
  155. beRemoteOn: anIPAddress port: aPort
  156. "to-do"
  157. "environment := HLRemoteEnvironment on: anIPAddress port: aPort
  158. ...kind of stuff"
  159. !
  160. subscribe: aWidget
  161. aWidget subscribeTo: self announcer
  162. ! !
  163. !HLInspectorModel methodsFor: 'initialization'!
  164. initializeAnnouncer
  165. ^ announcer := Announcer new
  166. !
  167. initializeCode
  168. ^ code := HLCodeModel on: self environment
  169. !
  170. initializeEnvironment
  171. ^ environment := HLLocalEnvironment new
  172. !
  173. initializeSelection
  174. ^ selection := self inspectee
  175. ! !
  176. !HLInspectorModel methodsFor: 'reactions'!
  177. onKeyDown: anEvent
  178. <if(anEvent.ctrlKey) {
  179. if(anEvent.keyCode === 80) { //ctrl+p
  180. self._printIt();
  181. anEvent.preventDefault();
  182. return false;
  183. }
  184. if(anEvent.keyCode === 68) { //ctrl+d
  185. self._doIt();
  186. anEvent.preventDefault();
  187. return false;
  188. }
  189. if(anEvent.keyCode === 73) { //ctrl+i
  190. self._inspectIt();
  191. anEvent.preventDefault();
  192. return false;
  193. }
  194. }>
  195. ! !
  196. !HLInspectorModel class methodsFor: 'actions'!
  197. on: anEnvironment
  198. ^ self new
  199. environment: anEnvironment;
  200. yourself
  201. ! !
  202. HLNavigationListWidget subclass: #HLInspectorVariables
  203. instanceVariableNames: 'model'
  204. package: 'Helios-Inspector'!
  205. !HLInspectorVariables methodsFor: 'accessing'!
  206. model
  207. ^ model
  208. !
  209. model: aModel
  210. model := aModel
  211. ! !
  212. !HLInspectorVariables methodsFor: 'rendering'!
  213. renderContentOn: html
  214. html div with: 'variables'
  215. ! !