Allow regular filenames to be entered in pathField.
--- a/FBrowser.st Sat Oct 04 19:54:57 1997 +0200
+++ b/FBrowser.st Tue Oct 07 15:10:43 1997 +0200
@@ -1473,6 +1473,16 @@
"Modified: 19.4.1997 / 13:51:48 / cg"
!
+discardChangesDialog
+ "ask the user if changes should be discarded,
+ return true if changes should be discarded, false otherwise"
+
+ ^ self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
+ yesButton:'change'
+
+ "Created: 2.10.1997 / 14:08:37 / stefan"
+!
+
filterPatternChanged
fileListView scrollToTop.
self updateCurrentDirectory
@@ -1542,54 +1552,58 @@
"if text was modified show a queryBox,
otherwise ask for & change to that directory"
- (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
- yesButton:'change') ifTrue:[
- self queryForDirectoryToChange
+ self discardChangesDialog ifTrue:[
+ self queryForDirectoryToChange
]
"Modified: 21.9.1997 / 23:45:35 / cg"
+ "Modified: 2.10.1997 / 14:09:02 / stefan"
!
changeDirectoryTo:aDirectoryName
"sent from label menu to change back to a previous directory"
- self doChangeCurrentDirectoryTo:aDirectoryName updateHistory:false
+ self discardChangesDialog ifTrue:[
+ self doChangeCurrentDirectoryTo:aDirectoryName updateHistory:false.
+ ].
+
+ "Modified: 2.10.1997 / 14:09:24 / stefan"
!
changeToDefaultDirectory
"if text was modified show a queryBox,
otherwise change immediately to the default directory"
- (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
- yesButton:'change') ifTrue:[
- self doChangeToDefaultDirectory
+ self discardChangesDialog ifTrue:[
+ self doChangeToDefaultDirectory
]
"Modified: 21.9.1997 / 23:45:04 / cg"
+ "Modified: 2.10.1997 / 14:09:33 / stefan"
!
changeToHomeDirectory
"if text was modified show a queryBox,
otherwise change immediately to the home directory"
- (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
- yesButton:'change') ifTrue:[
- self doChangeToHomeDirectory
+ self discardChangesDialog ifTrue:[
+ self doChangeToHomeDirectory
]
"Modified: 21.9.1997 / 23:45:10 / cg"
+ "Modified: 2.10.1997 / 14:09:42 / stefan"
!
changeToParentDirectory
"if text was modified show a queryBox,
otherwise change immediately to the parent directory"
- (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
- yesButton:'change') ifTrue:[
- self doChangeToParentDirectory
+ self discardChangesDialog ifTrue:[
+ self doChangeToParentDirectory
]
"Modified: 21.9.1997 / 23:45:15 / cg"
+ "Modified: 2.10.1997 / 14:09:55 / stefan"
!
copyPath
@@ -1661,9 +1675,30 @@
!
pathChanged:newPath
- self changeDirectoryTo:newPath
+ "change directory to newPath. If newPath is a filename, change
+ to its directory and get get the file."
+
+ |f name idx|
+
+ self discardChangesDialog ifTrue:[
+ f := newPath asFilename.
+ (f isDirectory) ifTrue:[
+ self changeDirectoryTo:newPath
+ ] ifFalse:[
+ self changeDirectoryTo:(f directoryName).
+ self changed:#path.
+ name := f baseName.
+ idx := fileList indexOf:name.
+ fileListView selection:idx.
+ self fileSelect:name.
+ self fileGet:true.
+ ].
+ ] ifFalse:[
+ self changed:#path.
+ ].
"Created: 21.9.1997 / 10:43:12 / cg"
+ "Modified: 7.10.1997 / 14:10:39 / stefan"
!
queryForDirectoryToChange
@@ -1749,11 +1784,15 @@
"tell user, that code has been modified - let her confirm"
(subView modified not or:[subView contentsWasSaved]) ifTrue:[
- ^ true
+ ^ true
].
- ^ self
- ask:(resources string:question)
- yesButton:yesButtonText
+ ^ (self ask:(resources string:question) yesButton:yesButtonText) ifTrue:[
+ "/ reset modified flag so question is asked only once
+ subView modified:false.
+ true
+ ] ifFalse:[false]
+
+ "Modified: 2.10.1997 / 14:23:47 / stefan"
!
getSelectedFileName
@@ -2285,10 +2324,11 @@
otherwise change immediately to previous directory."
previousDirectory isNil ifTrue:[^ self].
- (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
- yesButton:'change') ifTrue:[
- self doChangeCurrentDirectoryTo:previousDirectory updateHistory:false
+ self discardChangesDialog ifTrue:[
+ self doChangeCurrentDirectoryTo:previousDirectory updateHistory:false
]
+
+ "Modified: 2.10.1997 / 14:13:40 / stefan"
!
checkIfDirectoryHasChanged
@@ -3954,5 +3994,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/Attic/FBrowser.st,v 1.202 1997-10-02 13:34:27 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Attic/FBrowser.st,v 1.203 1997-10-07 13:10:43 stefan Exp $'
! !
--- a/FileBrowser.st Sat Oct 04 19:54:57 1997 +0200
+++ b/FileBrowser.st Tue Oct 07 15:10:43 1997 +0200
@@ -1473,6 +1473,16 @@
"Modified: 19.4.1997 / 13:51:48 / cg"
!
+discardChangesDialog
+ "ask the user if changes should be discarded,
+ return true if changes should be discarded, false otherwise"
+
+ ^ self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
+ yesButton:'change'
+
+ "Created: 2.10.1997 / 14:08:37 / stefan"
+!
+
filterPatternChanged
fileListView scrollToTop.
self updateCurrentDirectory
@@ -1542,54 +1552,58 @@
"if text was modified show a queryBox,
otherwise ask for & change to that directory"
- (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
- yesButton:'change') ifTrue:[
- self queryForDirectoryToChange
+ self discardChangesDialog ifTrue:[
+ self queryForDirectoryToChange
]
"Modified: 21.9.1997 / 23:45:35 / cg"
+ "Modified: 2.10.1997 / 14:09:02 / stefan"
!
changeDirectoryTo:aDirectoryName
"sent from label menu to change back to a previous directory"
- self doChangeCurrentDirectoryTo:aDirectoryName updateHistory:false
+ self discardChangesDialog ifTrue:[
+ self doChangeCurrentDirectoryTo:aDirectoryName updateHistory:false.
+ ].
+
+ "Modified: 2.10.1997 / 14:09:24 / stefan"
!
changeToDefaultDirectory
"if text was modified show a queryBox,
otherwise change immediately to the default directory"
- (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
- yesButton:'change') ifTrue:[
- self doChangeToDefaultDirectory
+ self discardChangesDialog ifTrue:[
+ self doChangeToDefaultDirectory
]
"Modified: 21.9.1997 / 23:45:04 / cg"
+ "Modified: 2.10.1997 / 14:09:33 / stefan"
!
changeToHomeDirectory
"if text was modified show a queryBox,
otherwise change immediately to the home directory"
- (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
- yesButton:'change') ifTrue:[
- self doChangeToHomeDirectory
+ self discardChangesDialog ifTrue:[
+ self doChangeToHomeDirectory
]
"Modified: 21.9.1997 / 23:45:10 / cg"
+ "Modified: 2.10.1997 / 14:09:42 / stefan"
!
changeToParentDirectory
"if text was modified show a queryBox,
otherwise change immediately to the parent directory"
- (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
- yesButton:'change') ifTrue:[
- self doChangeToParentDirectory
+ self discardChangesDialog ifTrue:[
+ self doChangeToParentDirectory
]
"Modified: 21.9.1997 / 23:45:15 / cg"
+ "Modified: 2.10.1997 / 14:09:55 / stefan"
!
copyPath
@@ -1661,9 +1675,30 @@
!
pathChanged:newPath
- self changeDirectoryTo:newPath
+ "change directory to newPath. If newPath is a filename, change
+ to its directory and get get the file."
+
+ |f name idx|
+
+ self discardChangesDialog ifTrue:[
+ f := newPath asFilename.
+ (f isDirectory) ifTrue:[
+ self changeDirectoryTo:newPath
+ ] ifFalse:[
+ self changeDirectoryTo:(f directoryName).
+ self changed:#path.
+ name := f baseName.
+ idx := fileList indexOf:name.
+ fileListView selection:idx.
+ self fileSelect:name.
+ self fileGet:true.
+ ].
+ ] ifFalse:[
+ self changed:#path.
+ ].
"Created: 21.9.1997 / 10:43:12 / cg"
+ "Modified: 7.10.1997 / 14:10:39 / stefan"
!
queryForDirectoryToChange
@@ -1749,11 +1784,15 @@
"tell user, that code has been modified - let her confirm"
(subView modified not or:[subView contentsWasSaved]) ifTrue:[
- ^ true
+ ^ true
].
- ^ self
- ask:(resources string:question)
- yesButton:yesButtonText
+ ^ (self ask:(resources string:question) yesButton:yesButtonText) ifTrue:[
+ "/ reset modified flag so question is asked only once
+ subView modified:false.
+ true
+ ] ifFalse:[false]
+
+ "Modified: 2.10.1997 / 14:23:47 / stefan"
!
getSelectedFileName
@@ -2285,10 +2324,11 @@
otherwise change immediately to previous directory."
previousDirectory isNil ifTrue:[^ self].
- (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
- yesButton:'change') ifTrue:[
- self doChangeCurrentDirectoryTo:previousDirectory updateHistory:false
+ self discardChangesDialog ifTrue:[
+ self doChangeCurrentDirectoryTo:previousDirectory updateHistory:false
]
+
+ "Modified: 2.10.1997 / 14:13:40 / stefan"
!
checkIfDirectoryHasChanged
@@ -3954,5 +3994,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.202 1997-10-02 13:34:27 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.203 1997-10-07 13:10:43 stefan Exp $'
! !