Helios-Commands-Core.st 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. Smalltalk current createPackage: 'Helios-Commands-Core'!
  2. Object subclass: #HLCommand
  3. instanceVariableNames: 'input'
  4. package: 'Helios-Commands-Core'!
  5. !HLCommand methodsFor: 'accessing'!
  6. documentation
  7. ^ self class documentation
  8. !
  9. input
  10. ^ input
  11. !
  12. input: aString
  13. ^ input := aString
  14. !
  15. inputCompletion
  16. ^ #()
  17. !
  18. inputLabel
  19. ^ self label
  20. !
  21. key
  22. ^ self class key
  23. !
  24. keyCode
  25. ^ self key asUppercase charCodeAt: 1
  26. !
  27. label
  28. ^ self class label
  29. !
  30. menuLabel
  31. ^ self class menuLabel
  32. ! !
  33. !HLCommand methodsFor: 'converting'!
  34. asActionBinding
  35. ^ (HLBindingAction on: self keyCode labelled: self label)
  36. command: self;
  37. yourself
  38. !
  39. asBinding
  40. ^ self isBindingGroup
  41. ifTrue: [ self asGroupBinding ]
  42. ifFalse: [ self asActionBinding ]
  43. !
  44. asGroupBinding
  45. ^ HLBindingGroup
  46. on: self keyCode
  47. labelled: self label
  48. ! !
  49. !HLCommand methodsFor: 'error handling'!
  50. commandError: aString
  51. self error: aString
  52. ! !
  53. !HLCommand methodsFor: 'executing'!
  54. execute
  55. ! !
  56. !HLCommand methodsFor: 'registration'!
  57. registerOn: aBinding
  58. ^ aBinding add: self asBinding
  59. ! !
  60. !HLCommand methodsFor: 'testing'!
  61. isAction
  62. ^ self isBindingGroup not
  63. !
  64. isActive
  65. ^ true
  66. !
  67. isBindingGroup
  68. ^ (self class methodDictionary includesKey: 'execute') not
  69. !
  70. isInputRequired
  71. ^ false
  72. ! !
  73. !HLCommand class methodsFor: 'accessing'!
  74. documentation
  75. ^ ''
  76. !
  77. key
  78. "Answer a single character string or nil if no key"
  79. ^ nil
  80. !
  81. label
  82. ^ ''
  83. !
  84. menuLabel
  85. ^ self label
  86. !
  87. registerConcreteClassesOn: aBinding
  88. | newBinding |
  89. self isConcrete
  90. ifTrue: [ newBinding := self registerOn: aBinding ]
  91. ifFalse: [ newBinding := aBinding ].
  92. self subclasses do: [ :each | each registerConcreteClassesOn: newBinding ]
  93. ! !
  94. !HLCommand class methodsFor: 'registration'!
  95. concreteClasses
  96. | classes |
  97. classes := OrderedCollection new.
  98. self isConcrete
  99. ifTrue: [ classes add: self ].
  100. self subclasses do: [ :each |
  101. classes addAll: each concreteClasses ].
  102. ^ classes
  103. !
  104. registerOn: aBinding
  105. ^ self new registerOn: aBinding
  106. ! !
  107. !HLCommand class methodsFor: 'testing'!
  108. isConcrete
  109. ^ self key notNil
  110. !
  111. isValidFor: aModel
  112. ^ false
  113. ! !
  114. HLCommand subclass: #HLCloseTabCommand
  115. instanceVariableNames: ''
  116. package: 'Helios-Commands-Core'!
  117. !HLCloseTabCommand methodsFor: 'executing'!
  118. execute
  119. HLManager current removeActiveTab
  120. ! !
  121. !HLCloseTabCommand class methodsFor: 'accessing'!
  122. key
  123. ^ 'w'
  124. !
  125. label
  126. ^ 'Close tab'
  127. ! !
  128. HLCommand subclass: #HLModelCommand
  129. instanceVariableNames: 'model'
  130. package: 'Helios-Commands-Core'!
  131. !HLModelCommand methodsFor: 'accessing'!
  132. model
  133. ^ model
  134. !
  135. model: aModel
  136. model := aModel
  137. ! !
  138. !HLModelCommand class methodsFor: 'instance creation'!
  139. for: aModel
  140. ^ self new
  141. ! !
  142. !HLModelCommand class methodsFor: 'registration'!
  143. registerConcreteClassesOn: aBinding for: aModel
  144. | newBinding |
  145. self isConcrete
  146. ifTrue: [ newBinding := self registerOn: aBinding for: aModel ]
  147. ifFalse: [ newBinding := aBinding ].
  148. self subclasses do: [ :each |
  149. each registerConcreteClassesOn: newBinding for: aModel ]
  150. !
  151. registerOn: aBinding for: aModel
  152. ^ (self for: aModel) registerOn: aBinding
  153. ! !
  154. HLCommand subclass: #HLOpenCommand
  155. instanceVariableNames: ''
  156. package: 'Helios-Commands-Core'!
  157. !HLOpenCommand class methodsFor: 'accessing'!
  158. key
  159. ^ 'o'
  160. !
  161. label
  162. ^ 'Open'
  163. ! !
  164. HLOpenCommand subclass: #HLOpenBrowserCommand
  165. instanceVariableNames: ''
  166. package: 'Helios-Commands-Core'!
  167. !HLOpenBrowserCommand methodsFor: 'executing'!
  168. execute
  169. ^ HLBrowser openAsTab
  170. ! !
  171. !HLOpenBrowserCommand class methodsFor: 'accessing'!
  172. key
  173. ^ 'b'
  174. !
  175. label
  176. ^ 'Browser'
  177. ! !
  178. HLOpenCommand subclass: #HLOpenTranscriptCommand
  179. instanceVariableNames: ''
  180. package: 'Helios-Commands-Core'!
  181. !HLOpenTranscriptCommand methodsFor: 'executing'!
  182. execute
  183. ^ HLTranscript openAsTab
  184. ! !
  185. !HLOpenTranscriptCommand class methodsFor: 'accessing'!
  186. key
  187. ^ 't'
  188. !
  189. label
  190. ^ 'Transcript'
  191. ! !
  192. HLOpenCommand subclass: #HLOpenWorkspaceCommand
  193. instanceVariableNames: ''
  194. package: 'Helios-Commands-Core'!
  195. !HLOpenWorkspaceCommand methodsFor: 'executing'!
  196. execute
  197. ^ HLWorkspace openAsTab
  198. ! !
  199. !HLOpenWorkspaceCommand class methodsFor: 'accessing'!
  200. key
  201. ^ 'w'
  202. !
  203. label
  204. ^ 'Workspace'
  205. ! !
  206. HLCommand subclass: #HLViewCommand
  207. instanceVariableNames: ''
  208. package: 'Helios-Commands-Core'!
  209. !HLViewCommand class methodsFor: 'accessing'!
  210. label
  211. ^ 'View'
  212. ! !