eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'FileSelectionTree':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: FileSelectionTree


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--View
               |
               +--ListView
                  |
                  +--SelectionInListView
                     |
                     +--SelectionInTreeView
                        |
                        +--FileSelectionTree

Package:
stx:libwidg2
Category:
Views-Trees
Version:
rev: 1.44 date: 2021/08/14 09:00:14
user: cg
file: FileSelectionTree.st directory: libwidg2
module: stx stc-classLibrary: libwidg2

Description:


somewhat like a FileSelectionInList; but specialized for hierarchical (i.e. tree-like)
lists and adds the functions to show/hide subtrees.
Requires SelectionInTree as model and FileSelectionItem (or compatible) list entries.

You can define your own TreeItem instead of using the default class FileSelectionItem
by setting the class through to #itemClass:

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.

Class protocol:

constants
o  monitoringDelayTime
default delay time of monitoring task in seconds


Instance protocol:

accessing
o  changeDirectory: aPathname
change the root directory; try to reuse old hierarchy list and
the selection in case of a single selection. The pathname must
be a directory otherwise the root directory is set to nil

o  directory
get the full pathname of the root directory

o  directory: aPath
change the root directory of the selection tree to the full pathName,
aPath. The pathname must be a directory otherwise the root directory
is set to nil.

o  itemClass: anItemClass
set itemClass to be used

o  pathnameAtIndex: anIndex
returns pathname at an index or nil

accessing-monitoring
o  monitoring
returns true if monitor process is running

o  monitoring: aBoolean
enable or disable monitoring

o  monitoringDelayTime
delay time of monitoring task in seconds

o  monitoringDelayTime: seconds
delay time of monitoring task in seconds

drag & drop
o  dragObjectForNode: aNode
returns the dragable object for a node; could be redefined in subclass

initialization
o  destroy
(comment from inherited method)
unmap & destroy - make me invisible, destroy subviews then
make me unknown to the device

o  initialize
setup my model and set the default path to the current directory;
by default, multiple selection is disabled.

model
o  rootFromModel
update hierarchical list from root model

o  selectionFromModel
set the selection derived from the selectionHolder

o  selectionToModel
write selection to selection holder

private
o  fileName2node: aFile
file := self makeLegalFilename:aFile.

o  makeLegalFilename: aFile

o  monitorCycle
run monitor cycle

selection
o  selectPathname: aPath
set selection to a path

o  selectedNodeExpand: doExpand
collapse or expand selected node.
Redefined to show a busy cursor while reading dirs

o  selectedPathname
if there is a single selection, the full pathname of the selected
entry will be returned otherwise nil


Examples:


open a FileSelectionTree on current directory
|top scr|

top := StandardSystemView new label:'select'; extent:300@500.
scr := HVScrollableView for:FileSelectionTree origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
scr := scr scrolledView.

scr directory:'/'.
scr showDirectoryIndicator:true.
scr showRoot:false.
scr showLines:false.
scr allowDrag:true.
scr multipleSelectOk:true.

top open
open a FileSelectionTree using a model
|top scr model|

top := StandardSystemView new label:'select'; extent:300@500.
scr := HVScrollableView for:FileSelectionTree origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
scr := scr scrolledView.
model := (Filename currentDirectory asString) asValue.
scr rootHolder:model.
model inspect.

scr action:[:anIndex| Transcript showCR:anIndex.
                      Transcript showCR:scr selectedPathname.
           ].
top open
|top scr|

top := StandardSystemView new label:'select'; extent:300@500.
scr := HVScrollableView for:FileSelectionTree origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
scr := scr scrolledView.

scr directory:Filename currentDirectory.
scr selectionHolder:nil asValue.
scr selectionHolder inspect.
scr multipleSelectOk:true.

scr action:[:anIndex| Transcript showCR:anIndex.
                      Transcript showCR:scr selectedPathname.
           ].
top open
open a FileSelectionTree on root path; show directory indication (open/closed), no lines and not the root
|top scr|

top := StandardSystemView new label:'select'; extent:300@500.
scr := HVScrollableView for:FileSelectionTree origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
scr := scr scrolledView.
scr showDirectoryIndicator:true.
scr showLines:false.
scr showRoot:false.

scr directory:'/'.

scr action:[:anIndex| Transcript showCR:anIndex.
                      Transcript showCR:scr selectedPathname.
           ].
