Helios-Commands-Tools.st 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. Smalltalk createPackage: 'Helios-Commands-Tools'!
  2. HLModelCommand subclass: #HLToolCommand
  3. slots: {}
  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. slots: {}
  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. slots: {}
  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. slots: {}
  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. slots: {}
  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. slots: {}
  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. slots: {}
  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. HLFindCommand subclass: #HLFindClassReferencesCommand
  163. slots: {}
  164. package: 'Helios-Commands-Tools'!
  165. !HLFindClassReferencesCommand methodsFor: 'as yet unclassified'!
  166. category
  167. ^ 'Classes'
  168. !
  169. execute
  170. HLReferences new
  171. openAsTab;
  172. search: self model selectedClass theNonMetaClass name
  173. !
  174. isActive
  175. ^ self model selectedClass notNil
  176. !
  177. isInputRequired
  178. ^ false
  179. ! !
  180. !HLFindClassReferencesCommand class methodsFor: 'as yet unclassified'!
  181. menuLabel
  182. ^ 'Find class references...'
  183. ! !
  184. HLFindCommand subclass: #HLFindReferencesCommand
  185. slots: {}
  186. package: 'Helios-Commands-Tools'!
  187. !HLFindReferencesCommand methodsFor: 'accessing'!
  188. displayLabel
  189. ^ 'find references'
  190. !
  191. inputCompletion
  192. ^ self model availableClassNames, self model allSelectors
  193. !
  194. inputLabel
  195. ^ 'Find references of'
  196. ! !
  197. !HLFindReferencesCommand methodsFor: 'defaults'!
  198. defaultInput
  199. ^ self model selectedMethod
  200. ifNil: [
  201. self model selectedClass
  202. ifNil: [ '' ]
  203. ifNotNil: [ :class | class theNonMetaClass name ] ]
  204. ifNotNil: [ :method | method selector ]
  205. ! !
  206. !HLFindReferencesCommand methodsFor: 'executing'!
  207. execute
  208. HLReferences new
  209. openAsTab;
  210. search: self input
  211. ! !
  212. !HLFindReferencesCommand methodsFor: 'testing'!
  213. isInputRequired
  214. ^ true
  215. ! !
  216. !HLFindReferencesCommand class methodsFor: 'accessing'!
  217. key
  218. ^ 'r'
  219. !
  220. label
  221. ^ 'Find references'
  222. ! !
  223. HLToolCommand subclass: #HLMoveToCommand
  224. slots: {}
  225. package: 'Helios-Commands-Tools'!
  226. !HLMoveToCommand class methodsFor: 'accessing'!
  227. key
  228. ^ 'm'
  229. !
  230. label
  231. ^ 'Move'
  232. ! !
  233. HLMoveToCommand subclass: #HLMoveClassToCommand
  234. slots: {}
  235. package: 'Helios-Commands-Tools'!
  236. !HLMoveClassToCommand methodsFor: 'testing'!
  237. isActive
  238. ^ self model selectedClass notNil
  239. ! !
  240. !HLMoveClassToCommand class methodsFor: 'accessing'!
  241. key
  242. ^ 'c'
  243. !
  244. label
  245. ^ 'Move class'
  246. ! !
  247. HLMoveClassToCommand subclass: #HLMoveClassToPackageCommand
  248. slots: {}
  249. package: 'Helios-Commands-Tools'!
  250. !HLMoveClassToPackageCommand methodsFor: 'accessing'!
  251. category
  252. ^ 'Classes'
  253. !
  254. displayLabel
  255. ^ 'select a package'
  256. !
  257. inputCompletion
  258. ^ self model availablePackageNames
  259. !
  260. inputLabel
  261. ^ 'Move class to package:'
  262. ! !
  263. !HLMoveClassToPackageCommand methodsFor: 'executing'!
  264. execute
  265. self model moveClassToPackage: self input
  266. ! !
  267. !HLMoveClassToPackageCommand methodsFor: 'testing'!
  268. isInputRequired
  269. ^ true
  270. ! !
  271. !HLMoveClassToPackageCommand class methodsFor: 'accessing'!
  272. key
  273. ^ 'p'
  274. !
  275. label
  276. ^ 'Move class to package'
  277. !
  278. menuLabel
  279. ^ 'Move to package...'
  280. ! !
  281. HLMoveToCommand subclass: #HLMoveMethodToCommand
  282. slots: {}
  283. package: 'Helios-Commands-Tools'!
  284. !HLMoveMethodToCommand methodsFor: 'accessing'!
  285. category
  286. ^ 'Methods'
  287. ! !
  288. !HLMoveMethodToCommand methodsFor: 'testing'!
  289. isActive
  290. ^ self model selectedMethod notNil
  291. ! !
  292. !HLMoveMethodToCommand class methodsFor: 'accessing'!
  293. key
  294. ^ 'm'
  295. !
  296. label
  297. ^ 'Move method'
  298. ! !
  299. HLMoveMethodToCommand subclass: #HLMoveMethodToClassCommand
  300. slots: {}
  301. package: 'Helios-Commands-Tools'!
  302. !HLMoveMethodToClassCommand methodsFor: 'accessing'!
  303. displayLabel
  304. ^ 'select a class'
  305. !
  306. inputCompletion
  307. ^ self model availableClassNames
  308. !
  309. inputLabel
  310. ^ 'Move method to class:'
  311. ! !
  312. !HLMoveMethodToClassCommand methodsFor: 'executing'!
  313. execute
  314. self model moveMethodToClass: self input
  315. ! !
  316. !HLMoveMethodToClassCommand methodsFor: 'testing'!
  317. isInputRequired
  318. ^ true
  319. ! !
  320. !HLMoveMethodToClassCommand class methodsFor: 'accessing'!
  321. key
  322. ^ 'c'
  323. !
  324. label
  325. ^ 'Move method to class'
  326. !
  327. menuLabel
  328. ^ 'Move to class...'
  329. ! !
  330. HLMoveMethodToCommand subclass: #HLMoveMethodToProtocolCommand
  331. slots: {}
  332. package: 'Helios-Commands-Tools'!
  333. !HLMoveMethodToProtocolCommand methodsFor: 'accessing'!
  334. displayLabel
  335. ^ 'select a protocol'
  336. !
  337. inputCompletion
  338. ^ self model availableProtocols
  339. !
  340. inputLabel
  341. ^ 'Move method to a protocol:'
  342. ! !
  343. !HLMoveMethodToProtocolCommand methodsFor: 'executing'!
  344. execute
  345. self model moveMethodToProtocol: self input
  346. ! !
  347. !HLMoveMethodToProtocolCommand methodsFor: 'testing'!
  348. isInputRequired
  349. ^ true
  350. ! !
  351. !HLMoveMethodToProtocolCommand class methodsFor: 'accessing'!
  352. key
  353. ^ 't'
  354. !
  355. label
  356. ^ 'Move method to protocol'
  357. !
  358. menuLabel
  359. ^ 'Move to protocol...'
  360. ! !
  361. HLToolCommand subclass: #HLRemoveCommand
  362. slots: {}
  363. package: 'Helios-Commands-Tools'!
  364. !HLRemoveCommand class methodsFor: 'accessing'!
  365. key
  366. ^ 'x'
  367. !
  368. label
  369. ^ 'Remove'
  370. ! !
  371. HLRemoveCommand subclass: #HLRemoveClassCommand
  372. slots: {}
  373. package: 'Helios-Commands-Tools'!
  374. !HLRemoveClassCommand methodsFor: 'accessing'!
  375. category
  376. ^ 'Classes'
  377. ! !
  378. !HLRemoveClassCommand methodsFor: 'executing'!
  379. execute
  380. self model removeClass
  381. ! !
  382. !HLRemoveClassCommand methodsFor: 'testing'!
  383. isActive
  384. ^ self model selectedClass notNil
  385. ! !
  386. !HLRemoveClassCommand class methodsFor: 'accessing'!
  387. key
  388. ^ 'c'
  389. !
  390. label
  391. ^ 'Remove class'
  392. !
  393. menuLabel
  394. ^ 'Remove class'
  395. ! !
  396. HLRemoveCommand subclass: #HLRemoveMethodCommand
  397. slots: {}
  398. package: 'Helios-Commands-Tools'!
  399. !HLRemoveMethodCommand methodsFor: 'accessing'!
  400. category
  401. ^ 'Methods'
  402. ! !
  403. !HLRemoveMethodCommand methodsFor: 'executing'!
  404. execute
  405. self model removeMethod
  406. ! !
  407. !HLRemoveMethodCommand methodsFor: 'testing'!
  408. isActive
  409. ^ self model selectedMethod notNil
  410. ! !
  411. !HLRemoveMethodCommand class methodsFor: 'accessing'!
  412. key
  413. ^ 'm'
  414. !
  415. label
  416. ^ 'Remove method'
  417. !
  418. menuLabel
  419. ^ 'Remove method'
  420. ! !
  421. HLRemoveCommand subclass: #HLRemoveProtocolCommand
  422. slots: {}
  423. package: 'Helios-Commands-Tools'!
  424. !HLRemoveProtocolCommand methodsFor: 'accessing'!
  425. category
  426. ^ 'Protocols'
  427. ! !
  428. !HLRemoveProtocolCommand methodsFor: 'executing'!
  429. execute
  430. self model removeProtocol
  431. ! !
  432. !HLRemoveProtocolCommand methodsFor: 'testing'!
  433. isActive
  434. ^ self model selectedProtocol notNil
  435. ! !
  436. !HLRemoveProtocolCommand class methodsFor: 'accessing'!
  437. key
  438. ^ 't'
  439. !
  440. label
  441. ^ 'Remove protocol'
  442. !
  443. menuLabel
  444. ^ 'Remove protocol'
  445. ! !
  446. HLToolCommand subclass: #HLRenameCommand
  447. slots: {}
  448. package: 'Helios-Commands-Tools'!
  449. !HLRenameCommand class methodsFor: 'accessing'!
  450. key
  451. ^ 'r'
  452. !
  453. label
  454. ^ 'Rename'
  455. ! !
  456. HLRenameCommand subclass: #HLRenameClassCommand
  457. slots: {}
  458. package: 'Helios-Commands-Tools'!
  459. !HLRenameClassCommand methodsFor: 'accessing'!
  460. category
  461. ^ 'Classes'
  462. !
  463. displayLabel
  464. ^ 'Rename class to:'
  465. ! !
  466. !HLRenameClassCommand methodsFor: 'defaults'!
  467. defaultInput
  468. ^ self model selectedClass theNonMetaClass name
  469. ! !
  470. !HLRenameClassCommand methodsFor: 'executing'!
  471. execute
  472. self model renameClassTo: self input
  473. ! !
  474. !HLRenameClassCommand methodsFor: 'testing'!
  475. isActive
  476. ^ self model selectedClass notNil
  477. !
  478. isInputRequired
  479. ^ true
  480. ! !
  481. !HLRenameClassCommand class methodsFor: 'accessing'!
  482. key
  483. ^ 'c'
  484. !
  485. label
  486. ^ 'Rename class'
  487. !
  488. menuLabel
  489. ^ 'Rename class...'
  490. ! !
  491. HLRenameCommand subclass: #HLRenamePackageCommand
  492. slots: {}
  493. package: 'Helios-Commands-Tools'!
  494. !HLRenamePackageCommand methodsFor: 'accessing'!
  495. category
  496. ^ 'Packages'
  497. !
  498. displayLabel
  499. ^ 'Rename package to:'
  500. ! !
  501. !HLRenamePackageCommand methodsFor: 'defaults'!
  502. defaultInput
  503. ^ self model selectedPackage name
  504. ! !
  505. !HLRenamePackageCommand methodsFor: 'executing'!
  506. execute
  507. self model renamePackageTo: self input
  508. ! !
  509. !HLRenamePackageCommand methodsFor: 'testing'!
  510. isActive
  511. ^ self model selectedPackage notNil
  512. !
  513. isInputRequired
  514. ^ true
  515. ! !
  516. !HLRenamePackageCommand class methodsFor: 'accessing'!
  517. key
  518. ^ 'p'
  519. !
  520. label
  521. ^ 'Rename package'
  522. !
  523. menuLabel
  524. ^ 'Rename package...'
  525. ! !
  526. HLRenameCommand subclass: #HLRenameProtocolCommand
  527. slots: {}
  528. package: 'Helios-Commands-Tools'!
  529. !HLRenameProtocolCommand methodsFor: 'accessing'!
  530. category
  531. ^ 'Protocols'
  532. !
  533. displayLabel
  534. ^ 'Rename protocol to:'
  535. ! !
  536. !HLRenameProtocolCommand methodsFor: 'defaults'!
  537. defaultInput
  538. ^ self model selectedProtocol
  539. ! !
  540. !HLRenameProtocolCommand methodsFor: 'executing'!
  541. execute
  542. self model renameProtocolTo: self input
  543. ! !
  544. !HLRenameProtocolCommand methodsFor: 'testing'!
  545. isActive
  546. ^ self model selectedProtocol notNil
  547. !
  548. isInputRequired
  549. ^ true
  550. ! !
  551. !HLRenameProtocolCommand class methodsFor: 'accessing'!
  552. key
  553. ^ 't'
  554. !
  555. label
  556. ^ 'Rename protocol'
  557. !
  558. menuLabel
  559. ^ 'Rename protocol...'
  560. ! !