Helios-Commands-Tools.st 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. Smalltalk createPackage: 'Helios-Commands-Tools'!
  2. HLModelCommand subclass: #HLToolCommand
  3. instanceVariableNames: ''
  4. package: 'Helios-Commands-Tools'!
  5. !HLToolCommand methodsFor: 'accessing'!
  6. category
  7. ^ nil
  8. ! !
  9. !HLToolCommand class methodsFor: 'instance creation'!
  10. for: aToolModel
  11. ^ self new
  12. model: aToolModel;
  13. yourself
  14. ! !
  15. !HLToolCommand class methodsFor: 'testing'!
  16. isValidFor: aModel
  17. ^ aModel isToolModel
  18. ! !
  19. HLToolCommand subclass: #HLBrowseMethodCommand
  20. instanceVariableNames: ''
  21. package: 'Helios-Commands-Tools'!
  22. !HLBrowseMethodCommand methodsFor: 'accessing'!
  23. displayLabel
  24. ^ 'browse method'
  25. ! !
  26. !HLBrowseMethodCommand methodsFor: 'executing'!
  27. execute
  28. self model openMethod
  29. ! !
  30. !HLBrowseMethodCommand class methodsFor: 'accessing'!
  31. key
  32. ^ 'b'
  33. !
  34. label
  35. ^ 'browse method'
  36. ! !
  37. !HLBrowseMethodCommand class methodsFor: 'testing'!
  38. isValidFor: aModel
  39. ^ aModel isReferencesModel
  40. ! !
  41. HLToolCommand subclass: #HLCommitPackageCommand
  42. instanceVariableNames: ''
  43. package: 'Helios-Commands-Tools'!
  44. !HLCommitPackageCommand methodsFor: 'accessing'!
  45. category
  46. ^ 'Packages'
  47. ! !
  48. !HLCommitPackageCommand methodsFor: 'error handling'!
  49. onPackageCommitError: anError
  50. (HLPackageCommitErrorHelper on: self model)
  51. showHelp
  52. ! !
  53. !HLCommitPackageCommand methodsFor: 'executing'!
  54. commitPackage
  55. self model
  56. commitPackageOnSuccess: [ self informSuccess ]
  57. onError: [ :error | self onPackageCommitError: error ]
  58. !
  59. execute
  60. self commitPackage
  61. !
  62. informSuccess
  63. HLInformationWidget new
  64. informationString: 'Commit successful!!';
  65. show
  66. ! !
  67. !HLCommitPackageCommand methodsFor: 'testing'!
  68. isActive
  69. ^ true
  70. "self model isPackageDirty"
  71. ! !
  72. !HLCommitPackageCommand class methodsFor: 'accessing'!
  73. key
  74. ^ 'k'
  75. !
  76. label
  77. ^ 'Commit package'
  78. ! !
  79. HLToolCommand subclass: #HLCopyCommand
  80. instanceVariableNames: ''
  81. package: 'Helios-Commands-Tools'!
  82. !HLCopyCommand class methodsFor: 'accessing'!
  83. key
  84. ^ 'c'
  85. !
  86. label
  87. ^ 'Copy'
  88. ! !
  89. HLCopyCommand subclass: #HLCopyClassCommand
  90. instanceVariableNames: ''
  91. package: 'Helios-Commands-Tools'!
  92. !HLCopyClassCommand methodsFor: 'accessing'!
  93. category
  94. ^ 'Classes'
  95. !
  96. displayLabel
  97. ^ 'New class name:'
  98. ! !
  99. !HLCopyClassCommand methodsFor: 'defaults'!
  100. defaultInput
  101. ^ self model selectedClass theNonMetaClass name
  102. ! !
  103. !HLCopyClassCommand methodsFor: 'executing'!
  104. execute
  105. self model copyClassTo: self input
  106. ! !
  107. !HLCopyClassCommand methodsFor: 'testing'!
  108. isActive
  109. ^ self model selectedClass notNil
  110. !
  111. isInputRequired
  112. ^ true
  113. ! !
  114. !HLCopyClassCommand class methodsFor: 'accessing'!
  115. key
  116. ^ 'c'
  117. !
  118. label
  119. ^ 'Copy class'
  120. !
  121. menuLabel
  122. ^ 'Copy class...'
  123. ! !
  124. HLToolCommand subclass: #HLFindCommand
  125. instanceVariableNames: ''
  126. package: 'Helios-Commands-Tools'!
  127. !HLFindCommand class methodsFor: 'accessing'!
  128. key
  129. ^ 'f'
  130. !
  131. label
  132. ^ 'Find'
  133. ! !
  134. HLFindCommand subclass: #HLFindClassCommand
  135. instanceVariableNames: ''
  136. package: 'Helios-Commands-Tools'!
  137. !HLFindClassCommand methodsFor: 'accessing'!
  138. displayLabel
  139. ^ 'select a class'
  140. !
  141. inputCompletion
  142. ^ self model availableClassNames
  143. !
  144. inputLabel
  145. ^ 'Find a class'
  146. ! !
  147. !HLFindClassCommand methodsFor: 'executing'!
  148. execute
  149. self model openClassNamed: self input
  150. ! !
  151. !HLFindClassCommand methodsFor: 'testing'!
  152. isInputRequired
  153. ^ true
  154. ! !
  155. !HLFindClassCommand class methodsFor: 'accessing'!
  156. key
  157. ^ 'c'
  158. !
  159. label
  160. ^ 'Find class'
  161. ! !
  162. !HLFindClassCommand class methodsFor: 'testing'!
  163. isValidFor: aModel
  164. ^ true
  165. ! !
  166. HLFindCommand subclass: #HLFindReferencesCommand
  167. instanceVariableNames: ''
  168. package: 'Helios-Commands-Tools'!
  169. !HLFindReferencesCommand methodsFor: 'accessing'!
  170. displayLabel
  171. ^ 'find references'
  172. !
  173. inputCompletion
  174. ^ self model availableClassNames, self model allSelectors
  175. !
  176. inputLabel
  177. ^ 'Find references of'
  178. ! !
  179. !HLFindReferencesCommand methodsFor: 'defaults'!
  180. defaultInput
  181. ^ self model selectedMethod
  182. ifNil: [
  183. self model selectedClass
  184. ifNil: [ '' ]
  185. ifNotNil: [ :class | class theNonMetaClass name ] ]
  186. ifNotNil: [ :method | method selector ]
  187. ! !
  188. !HLFindReferencesCommand methodsFor: 'executing'!
  189. execute
  190. HLReferences new
  191. openAsTab;
  192. search: self input
  193. ! !
  194. !HLFindReferencesCommand methodsFor: 'testing'!
  195. isInputRequired
  196. ^ true
  197. ! !
  198. !HLFindReferencesCommand class methodsFor: 'accessing'!
  199. key
  200. ^ 'r'
  201. !
  202. label
  203. ^ 'Find references'
  204. ! !
  205. HLToolCommand subclass: #HLMoveToCommand
  206. instanceVariableNames: ''
  207. package: 'Helios-Commands-Tools'!
  208. !HLMoveToCommand class methodsFor: 'accessing'!
  209. key
  210. ^ 'm'
  211. !
  212. label
  213. ^ 'Move'
  214. ! !
  215. HLMoveToCommand subclass: #HLMoveClassToCommand
  216. instanceVariableNames: ''
  217. package: 'Helios-Commands-Tools'!
  218. !HLMoveClassToCommand methodsFor: 'testing'!
  219. isActive
  220. ^ self model selectedClass notNil
  221. ! !
  222. !HLMoveClassToCommand class methodsFor: 'accessing'!
  223. key
  224. ^ 'c'
  225. !
  226. label
  227. ^ 'Move class'
  228. ! !
  229. HLMoveClassToCommand subclass: #HLMoveClassToPackageCommand
  230. instanceVariableNames: ''
  231. package: 'Helios-Commands-Tools'!
  232. !HLMoveClassToPackageCommand methodsFor: 'accessing'!
  233. category
  234. ^ 'Classes'
  235. !
  236. displayLabel
  237. ^ 'select a package'
  238. !
  239. inputCompletion
  240. ^ self model availablePackageNames
  241. !
  242. inputLabel
  243. ^ 'Move class to package:'
  244. ! !
  245. !HLMoveClassToPackageCommand methodsFor: 'executing'!
  246. execute
  247. self model moveClassToPackage: self input
  248. ! !
  249. !HLMoveClassToPackageCommand methodsFor: 'testing'!
  250. isInputRequired
  251. ^ true
  252. ! !
  253. !HLMoveClassToPackageCommand class methodsFor: 'accessing'!
  254. key
  255. ^ 'p'
  256. !
  257. label
  258. ^ 'Move class to package'
  259. !
  260. menuLabel
  261. ^ 'Move to package...'
  262. ! !
  263. HLMoveToCommand subclass: #HLMoveMethodToCommand
  264. instanceVariableNames: ''
  265. package: 'Helios-Commands-Tools'!
  266. !HLMoveMethodToCommand methodsFor: 'accessing'!
  267. category
  268. ^ 'Methods'
  269. ! !
  270. !HLMoveMethodToCommand methodsFor: 'testing'!
  271. isActive
  272. ^ self model selectedMethod notNil
  273. ! !
  274. !HLMoveMethodToCommand class methodsFor: 'accessing'!
  275. key
  276. ^ 'm'
  277. !
  278. label
  279. ^ 'Move method'
  280. ! !
  281. HLMoveMethodToCommand subclass: #HLMoveMethodToClassCommand
  282. instanceVariableNames: ''
  283. package: 'Helios-Commands-Tools'!
  284. !HLMoveMethodToClassCommand methodsFor: 'accessing'!
  285. displayLabel
  286. ^ 'select a class'
  287. !
  288. inputCompletion
  289. ^ self model availableClassNames
  290. !
  291. inputLabel
  292. ^ 'Move method to class:'
  293. ! !
  294. !HLMoveMethodToClassCommand methodsFor: 'executing'!
  295. execute
  296. self model moveMethodToClass: self input
  297. ! !
  298. !HLMoveMethodToClassCommand methodsFor: 'testing'!
  299. isInputRequired
  300. ^ true
  301. ! !
  302. !HLMoveMethodToClassCommand class methodsFor: 'accessing'!
  303. key
  304. ^ 'c'
  305. !
  306. label
  307. ^ 'Move method to class'
  308. !
  309. menuLabel
  310. ^ 'Move to class...'
  311. ! !
  312. HLMoveMethodToCommand subclass: #HLMoveMethodToProtocolCommand
  313. instanceVariableNames: ''
  314. package: 'Helios-Commands-Tools'!
  315. !HLMoveMethodToProtocolCommand methodsFor: 'accessing'!
  316. displayLabel
  317. ^ 'select a protocol'
  318. !
  319. inputCompletion
  320. ^ self model availableProtocols
  321. !
  322. inputLabel
  323. ^ 'Move method to a protocol:'
  324. ! !
  325. !HLMoveMethodToProtocolCommand methodsFor: 'executing'!
  326. execute
  327. self model moveMethodToProtocol: self input
  328. ! !
  329. !HLMoveMethodToProtocolCommand methodsFor: 'testing'!
  330. isInputRequired
  331. ^ true
  332. ! !
  333. !HLMoveMethodToProtocolCommand class methodsFor: 'accessing'!
  334. key
  335. ^ 't'
  336. !
  337. label
  338. ^ 'Move method to protocol'
  339. !
  340. menuLabel
  341. ^ 'Move to protocol...'
  342. ! !
  343. HLToolCommand subclass: #HLRemoveCommand
  344. instanceVariableNames: ''
  345. package: 'Helios-Commands-Tools'!
  346. !HLRemoveCommand class methodsFor: 'accessing'!
  347. key
  348. ^ 'x'
  349. !
  350. label
  351. ^ 'Remove'
  352. ! !
  353. HLRemoveCommand subclass: #HLRemoveClassCommand
  354. instanceVariableNames: ''
  355. package: 'Helios-Commands-Tools'!
  356. !HLRemoveClassCommand methodsFor: 'accessing'!
  357. category
  358. ^ 'Classes'
  359. ! !
  360. !HLRemoveClassCommand methodsFor: 'executing'!
  361. execute
  362. self model removeClass
  363. ! !
  364. !HLRemoveClassCommand methodsFor: 'testing'!
  365. isActive
  366. ^ self model selectedClass notNil
  367. ! !
  368. !HLRemoveClassCommand class methodsFor: 'accessing'!
  369. key
  370. ^ 'c'
  371. !
  372. label
  373. ^ 'Remove class'
  374. !
  375. menuLabel
  376. ^ 'Remove class'
  377. ! !
  378. HLRemoveCommand subclass: #HLRemoveMethodCommand
  379. instanceVariableNames: ''
  380. package: 'Helios-Commands-Tools'!
  381. !HLRemoveMethodCommand methodsFor: 'accessing'!
  382. category
  383. ^ 'Methods'
  384. ! !
  385. !HLRemoveMethodCommand methodsFor: 'executing'!
  386. execute
  387. self model removeMethod
  388. ! !
  389. !HLRemoveMethodCommand methodsFor: 'testing'!
  390. isActive
  391. ^ self model selectedMethod notNil
  392. ! !
  393. !HLRemoveMethodCommand class methodsFor: 'accessing'!
  394. key
  395. ^ 'm'
  396. !
  397. label
  398. ^ 'Remove method'
  399. !
  400. menuLabel
  401. ^ 'Remove method'
  402. ! !
  403. HLRemoveCommand subclass: #HLRemoveProtocolCommand
  404. instanceVariableNames: ''
  405. package: 'Helios-Commands-Tools'!
  406. !HLRemoveProtocolCommand methodsFor: 'accessing'!
  407. category
  408. ^ 'Protocols'
  409. ! !
  410. !HLRemoveProtocolCommand methodsFor: 'executing'!
  411. execute
  412. self model removeProtocol
  413. ! !
  414. !HLRemoveProtocolCommand methodsFor: 'testing'!
  415. isActive
  416. ^ self model selectedProtocol notNil
  417. ! !
  418. !HLRemoveProtocolCommand class methodsFor: 'accessing'!
  419. key
  420. ^ 't'
  421. !
  422. label
  423. ^ 'Remove protocol'
  424. !
  425. menuLabel
  426. ^ 'Remove protocol'
  427. ! !
  428. HLToolCommand subclass: #HLRenameCommand
  429. instanceVariableNames: ''
  430. package: 'Helios-Commands-Tools'!
  431. !HLRenameCommand class methodsFor: 'accessing'!
  432. key
  433. ^ 'r'
  434. !
  435. label
  436. ^ 'Rename'
  437. ! !
  438. HLRenameCommand subclass: #HLRenameClassCommand
  439. instanceVariableNames: ''
  440. package: 'Helios-Commands-Tools'!
  441. !HLRenameClassCommand methodsFor: 'accessing'!
  442. category
  443. ^ 'Classes'
  444. !
  445. displayLabel
  446. ^ 'Rename class to:'
  447. ! !
  448. !HLRenameClassCommand methodsFor: 'defaults'!
  449. defaultInput
  450. ^ self model selectedClass theNonMetaClass name
  451. ! !
  452. !HLRenameClassCommand methodsFor: 'executing'!
  453. execute
  454. self model renameClassTo: self input
  455. ! !
  456. !HLRenameClassCommand methodsFor: 'testing'!
  457. isActive
  458. ^ self model selectedClass notNil
  459. !
  460. isInputRequired
  461. ^ true
  462. ! !
  463. !HLRenameClassCommand class methodsFor: 'accessing'!
  464. key
  465. ^ 'c'
  466. !
  467. label
  468. ^ 'Rename class'
  469. !
  470. menuLabel
  471. ^ 'Rename class...'
  472. ! !
  473. HLRenameCommand subclass: #HLRenameProtocolCommand
  474. instanceVariableNames: ''
  475. package: 'Helios-Commands-Tools'!
  476. !HLRenameProtocolCommand methodsFor: 'accessing'!
  477. category
  478. ^ 'Protocols'
  479. !
  480. displayLabel
  481. ^ 'Rename protocol to:'
  482. ! !
  483. !HLRenameProtocolCommand methodsFor: 'defaults'!
  484. defaultInput
  485. ^ self model selectedProtocol
  486. ! !
  487. !HLRenameProtocolCommand methodsFor: 'executing'!
  488. execute
  489. self model renameProtocolTo: self input
  490. ! !
  491. !HLRenameProtocolCommand methodsFor: 'testing'!
  492. isActive
  493. ^ self model selectedProtocol notNil
  494. !
  495. isInputRequired
  496. ^ true
  497. ! !
  498. !HLRenameProtocolCommand class methodsFor: 'accessing'!
  499. key
  500. ^ 't'
  501. !
  502. label
  503. ^ 'Rename protocol'
  504. !
  505. menuLabel
  506. ^ 'Rename protocol...'
  507. ! !