reenabled old showUnselected code.
"
COPYRIGHT (c) 1997 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
SelectionBrowser subclass:#FileSelectionBrowser
instanceVariableNames:'selectedFileFilter directoryView listOfFileFilters directory'
classVariableNames:''
poolDictionaries:''
category:'Interface-Dialogs'
!
!FileSelectionBrowser class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1997 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
The FileSelectionBrowser allows you to browse in file directories
and to select files in order to load file contents or to save
something to files.
[start with:]
FileSelectionBrowser open
[author:]
Thomas Zwick, eXept Software AG
"
! !
!FileSelectionBrowser class methodsFor:'instance creation'!
request: aTitle fileName: aFileName inDirectory: dir withFileFilters: fileFilters
^self new
title: aTitle;
fileName: aFileName;
directory: dir;
listOfFileFilters: fileFilters;
open
"
self
request: 'Select Your Profile File'
fileName: '.profile'
inDirectory: Filename homeDirectory
withFileFilters: #('.*')
"
"Modified: / 17.8.1998 / 10:15:50 / cg"
!
request: aTitle fileName: aFileName withFileFilters: fileFilters
^self new
title: aTitle;
fileName: aFileName;
listOfFileFilters: fileFilters;
open
"
self
request: 'Select Your Profile File'
fileName: '/etc/fstab'
withFileFilters: #('*')
"
"Modified: / 17.8.1998 / 10:15:50 / cg"
!
request: aTitle pathName: aPath withFileFilters: fileFilters
^self new
title: aTitle;
directory: aPath;
listOfFileFilters: fileFilters;
open
"
self
request: 'Select A File'
pathName: '/etc'
withFileFilters: #('*.conf')
"
"Modified: / 17.8.1998 / 10:15:50 / cg"
!
request: aTitle withFileFilters: fileFilters
^self new
title: aTitle;
listOfFileFilters: fileFilters;
open
"
self request: 'Select A File' fileFilters: #('.*')
"
"Modified: / 17.8.1998 / 10:15:49 / cg"
!
requestFileName
^self new title: 'Select A File'; open
"
self requestFileName
"
"Modified: / 17.8.1998 / 10:15:48 / cg"
! !
!FileSelectionBrowser class methodsFor:'accessing'!
loadImageFileNameFilters
^ OrderedCollection
withAll: #(
'*.xpm ; *.xbm ; *.gif ; *.tif ; *.tiff ; *.bmp ; *.jpeg ; *.jpg'
'*'
)
"Modified: / 12.9.1998 / 17:23:42 / cg"
!
projectFileNameFilters
^Array withAll: #(
'*.st ; *.*o ; *.s ; *.c ; Make* ; *.project'
'*'
)
"Modified: / 12.9.1998 / 17:23:22 / cg"
!
saveImageFileNameFilters
^ OrderedCollection
withAll: #(
'*.xpm ; *.xbm ; *.gif ; *.tif ; *.tiff ; *.bmp'
'*'
)
"Modified: / 12.9.1998 / 17:23:54 / cg"
! !
!FileSelectionBrowser class methodsFor:'interface specs'!
windowSpec
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:FileSelectionBrowser andSelector:#windowSpec
FileSelectionBrowser new openInterface:#windowSpec
FileSelectionBrowser open
"
<resource: #canvas>
^
#(#FullSpec
#window:
#(#WindowSpec
#name: 'File Selection Browser'
#layout: #(#LayoutFrame 379 0 259 0 978 0 608 0)
#label: 'File Selection Browser'
#min: #(#Point 10 10)
#max: #(#Point 1152 900)
#bounds: #(#Rectangle 379 259 979 609)
#usePreferredExtent: false
)
#component:
#(#SpecCollection
#collection:
#(
#(#VariableHorizontalPanelSpec
#name: 'panel'
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -40 1.0)
#component:
#(#SpecCollection
#collection:
#(
#(#ViewSpec
#name: 'view1'
#component:
#(#SpecCollection
#collection:
#(
#(#FileSelectionTreeSpec
#name: 'directoryTreeView'
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -25 1.0)
#model: #selectionOfDirectory
#hasHorizontalScrollBar: true
#hasVerticalScrollBar: true
#miniScrollerHorizontal: true
#showDirectoryIndicatorForRoot: false
#showDirectoryIndicator: true
#valueChangeSelector: #readDirectory
#hierarchicalList: #rootOfDirectory
#itemClass: 'Directory'
)
#(#InputFieldSpec
#name: 'directoryInputField'
#layout: #(#LayoutFrame 2 0.0 -22 1 0 1.0 0 1)
#model: #selectionOfDirectory
#immediateAccept: false
)
)
)
)
#(#ViewSpec
#name: 'view2'
#component:
#(#SpecCollection
#collection:
#(
#(#InputFieldSpec
#name: 'EditField'
#layout: #(#LayoutFrame 1 0.0 -22 1 -2 1.0 0 1)
#model: #valueOfFileName
#acceptOnReturn: false
#acceptOnTab: false
)
#(#SubCanvasSpec
#name: 'subCanvas1'
#layout: #(#LayoutFrame 1 0.0 0 0.0 0 1.0 -25 1.0)
#clientHolder: #directoryView
)
)
)
)
)
)
#handles: #(#Any 0.5 1.0)
)
#(#UISubSpecification
#name: 'SubSpecification'
#layout: #(#LayoutFrame 2 0.0 -32 1 0 1.0 -8 1.0)
#majorKey: #ToolApplicationModel
#minorKey: #windowSpecForCommitWithoutChannels
)
)
)
)
! !
!FileSelectionBrowser methodsFor:'accessing'!
directory: aDirectory
directory := (aDirectory ? Filename currentDirectory) asFilename asAbsoluteFilename pathName
"Modified: / 17.8.1998 / 10:15:53 / cg"
!
directoryView
^directoryView ? (directoryView := DirectoryView new)
!
fileName: aFileName
self valueOfFileName value: (aFileName ? '') asFilename baseName.
directory := directory ? ((aFileName ? '') asFilename asAbsoluteFilename directoryName).
"Modified: / 17.8.1998 / 10:15:54 / cg"
!
listOfFileFilters: anArray
listOfFileFilters := anArray
! !
!FileSelectionBrowser methodsFor:'accessing - views'!
directoryInputField
^builder componentAt: #directoryInputField
!
directoryTreeView
^builder componentAt: #directoryTreeView
! !
!FileSelectionBrowser methodsFor:'aspects'!
rootOfDirectory
|holder|
(holder := builder bindingAt:#rootOfDirectory) isNil ifTrue:[
builder aspectAt:#rootOfDirectory put: (holder := Filename rootDirectory name asValue).
].
^ holder
!
selectionOfDirectory
|holder|
(holder := builder bindingAt:#selectionOfDirectory) isNil ifTrue:[
builder aspectAt:#selectionOfDirectory put: (holder := ValueHolder new)
].
^ holder
!
valueOfFileName
|holder|
(holder := builder bindingAt:#valueOfFileName) isNil ifTrue:[
builder aspectAt:#valueOfFileName put:(holder := ValueHolder new).
].
^ holder
! !
!FileSelectionBrowser methodsFor:'callbacks'!
fileDoubleClicked: aFileName
self valueOfFileName value: aFileName.
accept value: true.
self close
!
readDirectory
self directoryTreeView selection notNil
ifTrue:
[
directoryView directory: self selectionOfDirectory value; readDirectory.
self class lastSelection notNil ifTrue: [self class lastSelection: self selectionOfDirectory value]
]
! !
!FileSelectionBrowser methodsFor:'startup / release'!
closeCancel
directoryView release.
super closeCancel
!
closeRequest
directoryView release.
super closeRequest
!
open
super open.
accept value ifTrue:[
^ (self selectionOfDirectory value ? '') asFilename
constructString:(self valueOfFileName value ? '')
].
^ nil
"Modified: / 17.8.1998 / 10:15:55 / cg"
!
postBuildWith:aBuilder
directoryView listOfFileFilters: listOfFileFilters ? #('*').
directoryView fileSelectAction: [:aFileName |self valueOfFileName value: aFileName asFilename baseName].
directoryView fileDoubleClickAction: [:aFileName |self fileDoubleClicked: aFileName asFilename baseName].
directoryView fileFilterSelectAction: [:fileFilter|
"/ CG: obscure code - isn't the code below the same as ?
"/ self valueOfFileName value:((self valueOfFileName value ? 'unknown')
"/ asFilename
"/ withSuffix:(fileFilter asFilename suffix))
self valueOfFileName value: (
((self valueOfFileName value ? 'unknown') readStream upTo: $.), '.',
(fileFilter copy reverse readStream upTo: $.) reverse)
].
self directoryTreeView selectPathname: directory ? self class lastSelection ? Filename currentDirectory asAbsoluteFilename name.
self directoryInputField entryCompletionBlock:
[:f|
|completedDirectory|
(completedDirectory := Filename
filenameCompletionFor: self directoryInputField contents
directory:(directory asFilename)
directoriesOnly:true
filesOnly:false
ifMultiple:
[:dir |
self directoryTreeView selection notNil ifTrue: [
self directoryTreeView selectedNodeExpand: true]
]) asFilename exists
ifTrue:
[
self directoryInputField contents: completedDirectory.
self directoryTreeView selectPathname: completedDirectory.
self readDirectory
]
ifFalse: [self directoryInputField flash]
].
directoryView selectionOfFile value:
(directoryView listOfFiles detect: [:row| row baseName = self valueOfFileName value] ifNone: nil).
^super postBuildWith:aBuilder
"Modified: / 12.9.1998 / 17:10:44 / cg"
! !
!FileSelectionBrowser class methodsFor:'documentation'!
version
^ '$Header$'
! !