added a hook to turn off confirmations
authorClaus Gittinger <cg@exept.de>
Thu, 04 Aug 2011 21:39:05 +0200
changeset 10466 4b42e5a1f395
parent 10465 7bb5a6157330
child 10467 d6bd6c9c5a1b
added a hook to turn off confirmations
CodeGeneratorTool.st
--- a/CodeGeneratorTool.st	Thu Aug 04 21:33:30 2011 +0200
+++ b/CodeGeneratorTool.st	Thu Aug 04 21:39:05 2011 +0200
@@ -13,7 +13,7 @@
 
 Object subclass:#CodeGeneratorTool
 	instanceVariableNames:'compositeChangeCollector compositeChangeNesting userPreferences
-		generateComments'
+		generateComments confirmChanges'
 	classVariableNames:'GenerateCommentsForGetters GenerateCommentsForSetters
 		CopyrightTemplate'
 	poolDictionaries:''
@@ -828,13 +828,17 @@
     ^ requiredSelectors
 ! !
 
-!CodeGeneratorTool methodsFor:'buld changes'!
+!CodeGeneratorTool methodsFor:'bulk changes'!
 
 addChange:aChange
     compositeChangeCollector addChange:aChange
 !
 
 executeCollectedChangesNamed:name
+    "if both the compositeChangeCollector and I myself think, that it should be confirmed,
+     the let user do it - I am not sure, if the heuristics here is useful;
+     it might be better to let the generator decide (for example, if it does high-impact
+     changes, as opposed to simple ones)"
 
     | changes |
 
@@ -845,13 +849,12 @@
             compositeChangeCollector changesSize == 0 ifTrue:[
                 self information:'Nothing generated.'.
             ] ifFalse:[
-                compositeChangeCollector shouldBeConfimed                 
+                (compositeChangeCollector shouldBeConfimed and:[self confirmChanges])
                     ifFalse: [
                         RefactoryChangeManager instance performChange: compositeChangeCollector
                     ] ifTrue: [                        
-                        changes := Tools::ChangeSetBrowser2 confirmChanges:
-                                (ChangeSet with:compositeChangeCollector).
-                        changes do:[:chg|RefactoryChangeManager instance performChange: chg].
+                        changes := Tools::ChangeSetBrowser2 confirmChanges:(ChangeSet with:compositeChangeCollector).
+                        changes do:[:chg | RefactoryChangeManager instance performChange: chg].
                     ].
             ].
             compositeChangeCollector := nil.
@@ -859,6 +862,7 @@
     ]
 
     "Modified: / 08-07-2011 / 11:03:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 04-08-2011 / 17:30:27 / cg"
 !
 
 startCollectChanges
@@ -1522,6 +1526,22 @@
 
 !CodeGeneratorTool methodsFor:'initialization'!
 
+confirmChanges
+    "if true, let user confirm complicated changes; if false, just do it"
+
+    ^ confirmChanges ? true
+
+    "Created: / 04-08-2011 / 17:31:45 / cg"
+!
+
+confirmChanges:aBoolean
+    "if true, let user confirm complicated changes; if false, just do it"
+
+    confirmChanges := aBoolean
+
+    "Created: / 04-08-2011 / 17:26:47 / cg"
+!
+
 initialize
     userPreferences := UserPreferences current.
     generateComments := userPreferences generateComments.
@@ -1560,5 +1580,5 @@
 !CodeGeneratorTool class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.91 2011-07-14 14:44:50 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.92 2011-08-04 19:39:05 cg Exp $'
 ! !