--- a/FilenameWidgetWithHistory.st Tue Nov 02 10:19:31 2010 +0100
+++ b/FilenameWidgetWithHistory.st Tue Nov 02 20:12:20 2010 +0100
@@ -13,7 +13,7 @@
SimpleView subclass:#FilenameWidgetWithHistory
instanceVariableNames:'fileNameEntryField browseButton history directoriesOnly filesOnly
- dialogTitle initialDirectoryHolder'
+ dialogTitle initialDirectoryHolder baseDirectory'
classVariableNames:''
poolDictionaries:''
category:'Views-Interactors'
@@ -74,6 +74,14 @@
"Created: / 20-10-2010 / 17:49:54 / cg"
!
+baseDirectory
+ ^ baseDirectory
+!
+
+baseDirectory:something
+ baseDirectory := something.
+!
+
contents
^ fileNameEntryField contents
@@ -211,16 +219,22 @@
topFraction:0 offset:0
bottomFraction:1 offset:0).
- browseButton := Button in:self.
- browseButton label:'...'.
- browseButton action:[ self browseForFileOrDirectory ].
+ self initializeBrowseButton.
browseButton layout:(LayoutFrame
leftFraction:1 offset:-22
rightFraction:1 offset:-2
topFraction:0 offset:0
bottomFraction:1 offset:0).
- "Modified: / 19-10-2010 / 16:21:17 / cg"
+ "Modified: / 02-11-2010 / 19:50:33 / cg"
+!
+
+initializeBrowseButton
+ browseButton := Button in:self.
+ browseButton label:'...'.
+ browseButton action:[ self browseForFileOrDirectory ].
+
+ "Created: / 02-11-2010 / 19:50:21 / cg"
!
initializeFilenameField
@@ -270,17 +284,25 @@
title := dialogTitle notNil
ifTrue:[ dialogTitle ]
- ifFalse:[
- directoriesOnly
- ifTrue:[ resources string:'Select Directory' ]
- ifFalse:[
- filesOnly
- ifTrue:[ resources string:'Select File' ]
- ifFalse:[ resources string:'Select Path' ]]].
+ ifFalse:[
+ resources string:(
+ directoriesOnly
+ ifTrue:[ 'Select Directory' ]
+ ifFalse:[
+ filesOnly
+ ifTrue:[ 'Select File' ]
+ ifFalse:[ 'Select Path' ]])].
defaultPath := (self model notNil)
ifTrue:[ self model value ]
ifFalse:[ fileNameEntryField contents ].
+
+ defaultPath asFilename isAbsolute ifFalse:[
+ baseDirectory notNil ifTrue:[
+ defaultPath := baseDirectory asFilename construct:defaultPath.
+ ].
+ ].
+
defaultPath notNil ifTrue:[
defaultDir := defaultPath asFilename directory.
] ifFalse:[
@@ -294,6 +316,12 @@
path isEmptyOrNil ifTrue:[ ^ self ].
path := path asFilename.
+ baseDirectory notNil ifTrue:[
+ (path pathName startsWith:baseDirectory asFilename pathName) ifTrue:[
+ path := (path pathName copyFrom:(baseDirectory asFilename pathName size + 2)) asFilename.
+ ].
+ ].
+
initialDirectoryHolder value:path directory.
path := path pathName.
@@ -303,15 +331,15 @@
].
fileNameEntryField contents:path.
- "Modified: / 26-10-2010 / 12:46:40 / cg"
+ "Modified: / 02-11-2010 / 20:11:45 / cg"
! !
!FilenameWidgetWithHistory class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/FilenameWidgetWithHistory.st,v 1.17 2010-10-26 10:47:16 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/FilenameWidgetWithHistory.st,v 1.18 2010-11-02 19:12:20 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libwidg2/FilenameWidgetWithHistory.st,v 1.17 2010-10-26 10:47:16 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/FilenameWidgetWithHistory.st,v 1.18 2010-11-02 19:12:20 cg Exp $'
! !