#FEATURE by cg draft
authorClaus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 21:09:50 +0200
changeset 3686 501ea259b6a8
parent 3685 854b28268aa6
child 3687 a3c56c0e4157
#FEATURE by cg class: FileVersionDiffBrowser added: #acceptInRightView removed: #showDiffTextView #showVersionInfoIfNothingSelected changed: #addAcceptToTextViewMenus #setupForFile:againstVersion:
FileVersionDiffBrowser.st
--- a/FileVersionDiffBrowser.st	Tue Jul 09 20:20:11 2019 +0200
+++ b/FileVersionDiffBrowser.st	Tue Jul 09 21:09:50 2019 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 2019 by eXept Software AG
               All Rights Reserved
@@ -1491,59 +1493,42 @@
 
 !FileVersionDiffBrowser methodsFor:'private'!
 
-addAcceptToTextViewMenus
-    "add to the standard diff text view or single text views menu an accept entry.
-     The acceptAction will fetch the corresponding change and apply it
-     (not the shown text)
+acceptInRightView
+    |text|
 
-     <return: self>
-    "
-
-    |diffTextView leftView rightView singleView|
+    text := self diffTextView text2.
+    self halt.
 
-    diffTextView := self diffTextView.
-    leftView := diffTextView leftTextView.
-    rightView := diffTextView rightTextView.
-    singleView := self componentAt:#singleTextView.
+    "Created: / 08-07-2019 / 02:32:30 / Claus Gittinger"
+!
 
-    (Array
-        with:leftView
-        with:rightView
-        with:singleView)
-    do:[:v |
-        |mGen|
+addAcceptToTextViewMenus
+    "add to the standard diff text view an accept entry.
+     The acceptAction will store the selected version into the file"
 
-        mGen := [
-            |m|
-
-            m := v editMenu.
+    |rightView|
 
-            (m selectorAt:#accept) isNil ifTrue:[
-                m addLabels:(resources array:#('-' 'Accept'))
-                  selectors:#(nil #accept)
-                  after:#copySelection.
-            ].
-            m
-                actionAt:#accept
-                put:[
-                    v == singleView ifTrue:[
-                        self acceptInSingleView
-                    ] ifFalse:[
-                        v == leftView ifTrue:[
-                           self acceptInLeftView
-                        ] ifFalse:[
-                           self acceptInRightView
-                        ].
-                    ].
-                ].
-            m selectorAt:#accept put:nil.
-            m enable:#copySelection.
-            m setEnable:#accept to:[self canAcceptInCodeView].
-            m
-        ].
-        v menuHolder:mGen.
-        v menuMessage:#value.
-    ]
+    self isMultipleVersionBrowser ifFalse:[^ self].
+    
+    diffTextView := self diffTextView.
+    rightView := diffTextView rightTextView.
+
+    rightView acceptAction:[:theCode | 
+                |version code|
+
+                version := self selectedVersionHolder value.
+                code := self getFile:(self fileHolder value) version:version.
+                self fileHolder value contents:code.
+              ].
+    rightView menuHolder:[
+        |m| 
+        m := rightView editMenu.
+        m enable:#accept.
+        m
+    ].
+    rightView menuMessage:#value.
+
+    "Modified: / 08-07-2019 / 02:45:49 / Claus Gittinger"
 !
 
 getFile:fileName version:version
@@ -1594,22 +1579,6 @@
     "Modified (comment): / 08-07-2019 / 00:06:09 / Claus Gittinger"
 !
 
-showDiffTextView
-    "
-    if a method change is selected, then show the diff text view.
-    Add an accept entry to the popup menu.
-
-    <return: self>
-    "
-
-    (self componentAt:#diffTextViewBox) raise; beVisible.
-    (self componentAt:#diffTextView) realizeAllSubViews.
-
-    "/ self addAcceptToTextViewMenus.
-
-    "Modified: / 08-07-2019 / 00:02:19 / Claus Gittinger"
-!
-
 showSingleTextView
     "
     if a method  is selected which is only in version A or B of the class,
@@ -1623,30 +1592,6 @@
     "/ self addAcceptToTextViewMenus.
 
     "Modified: / 08-07-2019 / 00:03:10 / Claus Gittinger"
-!
-
-showVersionInfoIfNothingSelected
-    "show the revision info (author, date, time and logMessage), 
-     if no method is selected"
-
-    |revInfo infoText|
-
-    "/ self information:''.
-
-    versionInfoList notNil ifTrue:[
-        revInfo := versionInfoList detect:[:info | (info at:#revision) = selectedVersionHolder value] ifNone:nil.
-        revInfo notNil ifTrue:[
-            infoText := 'Revision: %1\Author:   %2\Date:     %3\Log:\\%4' withCRs
-                            bindWith:(revInfo at:#revision) 
-                            with:(revInfo at:#author) 
-                            with:(revInfo at:#date)
-                            with:(revInfo at:#logMessage).
-        ].
-    ].    
-    self showSingleTextView.
-
-    "Modified: / 05-02-2017 / 11:49:47 / cg"
-    "Modified (comment): / 08-07-2019 / 00:06:32 / Claus Gittinger"
 ! !
 
 !FileVersionDiffBrowser methodsFor:'setup'!
@@ -1673,8 +1618,10 @@
     self diffTextLabelA value:('File: %1' bindWith:aFilename baseName).
     self diffTextLabelB value:aVersionA.
 
+    self addAcceptToTextViewMenus.
+
     "Created: / 07-07-2019 / 19:57:27 / Claus Gittinger"
-    "Modified: / 08-07-2019 / 01:13:47 / Claus Gittinger"
+    "Modified: / 08-07-2019 / 02:29:10 / Claus Gittinger"
 !
 
 setupForFile:fileA labelA:labelA andFile:fileB labelB:labelB