top open
open a FileSelectionTree on root path; showing only files
|top scr|

top := StandardSystemView new label:'select'; extent:300@500.
scr := HVScrollableView for:FileSelectionTree origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
scr := scr scrolledView.
scr itemClass:(FileSelectionItem filterClassForDirectoriesOnly).
scr directory:'/'.

scr action:[:anIndex| Transcript showCR:anIndex.
                      Transcript showCR:scr selectedPathname.
           ].
top open
open a FileSelectionTree on a specified path
|top scr|

top := StandardSystemView new label:'select'; extent:300@500.
scr := HVScrollableView for:FileSelectionTree origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
scr := scr scrolledView.
scr directory:'/'.
scr showLines:false.
scr action:[:anIndex| Transcript showCR:scr selectedPathname ].
scr doubleClickAction:[:anIndex| Transcript showCR:scr selectedPathname ].
top open
open a FileSelectionTree on a specified path; show or hide lines on doubleClick on a file (not a directory)
|top scr|

top := StandardSystemView new label:'select'; extent:300@500.
scr := HVScrollableView for:FileSelectionTree origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
scr := scr scrolledView.
scr directory:'/'.

scr action:[:anIndex| Transcript showCR:anIndex.
                      Transcript showCR:scr selectedPathname.
           ].
scr doubleClickAction:[:anIndex|
    |fn|
    fn := scr selectedPathname asFilename.
    fn isDirectory ifFalse:[
        scr showLines:(scr showLines not)
    ]
].
top open
example associated with a FileSelectionList
|top tree list field label|

top   := StandardSystemView new label:'select'; extent:600@600.
tree  := HVScrollableView for:FileSelectionTree origin:(0.0 @ 0.0) corner:(0.5 @ 1.0) in:top.
list  := HVScrollableView for:FileSelectionList origin:(0.5 @  25) corner:(1.0 @ 1.0) in:top.
label := Label origin:(0.5 @ 2) in:top.
label label:'pattern:'.
field := EditField origin:0.5@2 in:top.
field leftInset:(label preferredExtent x) + 5.
field width:1.0.
field editValue:'*'.
field crAction:[list pattern:field editValue].

tree  := tree scrolledView.
list  := list scrolledView.
list ignoreDirectories:true.
list pattern:(field editValue).

tree itemClass:(FileSelectionItem filterClassForDirectoriesOnly).
tree directory:(Filename homeDirectory).
tree showDirectoryIndicator:true.
list directory:(tree directory).

list action:[:index| Transcript showCR:'you selected: ' , list selectedPathname].
tree action:[:anIndex|
    list directory:(tree selectedPathname).
].
top open
a more complex example
|top listD listF field lbl inset|

top   := StandardSystemView new label:'select'; extent:600@600.
inset := 26.
listD := HVScrollableView for:FileSelectionTree origin:(0.0 @ inset) corner:(0.5 @ 1.0) in:top.
listF := HVScrollableView for:FileSelectionTree origin:(0.5 @ 0.0) corner:(1.0 @ 1.0) in:top.
listD := listD scrolledView.
listF := listF scrolledView.

listD itemClass:(FileSelectionItem filterClassForDirectoriesOnly).
listF itemClass:(FileSelectionItem filterClassForFilesOnly).
listD showDirectoryIndicator:true.
listD showLines:false.
listF showLines:false.
listF showRoot:false.

lbl := Label label:'directory:' in:top.
lbl origin:5 @ ((inset - lbl preferredExtent y) // 2).

field := FilenameEditField in:top.
field origin:(4 + lbl corner x) @ ((inset - field preferredExtent y) // 2).
field width:0.5.
field rightInset:(field origin x + 4).
field directoriesOnly.

field crAction:[|dir|
    dir := field editValue asFilename.

    (dir isDirectory and:[listD directory ~= dir pathName]) ifTrue:[
        listD changeDirectory:dir
    ]
].

listF action:[:anIndex||file|
    (file := listF selectedPathname) notNil ifTrue:[
        Transcript showCR:'selection: ', file
    ]
].

listD directory:(Filename homeDirectory).
field editValue:listD directory.

listD doubleClickAction:[:anIndex||path|
    path := listD selectedPathname.
    listF directory:path.
    path notNil ifTrue:[field editValue:path]
].
top open


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 06:30:30 GMT