Helios-Commands-Core.st 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. isActive
  62. ^ true
  63. !
  64. isBindingGroup
  65. ^ (self class methodDictionary includesKey: 'execute') not
  66. !
  67. isInputRequired
  68. ^ false
  69. ! !
  70. !HLCommand class methodsFor: 'accessing'!
  71. documentation
  72. ^ ''
  73. !
  74. key
  75. "Answer a single character string or nil if no key"
  76. ^ nil
  77. !
  78. label
  79. ^ ''
  80. !
  81. menuLabel
  82. ^ self label
  83. !
  84. registerConcreteClassesOn: aBinding
  85. | newBinding |
  86. self isConcrete
  87. ifTrue: [ newBinding := self registerOn: aBinding ]
  88. ifFalse: [ newBinding := aBinding ].
  89. self subclasses do: [ :each | each registerConcreteClassesOn: newBinding ]
  90. ! !
  91. !HLCommand class methodsFor: 'registration'!
  92. concreteClasses
  93. | classes |
  94. classes := OrderedCollection new.
  95. self isConcrete
  96. ifTrue: [ classes add: self ].
  97. self subclasses do: [ :each |
  98. classes addAll: each concreteClasses ].
  99. ^ classes
  100. !
  101. registerOn: aBinding
  102. ^ self new registerOn: aBinding
  103. ! !
  104. !HLCommand class methodsFor: 'testing'!
  105. isConcrete
  106. ^ self key notNil
  107. !
  108. isValidFor: aModel
  109. ^ false
  110. ! !
  111. HLCommand subclass: #HLCloseTabCommand
  112. instanceVariableNames: ''
  113. package: 'Helios-Commands-Core'!
  114. !HLCloseTabCommand methodsFor: 'executing'!
  115. execute
  116. HLManager current removeActiveTab
  117. ! !
  118. !HLCloseTabCommand class methodsFor: 'accessing'!
  119. key
  120. ^ 'w'
  121. !
  122. label
  123. ^ 'Close tab'
  124. ! !
  125. HLCommand subclass: #HLModelCommand
  126. instanceVariableNames: 'model'
  127. package: 'Helios-Commands-Core'!
  128. !HLModelCommand methodsFor: 'accessing'!
  129. model
  130. ^ model
  131. !
  132. model: aModel
  133. model := aModel
  134. ! !
  135. !HLModelCommand class methodsFor: 'instance creation'!
  136. for: aModel
  137. ^ self new
  138. ! !
  139. !HLModelCommand class methodsFor: 'registration'!
  140. registerConcreteClassesOn: aBinding for: aModel
  141. | newBinding |
  142. self isConcrete
  143. ifTrue: [ newBinding := self registerOn: aBinding for: aModel ]
  144. ifFalse: [ newBinding := aBinding ].
  145. self subclasses do: [ :each |
  146. each registerConcreteClassesOn: newBinding for: aModel ]
  147. !
  148. registerOn: aBinding for: aModel
  149. ^ (self for: aModel) registerOn: aBinding
  150. ! !
  151. HLCommand subclass: #HLOpenCommand
  152. instanceVariableNames: ''
  153. package: 'Helios-Commands-Core'!
  154. !HLOpenCommand class methodsFor: 'accessing'!
  155. key
  156. ^ 'o'
  157. !
  158. label
  159. ^ 'Open'
  160. ! !
  161. HLOpenCommand subclass: #HLOpenBrowserCommand
  162. instanceVariableNames: ''
  163. package: 'Helios-Commands-Core'!
  164. !HLOpenBrowserCommand methodsFor: 'executing'!
  165. execute
  166. ^ HLBrowser openAsTab
  167. ! !
  168. !HLOpenBrowserCommand class methodsFor: 'accessing'!
  169. key
  170. ^ 'b'
  171. !
  172. label
  173. ^ 'Browser'
  174. ! !
  175. HLOpenCommand subclass: #HLOpenTranscriptCommand
  176. instanceVariableNames: ''
  177. package: 'Helios-Commands-Core'!
  178. !HLOpenTranscriptCommand methodsFor: 'executing'!
  179. execute
  180. ^ HLTranscript openAsTab
  181. ! !
  182. !HLOpenTranscriptCommand class methodsFor: 'accessing'!
  183. key
  184. ^ 't'
  185. !
  186. label
  187. ^ 'Transcript'
  188. ! !
  189. HLOpenCommand subclass: #HLOpenWorkspaceCommand
  190. instanceVariableNames: ''
  191. package: 'Helios-Commands-Core'!
  192. !HLOpenWorkspaceCommand methodsFor: 'executing'!
  193. execute
  194. ^ HLWorkspace openAsTab
  195. ! !
  196. !HLOpenWorkspaceCommand class methodsFor: 'accessing'!
  197. key
  198. ^ 'w'
  199. !
  200. label
  201. ^ 'Workspace'
  202. ! !
  203. HLCommand subclass: #HLViewCommand
  204. instanceVariableNames: ''
  205. package: 'Helios-Commands-Core'!
  206. !HLViewCommand class methodsFor: 'accessing'!
  207. label
  208. ^ 'View'
  209. ! !