SourceCodeManagerUtilities.st
changeset 1030 7a798aa0735e
parent 1026 1f193eb5f877
child 1032 24faa0f05f25
--- a/SourceCodeManagerUtilities.st	Fri Dec 08 01:33:25 2000 +0100
+++ b/SourceCodeManagerUtilities.st	Fri Dec 08 14:05:36 2000 +0100
@@ -77,11 +77,22 @@
      return a dictionary containing module, package and filename,
      or nil if canceled."
 
+    ^ self
+        askForContainer:boxText title:title note:notice 
+        initialModule:initialModule initialPackage:initialPackage initialFileName:initialFileName 
+        forNewContainer:true
+!
+
+askForContainer:boxText title:title note:notice initialModule:initialModule initialPackage:initialPackage initialFileName:initialFileName forNewContainer:forNewContainer
+    "open a dialog asking for a source container;
+     return a dictionary containing module, package and filename,
+     or nil if canceled."
+
     |box y component resources 
      moduleHolder packageHolder fileNameHolder
      module package fileName 
      knownContainers knownPackages packageUpdater
-     packageBoxComponent|
+     packageBoxComponent fileNameBoxComponent fileNameUpdater|
 
     knownContainers := Set new.
     Smalltalk allClassesDo:[:cls | |pckg|
@@ -99,20 +110,37 @@
 
         theModulePrefix := moduleHolder value , ':'.
 
-        knownPackages := Set new.
-        Smalltalk allClassesDo:[:cls | |pckg idx|
-            pckg := cls package.
-            pckg size > 0 ifTrue:[
-                (pckg startsWith:theModulePrefix) ifTrue:[
-                    idx := pckg indexOf:$:.
-                    knownPackages add:(pckg copyFrom:idx + 1)
+        Cursor wait showWhile:[
+            knownPackages := Set new.
+            Smalltalk allClassesDo:[:cls | |pckg idx|
+                pckg := cls package.
+                pckg size > 0 ifTrue:[
+                    (pckg startsWith:theModulePrefix) ifTrue:[
+                        idx := pckg indexOf:$:.
+                        knownPackages add:(pckg copyFrom:idx + 1)
+                    ]
                 ]
-            ]
+            ].
+            knownPackages := knownPackages asOrderedCollection.
+            knownPackages := knownPackages select:[:package | package isBlank not].
+            knownPackages sort.
+            packageBoxComponent list:knownPackages.
         ].
-        knownPackages := knownPackages asOrderedCollection.
-        knownPackages := knownPackages select:[:package | package isBlank not].
-        knownPackages sort.
-        packageBoxComponent list:knownPackages.
+    ].
+
+    fileNameUpdater := [
+        |module package files|
+
+        Cursor read showWhile:[
+            module := moduleHolder value ? '__NoProject__'.
+            package := packageHolder value ? '__NoProject__'.
+
+            files := SourceCodeManager getExistingContainersInModule:module package:package.
+            files := files asOrderedCollection.
+            files := files select:[:eachFile | eachFile asFilename hasSuffix:'st'].
+            files sort.
+            fileNameBoxComponent list:files.
+        ].
     ].
 
     moduleHolder := initialModule asValue.
@@ -158,8 +186,16 @@
     component := box addTextLabel:(resources string:'Filename:').
     component width:0.4; adjust:#right.
     box yPosition:y.
-    component := box addInputFieldOn:fileNameHolder tabable:true.
-    component width:0.6; left:0.4; immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
+
+    forNewContainer ifTrue:[
+        component := box addInputFieldOn:fileNameHolder tabable:true.
+        component width:0.6; left:0.4; immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
+    ] ifFalse:[
+        fileNameBoxComponent := component := box addComboBoxOn:fileNameHolder tabable:true.
+        component width:0.6; left:0.4; immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
+        fileNameUpdater value.
+        packageHolder onChangeEvaluate:fileNameUpdater.
+    ].
 
     box addVerticalSpace.
 
@@ -451,7 +487,8 @@
             "/ mhmh - check if it has a container.
             (mgr checkForExistingContainerForClass:aClass) ifFalse:[
                 (self createSourceContainerForClass:aClass) ifFalse:[
-                    self warn:'did not create a container for ''' , aClass name , ''''.
+                    self warn:'Did not create/change repository container for ''' , aClass name allBold , ''''.
+                    ^ false.
                 ] ifTrue:[
                     freshCreated := true.
                 ].
@@ -730,8 +767,8 @@
      currentClass 
      aStream sourceToLoad currentSource v rev revString thisRevString
      nm msg rev2 newestRev
-     containerModule containerPackage rslt
-       pkg listHere listRep diffSet 
+     containerModule containerPackage containerFile rslt
+     pkg listHere listRep diffSet 
      changed onlyHere onlyInRep answer labels values
      changedClasses default|
 
@@ -763,10 +800,27 @@
             containerPackage size == 0 ifTrue:[
                 containerPackage := Project current package.
             ].
-            (self confirm:(resources string:'The class seems to have no (valid) repository information.\\I assume you want to check it out from: %1/%2.' 
-                                       with:containerModule allBold 
-                                       with:containerPackage allBold) withCRs)
-            ifFalse:[^ self].
+            answer := self confirmWithCancel:(resources 
+                                                string:'The class seems to have no (valid) repository information.\\I assume you want to check it out from: %1/%2.' 
+                                                with:containerModule allBold 
+                                                with:containerPackage allBold) withCRs.
+            answer isNil ifTrue:[^ self "cancelled"].
+            answer ifFalse:[
+                rslt := SourceCodeManagerUtilities
+                    askForContainer:(resources string:'The class seems to have no repository information.\\Do you want to checkOut from an existing containers contents ?')
+                    title:'Container to load from' note:nil 
+                    initialModule:containerModule 
+                    initialPackage:containerPackage 
+                    initialFileName:(currentClass name , '.st')
+                    forNewContainer:false.
+                rslt isNil ifTrue:[
+                    "/ canel
+                    ^ self
+                ].
+                containerModule := "lastModule :=" rslt at:#module.
+                containerPackage := "lastPackage :=" rslt at:#package.
+                containerFile := rslt at:#fileName.
+            ].
 
 "/            rslt := SourceCodeManagerUtilities
 "/                askForContainer:(resources string:'The class seems to have no (valid) repository information.\\Do you want to check it out from an existing container ?')
@@ -774,6 +828,7 @@
 "/                initialModule:containerModule 
 "/                initialPackage:containerPackage
 "/                initialFileName:(currentClass name , '.st').
+"/                forNewContainer:false.
 "/            rslt isNil ifTrue:[^ self].
             "/ self warn:(resources string:'Class %1 seems to be not yet in the repository' with:currentClass name allBold).
             "/ ^ self
@@ -1120,7 +1175,7 @@
     ^ self 
         defineSourceContainerForClass:aClass 
         title:(resources string:'Repository information for %1' with:aClass name)
-        text:(resources string:'CREATE_REPOSITORY' with:aClass name)
+        text:(resources string:'Create new repository container for ''%1''' with:aClass name allBold)
         createDirectories:true
         createContainer:true.
 
@@ -1267,7 +1322,8 @@
 
         rslt := self 
                 askForContainer:boxText title:title note:note
-                initialModule:module initialPackage:package initialFileName:fileName.        
+                initialModule:module initialPackage:package initialFileName:fileName
+                forNewContainer:true.        
 
         rslt isNil ifTrue:[
             ^ false
@@ -1750,5 +1806,5 @@
 !SourceCodeManagerUtilities class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.47 2000-12-07 14:13:50 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.48 2000-12-08 13:05:36 cg Exp $'
 ! !