Helios-Commands-Tools.st 11 KB

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