ResourceSpecEditor.st
changeset 2200 98ec425dc11c
parent 2120 0d32d6e4a918
child 2234 2c03d8e76468
--- a/ResourceSpecEditor.st	Tue Sep 05 17:57:47 2006 +0200
+++ b/ResourceSpecEditor.st	Tue Sep 05 18:44:05 2006 +0200
@@ -230,6 +230,10 @@
 
 !
 
+autoAcceptOnSelectionChange
+    ^ builder valueAspectFor:#autoAcceptOnSelectionChange initialValue:true
+!
+
 canPasteHolder
     "returns whether the application can paste; as value holder"
 
@@ -401,32 +405,31 @@
 
     anythingChangedHolder := self enablingCommitButtonsHolder.
     anythingChanged := anythingChangedHolder value.
-    anythingChanged ifTrue:[          
-"/        answer := ((YesNoBox title:'Resource item was modified!!\Save it?\' withCRs)        
-"/                        noText:'No';
-"/                        yesText:'Yes';
-"/                        showAtPointer;
-"/                        accepted). 
+    anythingChanged ifFalse:[^ true].
+
+    self autoAcceptOnSelectionChange value ifTrue:[
+        self accept.
+        ^ true
+    ].
 
-        answer := Dialog 
-                        confirmWithCancel:(resources string:'Item was modified !!\Save it ?\' withCRs)
-                        labels:(resources array:#('Cancel' 'No' 'Yes'))
-                        default:3.
-        answer isNil ifTrue:[
-            ^ false
-        ].
+    answer := Dialog 
+                    confirmWithCancel:(resources string:'Item was modified !!\Save it ?\' withCRs)
+                    labels:(resources array:#('Cancel' 'No' 'Yes'))
+                    default:3.
+    answer isNil ifTrue:[
+        ^ false
+    ].
 
-        answer ifTrue:[
-            self accept
-        ] ifFalse:[
-            anythingChangedHolder value: false. 
-            self clearModifiedFlag. 
-            self clearModified.
-        ].
+    answer ifTrue:[
+        self accept
+    ] ifFalse:[
+        anythingChangedHolder value: false. 
+        self clearModifiedFlag. 
+        self clearModified.
     ].
-    ^true
+    ^ true
 
-    "Modified: / 30.10.2001 / 18:38:34 / cg"
+    "Modified: / 05-09-2006 / 18:41:11 / cg"
 !
 
 askForListModification
@@ -530,6 +533,17 @@
 
 !ResourceSpecEditor methodsFor:'selection'!
 
+selectionChangeAllowed:newSelection
+    self isModified ifFalse:[^ true].
+
+    self autoAcceptOnSelectionChange value ifTrue:[
+        self accept
+    ] ifFalse:[
+        self askForUnsavedModifications ifFalse:[^ false].
+    ].
+    ^ true
+!
+
 tabSelection
     "returns selected tab index or 0"
 
@@ -756,5 +770,5 @@
 !ResourceSpecEditor class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/ResourceSpecEditor.st,v 1.37 2006-03-06 08:52:26 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ResourceSpecEditor.st,v 1.38 2006-09-05 16:44:05 cg Exp $'
 ! !