Tools__ChangeSetBrowser2.st
branchjv
changeset 18223 920de32128c2
parent 18222 7b2b8ae7a123
child 18226 346376844040
--- a/Tools__ChangeSetBrowser2.st	Mon Mar 05 10:19:20 2018 +0000
+++ b/Tools__ChangeSetBrowser2.st	Mon Mar 05 12:33:37 2018 +0000
@@ -3120,49 +3120,54 @@
 !
 
 doSave
-
-    changesetFile
-        ifNil:[self doSaveAs]
-        ifNotNil:[self doSaveAs: changesetFile]
-
-    "Modified: / 24-10-2009 / 22:55:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    changesetFile isNil ifTrue:[
+        self doSaveAs
+    ] ifFalse:[
+        self doSaveAs:changesetFile format: (self formatFromFile: changesetFile)  
+    ]
+
+    "Modified: / 05-03-2018 / 12:29:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 doSaveAs
-    | file |
+    | file formatMap formatHolder |
+
+    formatMap := Dictionary new
+                at: (resources string: 'Smalltalk/X changeset') put: nil;
+                at: (resources string: 'Smalltalk/X source') put: #classSource;
+                at: (resources string: 'Bee Smalltalk changseset') put: #Bee;
+                yourself.
+    formatHolder := (formatMap keyAtValue: (self formatFromFile: changesetFile)) asValue.
     Dialog aboutToOpenBoxNotificationSignal handle:[:ex|
-"/        | dialog |
-"/        dialog := ex box application.
-"/        dialog addComponent:(CheckBox label:'x'
-"/                              model:true asValue).
-"/        ex pass.
+        | dialog |
+        dialog := ex box application.
+        dialog addComponent: (ComboListView new
+                                list: formatMap keys asArray sort;
+                                model: formatHolder;
+                                yourself)
+                    labeled: (resources string: 'Format:').
+        ex pass.
     ] do:[
         file := Dialog requestFileName:'Select File for Save' default: (changesetFile ? 'somechanges.chg') pattern:('*.chg').
     ].
     file isNil ifTrue:[^self].
-    self doSaveAs: file.
+    self doSaveAs: file format: (formatMap at: formatHolder value)
 
     "Modified: / 27-12-2011 / 10:39:52 / cg"
-    "Modified: / 05-03-2018 / 10:09:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 05-03-2018 / 12:28:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-doSaveAs: newFile
+doSaveAs: newFile format: format
     | changesetToSave |
 
     changesetToSave := ChangeSet new.
     self list1Holder value do:[:e|
         e removed ~~ true ifTrue:[changesetToSave add:e].
     ].
-
-"/    [
-        (newFile asFilename suffix = 'st') ifTrue:[
-            changesetToSave saveToFile: newFile format: #classSource.
-        ] ifFalse:[
-            changesetToSave saveToFile: newFile
-        ].
-        changesetFile := newFile.
-"/    ] on: Error do:
-"/        [:ex|Dialog warn: 'Error saving changes: ' , ex description]
+    changesetToSave saveToFile: newFile format: format.
+    changesetFile := newFile.
+
+    "Created: / 05-03-2018 / 12:12:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 doScrollToBottom
@@ -3831,6 +3836,21 @@
     "Created: / 30-08-2011 / 14:30:58 / cg"
 !
 
+formatFromFile: aFilename
+    "Guess and return format of given changefile."
+    aFilename notNil ifTrue:[ 
+        | suffix |
+
+        suffix := aFilename asFilename suffix.
+        suffix = '.chg' ifTrue:[ ^ nil ].
+        suffix = '.ch' ifTrue:[ ^ #Bee  ].    
+        suffix = '.st' ifTrue:[ ^ #classSource ].    
+    ].
+    ^ nil
+
+    "Created: / 05-03-2018 / 12:28:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 getNavigatorChangeSet
 
     | changeset |