Clean up TextEditor modification checks
authorStefan Vogel <sv@exept.de>
Fri, 08 May 2009 17:18:57 +0200
changeset 8614 6712b6367808
parent 8613 6c82076a9cbf
child 8615 3407696ae28f
Clean up TextEditor modification checks
FileApplicationNoteBook.st
--- a/FileApplicationNoteBook.st	Fri May 08 11:38:09 2009 +0200
+++ b/FileApplicationNoteBook.st	Fri May 08 17:18:57 2009 +0200
@@ -4258,7 +4258,7 @@
 !FileApplicationNoteBook::TextEditor class methodsFor:'defaults'!
 
 checkModifiedDelayTime
-    ^ 5
+    ^ 30    "seconds"
 !
 
 tabStringFor:aApplicationType
@@ -4524,14 +4524,6 @@
 
     self setUpTextView.
 
-    checkModifiedBlock isNil ifTrue:[
-        checkModifiedBlock := [
-            self 
-                enqueueMessage:#checkItemForChangesWithNewSetup 
-                for:self 
-                arguments:#().
-        ].
-    ].
     textEditorModificationTime := self fileName modificationTime.
     self releaseCheckModify.
     self setupCheckModify.
@@ -5008,6 +5000,7 @@
     self enableReload value:false.
     self itemChanged value:false.
     self modifiedChannel value:false.
+    self notify:nil.
     ^ true
 
 
@@ -5368,7 +5361,7 @@
 !FileApplicationNoteBook::TextEditor methodsFor:'private-process'!
 
 checkItemForChanges
-    |exists time message|
+    |exists fileModificationTime message|
 
     item isNil ifTrue:[
         ^ self
@@ -5377,27 +5370,22 @@
     exists := self item exists.
     self itemRemoved value:(exists not).
     exists ifTrue:[
-        time := self fileName modificationTime.
+        fileModificationTime := self fileName modificationTime.
         textEditorModificationTime isNil ifTrue:[
-            textEditorModificationTime := time.
+            textEditorModificationTime := fileModificationTime.
         ].
-
         message := '%1 was changed by someone else.'.
     ] ifFalse:[
         message := '%1 was removed by someone else.'.
     ].
 
-    message := ((resources string:message with:item fileName baseName) allBold)
-                emphasisAllAdd:(UserPreferences current emphasisForModifiedBuffer).
-
-    (textEditorModificationTime ~= time) ifTrue:[
-        "/ contents changed by someone else
-        self notify:message.
-        self itemChanged value:true.
-    ] ifFalse:[
-        "/ not modified - if the shown message is my previous 
-        message = self notifyChannel value ifTrue:[
-            self notify:nil.
+    (textEditorModificationTime ~= fileModificationTime) ifTrue:[
+        "file contents has been changed by someone else"
+        message := (resources string:message with:item fileName baseName) allBold
+                        emphasisAllAdd:(UserPreferences current emphasisForModifiedBuffer).
+        message = self notifyChannel value ifFalse:[
+            self notify:message.
+            self itemChanged value:true.
         ].
     ].
 !
@@ -5408,12 +5396,21 @@
 !
 
 releaseCheckModify
-
-    Processor removeTimedBlock:checkModifiedBlock.
+    checkModifiedBlock notNil ifTrue:[
+        Processor removeTimedBlock:checkModifiedBlock.
+    ].
 !
 
 setupCheckModify
 
+    checkModifiedBlock isNil ifTrue:[
+        checkModifiedBlock := [
+                self 
+                    enqueueMessage:#checkItemForChangesWithNewSetup 
+                    for:self 
+                    arguments:#().
+            ].
+    ].
     Processor addTimedBlock:checkModifiedBlock afterSeconds:(self class checkModifiedDelayTime).
 ! !
 
@@ -6034,5 +6031,5 @@
 !FileApplicationNoteBook class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.232 2009-01-14 20:57:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.233 2009-05-08 15:18:57 stefan Exp $'
 ! !