Added support to update browser's selection after code is generated.
This is quite often what users would expect. Individual generatoes and
refatorings must override #updateInContext:
--- a/refactoring_custom/SmallSense__CustomBrowserContext.st Sat Aug 22 00:14:23 2015 +0100
+++ b/refactoring_custom/SmallSense__CustomBrowserContext.st Sat Aug 29 22:39:44 2015 +0100
@@ -71,6 +71,33 @@
!CustomBrowserContext methodsFor:'accessing-selection'!
+selectClassNamed:className
+ self browser switchToClassNamed: className
+
+ "Created: / 29-08-2015 / 13:25:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+selectClassNamed:className selector:selector
+ | browser class |
+
+ browser := self browser.
+ class := browser findClassNamed: className.
+ class notNil ifTrue:[
+ browser switchToClass: class selector: selector
+ ].
+
+ "Modified: / 29-08-2015 / 13:28:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+selectClassesNamed:classNames
+ classNames size == 1 ifTrue:[
+ self selectClassNamed: classNames
+ ].
+ self notYetImplemented
+
+ "Modified: / 29-08-2015 / 13:25:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
selectedClassCategories
^ state selectedCategories value
@@ -158,6 +185,16 @@
"Modified: / 17-05-2014 / 13:29:57 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
! !
+!CustomBrowserContext methodsFor:'private'!
+
+browser
+ "raise an error: this method should be implemented (TODO)"
+
+ ^ state canvas application
+
+ "Created: / 29-08-2015 / 13:25:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!CustomBrowserContext methodsFor:'testing'!
isInteractiveContext
--- a/refactoring_custom/SmallSense__CustomCodeGeneratorOrRefactoring.st Sat Aug 22 00:14:23 2015 +0100
+++ b/refactoring_custom/SmallSense__CustomCodeGeneratorOrRefactoring.st Sat Aug 29 22:39:44 2015 +0100
@@ -493,9 +493,11 @@
self executeCollectedChangesNamed: self class description.
+ self updateInContext: context.
+
"Created: / 19-03-2014 / 18:45:26 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
- "Modified: / 16-09-2014 / 11:04:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 25-11-2014 / 21:07:32 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+ "Modified: / 29-08-2015 / 13:29:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
executeInContextWithWaitCursor: aCustomContext
@@ -556,6 +558,12 @@
"Modified (comment): / 16-09-2014 / 11:00:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+updateInContext: aContext
+ "Update the context so it points to generated class/methods. To be overriden by subclasses."
+
+ "Created: / 29-08-2015 / 13:29:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
validateInContext: aCustomContext
"/ To be overridden by subclasses
--- a/refactoring_custom/SmallSense__CustomContext.st Sat Aug 22 00:14:23 2015 +0100
+++ b/refactoring_custom/SmallSense__CustomContext.st Sat Aug 29 22:39:44 2015 +0100
@@ -108,6 +108,24 @@
!CustomContext methodsFor:'accessing-selection'!
+selectClassNamed: className
+ self selectClassesNamed: { className }
+
+ "Created: / 29-08-2015 / 13:21:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+selectClassNamed: className selector: selector
+ self subclassResponsibility
+
+ "Created: / 29-08-2015 / 13:21:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+selectClassesNamed: classNames
+ self subclassResponsibility
+
+ "Created: / 29-08-2015 / 13:20:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
selectedClassCategories
"a collection with selected class categories"
--- a/refactoring_custom/SmallSense__CustomSubContext.st Sat Aug 22 00:14:23 2015 +0100
+++ b/refactoring_custom/SmallSense__CustomSubContext.st Sat Aug 29 22:39:44 2015 +0100
@@ -116,6 +116,16 @@
!CustomSubContext methodsFor:'accessing-selection'!
+selectClassNamed:className selector:selector
+
+ "Modified: / 29-08-2015 / 13:22:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+selectClassesNamed:classNames
+
+ "Modified: / 29-08-2015 / 13:22:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
selectedClassCategories
^ selectedClassCategories
--- a/refactoring_custom/SmallSense__CustomTestCaseCodeGenerator.st Sat Aug 22 00:14:23 2015 +0100
+++ b/refactoring_custom/SmallSense__CustomTestCaseCodeGenerator.st Sat Aug 29 22:39:44 2015 +0100
@@ -332,6 +332,12 @@
"Created: / 16-09-2014 / 11:15:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 01-10-2014 / 23:52:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 31-01-2015 / 22:14:22 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+updateInContext:aCustomContext
+ aCustomContext selectClassNamed: testClassName
+
+ "Created: / 29-08-2015 / 13:37:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CustomTestCaseCodeGenerator class methodsFor:'documentation'!
--- a/refactoring_custom/extensions.st Sat Aug 22 00:14:23 2015 +0100
+++ b/refactoring_custom/extensions.st Sat Aug 29 22:39:44 2015 +0100
@@ -897,7 +897,7 @@
] ifFalse: [
| info |
- info := resources stringWithCRs: 'No testcase named %1 or %2 found' with: (className, 'Tests') with: (className, 'Test.\\ Generate one?').
+ info := resources stringWithCRs: 'No testcase named %1 or %2 found. Generate?' with: (className, 'Tests') with: (className, 'Test.').
(Dialog confirm: info) ifTrue:[
| context |
@@ -920,7 +920,7 @@
"Created: / 26-12-2014 / 16:54:30 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
"Modified: / 27-12-2014 / 19:01:25 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
- "Modified: / 21-08-2015 / 14:27:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 29-08-2015 / 22:35:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!Tools::NewSystemBrowser methodsFor:'menus extensions-custom refactorings'!