# HG changeset patch # User tz # Date 891259741 -7200 # Node ID d3995881fa131b7be140be03d963d0c80dbc168a # Parent 20cbba6d7e96dcc3a28ce6d375eb90ad44ac5c6e some changes for instancing diff -r 20cbba6d7e96 -r d3995881fa13 FileSelectionBrowser.st --- a/FileSelectionBrowser.st Sat Mar 21 01:44:00 1998 +0100 +++ b/FileSelectionBrowser.st Mon Mar 30 14:09:01 1998 +0200 @@ -39,32 +39,28 @@ documentation " - documentation to be added. + 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 + Thomas Zwick, eXept Software AG " ! ! !FileSelectionBrowser class methodsFor:'instance creation'! -request: aTitle fileFilters: fileFilters - - "self request: 'Select A File' fileFilters: #('.*')" - - ^self new - title: aTitle; - listOfFileFilters: fileFilters; - open -! - request: aTitle fileName: aFileName inDirectory: dir withFileFilters: fileFilters - - "self + " + self request: 'Select Your Profile File' fileName: '.profile' inDirectory: Filename homeDirectory - withFileFilters: #('.*')" + withFileFilters: #('.*') + " ^self new title: aTitle; @@ -74,20 +70,48 @@ open ! -request: aTitle pathName: aPath fileFilters: fileFilters - - "self request: 'Select A File' pathName: '' fileFilters: #('.*')" +request: aTitle fileName: aFileName withFileFilters: fileFilters + " + self + request: 'Select Your Profile File' + fileName: '/etc/fstab' + withFileFilters: #('*') + " ^self new title: aTitle; - fileName: aPath; + fileName: aFileName; + listOfFileFilters: fileFilters; + open +! + +request: aTitle pathName: aPath withFileFilters: fileFilters + " + self request: 'Select A File' pathName: '/etc' fileFilters: #('*.conf') + " + + ^self new + title: aTitle; + directory: aPath; + listOfFileFilters: fileFilters; + open +! + +request: aTitle withFileFilters: fileFilters + " + self request: 'Select A File' fileFilters: #('.*') + " + + ^self new + title: aTitle; listOfFileFilters: fileFilters; open ! requestFileName - - "self requestFileName" + " + self requestFileName + " ^self new title: 'Select A File'; open @@ -113,101 +137,102 @@ !FileSelectionBrowser class methodsFor:'interface specs'! windowSpec - "this window spec was automatically generated by the ST/X UIPainter" + "This resource specification was automatically generated + by the UIPainter of ST/X." - "do not manually edit this - the painter/builder may not be able to - handle the specification if its corrupted." + "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 " - "FileSelectionBrowser open" ^ #(#FullSpec - #'window:' + #window: #(#WindowSpec - #'name:' 'File Selection Browser' - #'layout:' #(#LayoutFrame 248 0 226 0 847 0 575 0) - #'label:' 'File Selection Browser' - #'min:' #(#Point 10 10) - #'max:' #(#Point 1152 900) - #'bounds:' #(#Rectangle 248 226 848 576) - #'usePreferredExtent:' false + #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:' + #component: #(#SpecCollection - #'collection:' + #collection: #( #(#VariableHorizontalPanelSpec - #'name:' 'panel' - #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -40 1.0) - #'component:' + #name: 'panel' + #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -40 1.0) + #component: #(#SpecCollection - #'collection:' + #collection: #( #(#ViewSpec - #'name:' 'view1' - #'component:' + #name: 'view1' + #component: #(#SpecCollection - #'collection:' + #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' + #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 + #name: 'directoryInputField' + #layout: #(#LayoutFrame 2 0.0 -22 1 0 1.0 0 1) + #model: #selectionOfDirectory + #immediateAccept: false ) ) ) ) #(#ViewSpec - #'name:' 'view2' - #'component:' + #name: 'view2' + #component: #(#SpecCollection - #'collection:' + #collection: #( #(#InputFieldSpec - #'name:' 'EditField' - #'layout:' #(#LayoutFrame 1 0.0 -22 1 -2 1.0 0 1) - #'model:' #valueOfFileName - #'acceptOnReturn:' false - #'acceptOnTab:' false + #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 + #name: 'subCanvas1' + #layout: #(#LayoutFrame 1 0.0 0 0.0 0 1.0 -25 1.0) + #clientHolder: #directoryView ) ) ) ) ) ) - #'handles:' #(#Any 0.5 1.0) + #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 + #name: 'SubSpecification' + #layout: #(#LayoutFrame 2 0.0 -32 1 0 1.0 -8 1.0) + #majorKey: #ToolApplicationModel + #minorKey: #windowSpecForCommitWithoutChannels ) ) ) @@ -218,7 +243,8 @@ directory: aDirectory - directory := (aDirectory ? Filename homeDirectory) asFilename asAbsoluteFilename name + directory := (aDirectory ? Filename currentDirectory) asFilename asAbsoluteFilename name + ! directoryView @@ -230,7 +256,7 @@ self valueOfFileName value: (aFileName ? '') asFilename baseName. directory := directory ? ((aFileName ? '') asFilename directoryName). - + ! listOfFileFilters: anArray @@ -297,8 +323,8 @@ self directoryTreeView selection notNil ifTrue: [ - directoryView directory: self selectionOfDirectory value; readDirectory. - directory isNil ifTrue: [self class lastSelection: self selectionOfDirectory value] + directoryView directory: self selectionOfDirectory value; readDirectory. + self class lastSelection notNil ifTrue: [self class lastSelection: self selectionOfDirectory value] ] ! ! @@ -336,7 +362,7 @@ self valueOfFileName value: ( ((self valueOfFileName value ? 'unknown') readStream upTo: $.), '.', (fileFilter copy reverse readStream upTo: $.) reverse)]. - self directoryTreeView selectPathname: directory ? self class lastSelection ? '/'. + self directoryTreeView selectPathname: directory ? self class lastSelection ? Filename currentDirectory asAbsoluteFilename name. self directoryInputField entryCompletionBlock: [:f|