FileSelectionList.st
changeset 547 6c9aaf7a84e7
parent 472 17f795e6ecba
child 586 032b3245e53a
equal deleted inserted replaced
546:b643875bda30 547:6c9aaf7a84e7
    13 SelectionInListView subclass:#FileSelectionList
    13 SelectionInListView subclass:#FileSelectionList
    14 	instanceVariableNames:'pattern directory timeStamp directoryId directoryName
    14 	instanceVariableNames:'pattern directory timeStamp directoryId directoryName
    15 		directoryContents directoryFileTypes fileTypes realAction
    15 		directoryContents directoryFileTypes fileTypes realAction
    16 		matchBlock stayInDirectory ignoreParentDirectory markDirectories
    16 		matchBlock stayInDirectory ignoreParentDirectory markDirectories
    17 		ignoreDirectories directoryChangeCheckBlock quickDirectoryChange
    17 		ignoreDirectories directoryChangeCheckBlock quickDirectoryChange
    18 		directoryChangeAction'
    18 		directoryChangeAction directorySelectAction fileSelectAction
       
    19 		ignoreFiles'
    19 	classVariableNames:''
    20 	classVariableNames:''
    20 	poolDictionaries:''
    21 	poolDictionaries:''
    21 	category:'Views-Text'
    22 	category:'Views-Text'
    22 !
    23 !
    23 
    24 
    88 
    89 
    89             ignoreDirectories       if true, no directories are shown at all.
    90             ignoreDirectories       if true, no directories are shown at all.
    90                                     Makes sense to limit the user to choose among regular files.
    91                                     Makes sense to limit the user to choose among regular files.
    91                                     Default is false.
    92                                     Default is false.
    92 
    93 
       
    94             ignoreFiles             if true, no regular files are shown at all.
       
    95                                     Makes sense to limit the user to choose among directories files.
       
    96                                     Default is false.
       
    97 
    93             directoryChangeCheckBlock 
    98             directoryChangeCheckBlock 
    94                                     if nonNil, directoryChanges are only allowed if this block
    99                                     if nonNil, directoryChanges are only allowed if this block
    95                                     returns true. It is evaluated with one argument, the pathName.
   100                                     returns true. It is evaluated with one argument, the pathName.
    96                                     Defaults to nil (i.e. no checks).
   101                                     Defaults to nil (i.e. no checks).
    97 
   102 
       
   103             directorySelectAction 
       
   104                                     if nonNil, a directory-select evaluate this block.
       
   105                                     Possible hook for others (used with Boxes)
       
   106                                     Defaults to nil.
       
   107 
       
   108             fileSelectAction 
       
   109                                     if nonNil, file-select evaluate this block.
       
   110                                     Possible hook for others (used with Boxes)
       
   111                                     Defaults to nil.
    98 "
   112 "
    99 !
   113 !
   100 
   114 
   101 examples 
   115 examples 
   102 "
   116 "
   104     or file-browser-like applications.
   118     or file-browser-like applications.
   105     Thus, the following examples are a bit untypical.
   119     Thus, the following examples are a bit untypical.
   106 
   120 
   107     example (plain file-list):
   121     example (plain file-list):
   108 
   122 
   109 	|list|
   123         |list|
   110 
   124 
   111 	list := FileSelectionList new.
   125         list := FileSelectionList new.
   112 	list open
   126         list open
   113 
   127 
   114     example (scrolled & some action):
   128 
   115 
   129     scrolled & some action:
   116 	|top v list|
   130 
   117 
   131         |top v list|
   118 	top := StandardSystemView new.
   132 
   119 	top extent:(300 @ 200).
   133         top := StandardSystemView new.
   120 	v := ScrollableView for:FileSelectionList in:top.
   134         top extent:(300 @ 200).
   121 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   135         v := ScrollableView for:FileSelectionList in:top.
   122 	list := v scrolledView.
   136         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   123 	list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   137         list := v scrolledView.
   124 	top open
   138         list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
       
   139         top open
   125 
   140 
   126     ignore the parentDirectory:
   141     ignore the parentDirectory:
   127 
   142 
   128 	|top v list|
   143         |top v list|
   129 
   144 
   130 	top := StandardSystemView new.
   145         top := StandardSystemView new.
   131 	top extent:(300 @ 200).
   146         top extent:(300 @ 200).
   132 	v := ScrollableView for:FileSelectionList in:top.
   147         v := ScrollableView for:FileSelectionList in:top.
   133 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   148         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   134 	list := v scrolledView.
   149         list := v scrolledView.
   135 	list ignoreParentDirectory:true.
   150         list ignoreParentDirectory:true.
   136 	top open
   151         top open
   137 
   152 
   138     ignore all directories:
   153     ignore all directories (i.e. regular files only):
   139 
   154 
   140 	|top v list|
   155         |top v list|
   141 
   156 
   142 	top := StandardSystemView new.
   157         top := StandardSystemView new.
   143 	top extent:(300 @ 200).
   158         top extent:(300 @ 200).
   144 	v := ScrollableView for:FileSelectionList in:top.
   159         v := ScrollableView for:FileSelectionList in:top.
   145 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   160         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   146 	list := v scrolledView.
   161         list := v scrolledView.
   147 	list ignoreDirectories:true.
   162         list ignoreDirectories:true.
   148 	top open
   163         top open
       
   164 
       
   165     ignore all regular files (i.e. directories only):
       
   166 
       
   167         |top v list|
       
   168 
       
   169         top := StandardSystemView new.
       
   170         top extent:(300 @ 200).
       
   171         v := ScrollableView for:FileSelectionList in:top.
       
   172         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
       
   173         list := v scrolledView.
       
   174         list ignoreFiles:true.
       
   175         top open
   149 
   176 
   150     dont show the directory arrow-mark:
   177     dont show the directory arrow-mark:
   151 
   178 
   152 	|top v list|
   179         |top v list|
   153 
   180 
   154 	top := StandardSystemView new.
   181         top := StandardSystemView new.
   155 	top extent:(300 @ 200).
   182         top extent:(300 @ 200).
   156 	v := ScrollableView for:FileSelectionList in:top.
   183         v := ScrollableView for:FileSelectionList in:top.
   157 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   184         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   158 	list := v scrolledView.
   185         list := v scrolledView.
   159 	list markDirectories:false.
   186         list markDirectories:false.
   160 	top open
   187         top open
   161 
   188 
   162     example (adds a pattern, only showing .st files and directories):
   189     adds a pattern, only showing .st files and directories:
   163 
   190 
   164 	|top v list|
   191         |top v list|
   165 
   192 
   166 	top := StandardSystemView new.
   193         top := StandardSystemView new.
   167 	top extent:(300 @ 200).
   194         top extent:(300 @ 200).
   168 	v := ScrollableView for:FileSelectionList in:top.
   195         v := ScrollableView for:FileSelectionList in:top.
   169 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   196         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   170 	list := v scrolledView.
   197         list := v scrolledView.
   171 	list pattern:'*.st'.
   198         list pattern:'*.st'.
   172 	list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   199         list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   173 	top open
   200         top open
   174 
   201 
   175     example (a more complicated pattern):
   202     a more complicated pattern:
   176 
   203 
   177 	|top v list|
   204         |top v list|
   178 
   205 
   179 	top := StandardSystemView new.
   206         top := StandardSystemView new.
   180 	top extent:(300 @ 200).
   207         top extent:(300 @ 200).
   181 	v := ScrollableView for:FileSelectionList in:top.
   208         v := ScrollableView for:FileSelectionList in:top.
   182 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   209         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   183 	list := v scrolledView.
   210         list := v scrolledView.
   184 	list pattern:'[A-D]*.st'.
   211         list pattern:'[A-D]*.st'.
   185 	list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   212         list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   186 	top open
   213         top open
   187 
   214 
   188     example (adds a matchblock to show only writable files):
   215     adds a matchblock to show only writable files:
   189 
   216 
   190 	|top v list|
   217         |top v list|
   191 
   218 
   192 	top := StandardSystemView new.
   219         top := StandardSystemView new.
   193 	top extent:(300 @ 200).
   220         top extent:(300 @ 200).
   194 	v := ScrollableView for:FileSelectionList in:top.
   221         v := ScrollableView for:FileSelectionList in:top.
   195 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   222         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   196 	list := v scrolledView.
   223         list := v scrolledView.
   197 	list matchBlock:[:name | 
   224         list matchBlock:[:name | 
   198 			    |fileName|
   225                             |fileName|
   199 			    fileName := name asFilename.
   226                             fileName := name asFilename.
   200 			    fileName isWritable or:[fileName isDirectory]
   227                             fileName isWritable or:[fileName isDirectory]
   201 			].
   228                         ].
   202 	list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   229         list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   203 	top open
   230         top open
   204 
   231 
   205     example (adds a matchblock to suppress directories):
   232     adds a matchblock to suppress directories:
   206 
   233     (this can be done easier with #ignoreDirectories)
   207 	|top v list|
   234 
   208 
   235         |top v list|
   209 	top := StandardSystemView new.
   236 
   210 	top extent:(300 @ 200).
   237         top := StandardSystemView new.
   211 	v := ScrollableView for:FileSelectionList in:top.
   238         top extent:(300 @ 200).
   212 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   239         v := ScrollableView for:FileSelectionList in:top.
   213 	list := v scrolledView.
   240         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   214 	list matchBlock:[:name | 
   241         list := v scrolledView.
   215 			    name asFilename isDirectory not
   242         list matchBlock:[:name | 
   216 			].
   243                             name asFilename isDirectory not
   217 	list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   244                         ].
   218 	top open
   245         list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   219 
   246         top open
   220     example (the above can be done more convenient)
   247 
   221 
   248     the above can be done more convenient:
   222 	|top v list|
   249 
   223 
   250         |top v list|
   224 	top := StandardSystemView new.
   251 
   225 	top extent:(300 @ 200).
   252         top := StandardSystemView new.
   226 	v := ScrollableView for:FileSelectionList in:top.
   253         top extent:(300 @ 200).
   227 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   254         v := ScrollableView for:FileSelectionList in:top.
   228 	list := v scrolledView.
   255         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   229 	list ignoreDirectories:true.
   256         list := v scrolledView.
   230 	list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   257         list ignoreDirectories:true.
   231 	top open
   258         list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   232 
   259         top open
   233     example (adds a matchblock to block parent dirs (i.e. only allow files here & below):
   260 
   234 
   261     adds a matchblock to block parent dirs (i.e. only allow files here & below):
   235 	|top v list currentDir|
   262     (can be done easier with #ignoreParentDirectory)
   236 
   263 
   237 	currentDir := '.' asFilename pathName.
   264         |top v list currentDir|
   238 
   265 
   239 	top := StandardSystemView new.
   266         currentDir := '.' asFilename pathName.
   240 	top extent:(300 @ 200).
   267 
   241 	v := ScrollableView for:FileSelectionList in:top.
   268         top := StandardSystemView new.
   242 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   269         top extent:(300 @ 200).
   243 	list := v scrolledView.
   270         v := ScrollableView for:FileSelectionList in:top.
   244 	list matchBlock:[:name | 
   271         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   245 			    ((name endsWith:'/..') and:[list directory pathName = currentDir]) not
   272         list := v scrolledView.
   246 			].
   273         list matchBlock:[:name | 
   247 	list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   274                             ((name endsWith:'/..') and:[list directory pathName = currentDir]) not
   248 	top open
   275                         ].
   249 
   276         list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   250     example (block moving up AND show all .rc-files only):
   277         top open
   251 
   278 
   252 	|top v list currentDir|
   279     do not allow changing up AND show all .rc-files only:
   253 
   280     (but allow going down)
   254 	currentDir := '.' asFilename pathName.
   281 
   255 
   282         |top v list currentDir|
   256 	top := StandardSystemView new.
   283 
   257 	top extent:(300 @ 200).
   284         currentDir := '.' asFilename pathName.
   258 	v := ScrollableView for:FileSelectionList in:top.
   285 
   259 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   286         top := StandardSystemView new.
   260 	list := v scrolledView.
   287         top extent:(300 @ 200).
   261 	list pattern:'*.rc'.
   288         v := ScrollableView for:FileSelectionList in:top.
   262 	list matchBlock:[:name |  
   289         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   263 			    ((name endsWith:'/..') and:[list directory pathName = currentDir]) not
   290         list := v scrolledView.
   264 			].
   291         list pattern:'*.rc'.
   265 	list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   292         list matchBlock:[:name |  
   266 	top open
   293                             ((name endsWith:'/..') and:[list directory pathName = currentDir]) not
   267 
   294                         ].
   268     example (show only .rc-files in current directory):
   295         list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   269 
   296         top open
   270 	|top v list currentDir|
   297 
   271 
   298     show only .rc-files in current directory:
   272 	currentDir := '.' asFilename pathName.
   299 
   273 
   300         |top v list currentDir|
   274 	top := StandardSystemView new.
   301 
   275 	top extent:(300 @ 200).
   302         currentDir := '.' asFilename pathName.
   276 	v := ScrollableView for:FileSelectionList in:top.
   303 
   277 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   304         top := StandardSystemView new.
   278 	list := v scrolledView.
   305         top extent:(300 @ 200).
   279 	list pattern:'*.rc'.
   306         v := ScrollableView for:FileSelectionList in:top.
   280 	list matchBlock:[:name | 
   307         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   281 			    name asFilename isDirectory not
   308         list := v scrolledView.
   282 			].
   309         list pattern:'*.rc'.
   283 	list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   310         list matchBlock:[:name | 
   284 	top open
   311                             name asFilename isDirectory not
   285 
   312                         ].
   286     example (show only h*-files in /etc; dont allow directory changes):
   313         list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   287 
   314         top open
   288 	|top v list|
   315 
   289 
   316     show only h*-files in /etc; dont allow directory changes:
   290 	top := StandardSystemView new.
   317 
   291 	top extent:(300 @ 200).
   318         |top v list|
   292 	v := ScrollableView for:FileSelectionList in:top.
   319 
   293 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   320         top := StandardSystemView new.
   294 	list := v scrolledView.
   321         top extent:(300 @ 200).
   295 	list directory:'/etc'.
   322         v := ScrollableView for:FileSelectionList in:top.
   296 	list pattern:'h*'.
   323         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   297 	list matchBlock:[:name | name printNL.
   324         list := v scrolledView.
   298 			    name asFilename isDirectory not
   325         list directory:'/etc'.
   299 			].
   326         list pattern:'h*'.
   300 	list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   327         list matchBlock:[:name | name printNL.
   301 	top open
   328                             name asFilename isDirectory not
   302 
   329                         ].
   303     example (only allow changing into directories below the current one; i.e. not up;
   330         list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   304     but show it)
   331         top open
   305 
   332 
   306 	|top v list here|
   333     only allow changing into directories below the current one; i.e. not up;
   307 
   334     but show it
   308 	top := StandardSystemView new.
   335 
   309 	top extent:(300 @ 200).
   336         |top v list here|
   310 	v := ScrollableView for:FileSelectionList in:top.
   337 
   311 	v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   338         top := StandardSystemView new.
   312 	list := v scrolledView.
   339         top extent:(300 @ 200).
   313 	list directoryChangeCheckBlock:[:dirPath |
   340         v := ScrollableView for:FileSelectionList in:top.
   314 			dirPath asFilename pathName
   341         v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   315 			    startsWith:Filename currentDirectory pathName].
   342         list := v scrolledView.
   316 	list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
   343         list directoryChangeCheckBlock:[:dirPath |
   317 	top open
   344                         dirPath asFilename pathName
       
   345                             startsWith:Filename currentDirectory pathName].
       
   346         list action:[:index | Transcript showCr:'you selected: ' , list selectionValue].
       
   347         top open
       
   348 
       
   349 
       
   350     living in a box:
       
   351 
       
   352         |box listView|
       
   353 
       
   354         box := Dialog new.
       
   355         box addTextLabel:'which file ?'.
       
   356 
       
   357         listView := box 
       
   358                         addListBoxOn:nil 
       
   359                         class:FileSelectionList
       
   360                         withNumberOfLines:10 
       
   361                         hScrollable:false 
       
   362                         vScrollable:true.
       
   363 
       
   364         box addAbortButton; addOkButton.
       
   365         box open.
       
   366         box accepted ifTrue:[
       
   367             Transcript showCr:listView selectedPathname
       
   368         ]
       
   369 
       
   370 
       
   371     living in a box (local files only, no directory change allowed):
       
   372 
       
   373         |box listView|
       
   374 
       
   375         box := Dialog new.
       
   376         box addTextLabel:'which file ?'.
       
   377 
       
   378         listView := box 
       
   379                         addListBoxOn:nil 
       
   380                         class:FileSelectionList
       
   381                         withNumberOfLines:10 
       
   382                         hScrollable:false 
       
   383                         vScrollable:true.
       
   384 
       
   385         listView ignoreDirectories:true.
       
   386         listView ignoreParentDirectory:true.
       
   387 
       
   388         box addAbortButton; addOkButton.
       
   389         box open.
       
   390         box accepted ifTrue:[
       
   391             Transcript showCr:listView selectedPathname
       
   392         ]
       
   393 
       
   394 
       
   395     living in a box (local files only; immediately show owner in another field):
       
   396 
       
   397         |box listView lbl|
       
   398 
       
   399         box := Dialog new.
       
   400         box addTextLabel:'which file ?'.
       
   401 
       
   402         listView := box 
       
   403                         addListBoxOn:nil 
       
   404                         class:FileSelectionList
       
   405                         withNumberOfLines:10 
       
   406                         hScrollable:false 
       
   407                         vScrollable:true.
       
   408 
       
   409         lbl := box addTextLabel:''.
       
   410         lbl adjust:#left.
       
   411 
       
   412         listView fileSelectAction:[:index |
       
   413             |ownerId owner|
       
   414 
       
   415             ownerId := listView selectedPathname asFilename info at:#uid.
       
   416             ownerId == OperatingSystem getUserID ifTrue:[
       
   417                 lbl label:('one of yours').
       
   418             ] ifFalse:[
       
   419                 owner := OperatingSystem getUserNameFromID:ownerId.
       
   420                 lbl label:(owner , '''s property').
       
   421             ]
       
   422         ].
       
   423 
       
   424         listView directorySelectAction:[:index |
       
   425             |ownerId owner|
       
   426 
       
   427             ownerId := listView selectedPathname asFilename info at:#uid.
       
   428             ownerId == OperatingSystem getUserID ifTrue:[
       
   429                 lbl label:('your files there').
       
   430             ] ifFalse:[
       
   431                 owner := OperatingSystem getUserNameFromID:ownerId.
       
   432                 lbl label:(owner , '''s files there').
       
   433             ]    
       
   434         ].
       
   435 
       
   436         box addAbortButton; addOkButton.
       
   437         box open.
       
   438         box accepted ifTrue:[
       
   439             Transcript showCr:listView selectedPathname
       
   440         ]
   318 "
   441 "
   319 ! !
   442 ! !
   320 
   443 
   321 !FileSelectionList methodsFor:'accessing-behavior'!
   444 !FileSelectionList methodsFor:'accessing-behavior'!
   322 
   445 
   339      a directory change is legal."
   462      a directory change is legal."
   340 
   463 
   341     directoryChangeCheckBlock := aBlock
   464     directoryChangeCheckBlock := aBlock
   342 !
   465 !
   343 
   466 
       
   467 directorySelectAction:aBlock
       
   468     "set the action to be performed when a directory is selected.
       
   469      Useful if someone else wants to show additional information
       
   470      (readable/owner ...) somewhere."
       
   471 
       
   472     directorySelectAction := aBlock
       
   473 
       
   474     "Created: 18.4.1996 / 18:45:13 / cg"
       
   475 !
       
   476 
       
   477 fileSelectAction:aBlock
       
   478     "set the action to be performed when a file is selected.
       
   479      Useful if someone else wants to show additional information
       
   480      (readable/owner ...) somewhere."
       
   481 
       
   482     fileSelectAction := aBlock
       
   483 
       
   484     "Created: 18.4.1996 / 18:45:24 / cg"
       
   485 !
       
   486 
   344 ignoreDirectories:aBoolean
   487 ignoreDirectories:aBoolean
   345     "set/clear the flag which controls if directories are ignored
   488     "set/clear the flag which controls if directories are ignored
   346      (i.e. hidden). The default is false (i.e. dirs are shown)"
   489      (i.e. hidden). The default is false (i.e. dirs are shown)"
   347 
   490 
   348     ignoreDirectories := aBoolean
   491     ignoreDirectories := aBoolean
       
   492 !
       
   493 
       
   494 ignoreFiles:aBoolean
       
   495     "set/clear the flag which controls if plain files are ignored
       
   496      (i.e. hidden). The default is false (i.e. they are shown)"
       
   497 
       
   498     ignoreFiles := aBoolean
       
   499 
       
   500     "Created: 18.4.1996 / 18:48:43 / cg"
       
   501     "Modified: 18.4.1996 / 18:49:23 / cg"
   349 !
   502 !
   350 
   503 
   351 ignoreParentDirectory:aBoolean
   504 ignoreParentDirectory:aBoolean
   352     "set/clear the flag which controls if the parent directory (..)
   505     "set/clear the flag which controls if the parent directory (..)
   353      is shown in the list. The default is false (i.e. show it)"
   506      is shown in the list. The default is false (i.e. show it)"
   516                 directoryChangeAction notNil ifTrue:[
   669                 directoryChangeAction notNil ifTrue:[
   517                     directoryChangeAction value:self selection
   670                     directoryChangeAction value:self selection
   518                 ] ifFalse:[
   671                 ] ifFalse:[
   519                     self changeDirectory
   672                     self changeDirectory
   520                 ]
   673                 ]
       
   674             ] ifFalse:[
       
   675                 directorySelectAction notNil ifTrue:[
       
   676                     directorySelectAction value:self selection
       
   677                 ]
   521             ]
   678             ]
   522         ] ifFalse:[
   679         ] ifFalse:[
   523             realAction notNil ifTrue:[
   680             realAction notNil ifTrue:[
   524                 realAction value:self selection
   681                 realAction value:self selection
       
   682             ].
       
   683             fileSelectAction notNil ifTrue:[
       
   684                 fileSelectAction value:self selection
   525             ]
   685             ]
   526         ]
   686         ]
   527     ]
   687     ]
   528 
   688 
   529     "Modified: 5.3.1996 / 02:37:58 / cg"
   689     "Modified: 18.4.1996 / 18:44:30 / cg"
   530 !
   690 !
   531 
   691 
   532 sizeChanged:how
   692 sizeChanged:how
   533     "redraw marks if any"
   693     "redraw marks if any"
   534 
   694 
   541 !FileSelectionList methodsFor:'initialization'!
   701 !FileSelectionList methodsFor:'initialization'!
   542 
   702 
   543 initialize
   703 initialize
   544     directory := FileDirectory currentDirectory.
   704     directory := FileDirectory currentDirectory.
   545     stayInDirectory := ignoreParentDirectory := ignoreDirectories := false.
   705     stayInDirectory := ignoreParentDirectory := ignoreDirectories := false.
   546     quickDirectoryChange := false.
   706     ignoreFiles := quickDirectoryChange := false.
   547     markDirectories := true.
   707     markDirectories := true.
   548     super initialize.
   708     super initialize.
   549 
   709 
   550     pattern := '*'.
   710     pattern := '*'.
   551     self initializeAction.
   711     self initializeAction.
   556      (FileSelectionList new directory:'/etc') open
   716      (FileSelectionList new directory:'/etc') open
   557      (ScrollableView for:FileSelectionList) open
   717      (ScrollableView for:FileSelectionList) open
   558      (HVScrollableView for:FileSelectionList) open
   718      (HVScrollableView for:FileSelectionList) open
   559     "
   719     "
   560 
   720 
   561     "Modified: 4.3.1996 / 17:36:29 / cg"
   721     "Modified: 18.4.1996 / 18:49:19 / cg"
   562 !
   722 !
   563 
   723 
   564 initializeAction
   724 initializeAction
   565     "setup action as: selections in list get forwarded to enterfield if not 
   725     "setup action as: selections in list get forwarded to enterfield if not 
   566      a directory; otherwise directory is changed"
   726      a directory; otherwise directory is changed"
   696                             fileTypes add:type
   856                             fileTypes add:type
   697                         ]
   857                         ]
   698                     ]
   858                     ]
   699                 ]
   859                 ]
   700             ] ifFalse:[
   860             ] ifFalse:[
   701                 matching := true.
   861                 ignoreFiles ifFalse:[
   702 
   862                     matching := true.
   703                 (pattern isNil 
   863 
   704                 or:[pattern isEmpty]) ifFalse:[
   864                     (pattern isNil 
   705                     pattern = '*' ifFalse:[
   865                     or:[pattern isEmpty]) ifFalse:[
   706                         (pattern includes:$;) ifTrue:[
   866                         pattern = '*' ifFalse:[
   707                             patternList := pattern asCollectionOfSubstringsSeparatedBy:$;.
   867                             (pattern includes:$;) ifTrue:[
   708                             matching := (patternList findFirst:[:subPattern | subPattern match:name]) ~~ 0.
   868                                 patternList := pattern asCollectionOfSubstringsSeparatedBy:$;.
   709                         ] ifFalse:[
   869                                 matching := (patternList findFirst:[:subPattern | subPattern match:name]) ~~ 0.
   710                             matching := pattern match:name
   870                             ] ifFalse:[
       
   871                                 matching := pattern match:name
       
   872                             ]
   711                         ]
   873                         ]
       
   874                     ].
       
   875                                     
       
   876                     matching ifTrue:[
       
   877                         newList add:name.
       
   878                         fileTypes add:type
   712                     ]
   879                     ]
   713                 ].
       
   714                                 
       
   715                 matching ifTrue:[
       
   716                     newList add:name.
       
   717                     fileTypes add:type
       
   718                 ]
   880                 ]
   719             ].
   881             ].
   720         ].
   882         ].
   721         index := index + 1
   883         index := index + 1
   722     ].
   884     ].
   723     super list:newList.
   885     super list:newList.
   724 
   886 
   725     self cursor:oldCursor.
   887     self cursor:oldCursor.
       
   888 
       
   889     "Modified: 18.4.1996 / 18:49:48 / cg"
   726 !
   890 !
   727 
   891 
   728 visibleLineNeedsSpecialCare:visLineNr
   892 visibleLineNeedsSpecialCare:visLineNr
   729     |l|
   893     |l|
   730 
   894 
   760 ! !
   924 ! !
   761 
   925 
   762 !FileSelectionList class methodsFor:'documentation'!
   926 !FileSelectionList class methodsFor:'documentation'!
   763 
   927 
   764 version
   928 version
   765     ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.26 1996-03-05 01:38:29 cg Exp $'
   929     ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.27 1996-04-19 11:26:09 cg Exp $'
   766 ! !
   930 ! !