added askFor... utility.
authorClaus Gittinger <cg@exept.de>
Wed, 02 Feb 2000 13:41:14 +0100
changeset 893 09543b968f15
parent 892 e6da12b72fde
child 894 40292337f043
added askFor... utility.
SourceCodeManagerUtilities.st
--- a/SourceCodeManagerUtilities.st	Wed Feb 02 12:26:59 2000 +0100
+++ b/SourceCodeManagerUtilities.st	Wed Feb 02 13:41:14 2000 +0100
@@ -1,8 +1,8 @@
 Object subclass:#SourceCodeManagerUtilities
-        instanceVariableNames:''
-        classVariableNames:'LastSourceLogMessage LastModule LastPackage'
-        poolDictionaries:''
-        category:'System-SourceCodeManagement'
+	instanceVariableNames:''
+	classVariableNames:'LastSourceLogMessage LastModule LastPackage'
+	poolDictionaries:''
+	category:'System-SourceCodeManagement'
 !
 
 !SourceCodeManagerUtilities class methodsFor:'documentation'!
@@ -25,6 +25,88 @@
 
 !SourceCodeManagerUtilities class methodsFor:'utilities'!
 
+askForContainer:boxText title:title note:notice initialModule:initialModule initialPackage:initialPackage initialFileName:initialFileName
+    "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|
+
+    moduleHolder := initialModule asValue.
+    packageHolder := initialPackage asValue.
+    fileNameHolder := initialFileName asValue.
+
+    resources := ResourcePack for:self.
+
+    "/
+    "/ open a dialog for this
+    "/
+    box := DialogBox new.
+    box label:title.
+
+    component := box addTextLabel:boxText withCRs.
+    component adjust:#left; borderWidth:0.
+    box addVerticalSpace.
+    box addVerticalSpace.
+
+    y := box yPosition.
+    component := box addTextLabel:(resources string:'Module:').
+    component width:0.4; adjust:#right.
+    box yPosition:y.
+    component := box addInputFieldOn:moduleHolder tabable:true.
+    component width:0.6; left:0.4; immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
+
+    box addVerticalSpace.
+    y := box yPosition.
+    component := box addTextLabel:'Package:'.
+    component width:0.4; adjust:#right.
+    box yPosition:y.
+    component := box addInputFieldOn:packageHolder tabable:true.
+    component width:0.6; left:0.4; immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
+
+    box addVerticalSpace.
+    y := box yPosition.
+    component := box addTextLabel:'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.
+
+    box addVerticalSpace.
+
+    notice notNil ifTrue:[
+        component := box addTextLabel:notice.
+        component adjust:#left; borderWidth:0.
+    ].
+
+    box addVerticalSpace.
+    box addAbortAndOkButtons.
+    box showAtPointer.
+
+    box accepted ifFalse:[
+        box destroy.
+        ^ nil
+    ].
+    box destroy.
+
+    module := moduleHolder value withoutSpaces.
+    package := packageHolder value withoutSpaces.
+    fileName := fileNameHolder value withoutSpaces.
+    ^ Dictionary new
+        at:#module put:module;
+        at:#package put:package;
+        at:#fileName put:fileName;
+        yourself
+
+    "
+     self 
+        askForContainer:'enter container' title:'container' note:'some note'
+        initialModule:'foo' initialPackage:'bar' initialFileName:'baz'        
+    "
+!
+
 checkinClass:aClass
     "check a class into the source repository.
      Asks interactively for log-message."
@@ -160,11 +242,10 @@
     "let user specify the source-repository values for aClass"
 
     |box className
-     moduleHolder packageHolder fileNameHolder
      oldModule oldPackage oldFileName
      module package fileName nameSpace nameSpacePrefix
      y component info project nm mgr creatingNew msg 
-     answer doCheckinWithoutAsking forceCheckIn resources|
+     answer doCheckinWithoutAsking forceCheckIn resources rslt note|
 
     resources := ResourcePack for:self.
     aClass isLoaded ifFalse:[
@@ -245,15 +326,12 @@
         ]
     ].
 
-    fileNameHolder := fileName asValue.
     OperatingSystem isMSDOSlike ifTrue:[
         module replaceAll:$\ with:$/.
     ].
-    moduleHolder := module asValue.
     OperatingSystem isMSDOSlike ifTrue:[
         package replaceAll:$\ with:$/.
     ].
-    packageHolder := package asValue.
 
     "/
     "/ check for conflicts (i.e. if such a container already exists) ...
@@ -291,65 +369,26 @@
         "/
         "/ open a dialog for this
         "/
-        box := DialogBox new.
-        box label:title.
-
-        component := box addTextLabel:boxText withCRs.
-        component adjust:#left; borderWidth:0.
-        box addVerticalSpace.
-        box addVerticalSpace.
-
-        y := box yPosition.
-        component := box addTextLabel:(resources string:'Module:').
-        component width:0.4; adjust:#right.
-        box yPosition:y.
-        component := box addInputFieldOn:moduleHolder tabable:true.
-        component width:0.6; left:0.4; immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
-
-        box addVerticalSpace.
-        y := box yPosition.
-        component := box addTextLabel:'Package:'.
-        component width:0.4; adjust:#right.
-        box yPosition:y.
-        component := box addInputFieldOn:packageHolder tabable:true.
-        component width:0.6; left:0.4; immediateAccept:true; acceptOnLeave:false; cursorMovementWhenUpdating:#beginOfLine.
-
-        box addVerticalSpace.
-        y := box yPosition.
-        component := box addTextLabel:'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.
-
-        box addVerticalSpace.
-
         (mgr checkForExistingContainerInModule:module 
                                        package:package 
                                      container:fileName) ifFalse:[
-            component := box addTextLabel:'Notice: class seems to have no container yet.'.
-            component adjust:#left; borderWidth:0.
+            note := 'Notice: class seems to have no container yet.'.
             creatingNew := true.
         ] ifTrue:[
             creatingNew := false.
         ].
 
-        box addVerticalSpace.
-
-        box addAbortAndOkButtons.
+        rslt := self 
+                askForContainer:boxText title:title note:note
+                initialModule:module initialPackage:package initialFileName:fileName.        
 
-        box showAtPointer.
-
-        box accepted ifFalse:[
-            box destroy.
+        rslt isNil ifTrue:[
             ^ false
         ].
 
-        module := moduleHolder value withoutSpaces.
-        package := packageHolder value withoutSpaces.
-
-        fileName := fileNameHolder value withoutSpaces.
-
+        module := rslt at:#module.
+        package := rslt at:#package.
+        fileName := rslt at:#fileName.
     ].
 
     (fileName endsWith:',v') ifTrue:[
@@ -559,5 +598,5 @@
 !SourceCodeManagerUtilities class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.6 2000-01-21 12:05:39 ps Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.7 2000-02-02 12:41:14 cg Exp $'
 ! !