set pathname ...
--- a/FileSelectionTree.st Mon Aug 11 13:02:03 1997 +0200
+++ b/FileSelectionTree.st Mon Aug 11 13:02:30 1997 +0200
@@ -160,6 +160,40 @@
+ example associated with a FileSelectionList
+ [exBegin]
+ |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 directoriesOnly).
+ 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
+ [exEnd]
+
+
+
a more complex example
[exBegin]
|action top tree slvw file tgD tgF button hzPn|
@@ -246,18 +280,29 @@
aPathname. The pathname must be a directory otherwise the root directory
is set to nil.
"
- |root|
+ |root dir path keep|
+
+ (aPathname notNil and:[(path := aPathname asFilename) isDirectory]) ifFalse:[
+ model root:nil.
+ ^ self selection:nil
+ ].
+ (dir := self directory) notNil ifTrue:[
+ dir := dir asFilename.
+ keep := path pathName = dir directory pathName.
+ ] ifFalse:[
+ keep := false
+ ].
self selection:nil.
- (aPathname notNil and:[aPathname asFilename isDirectory]) ifFalse:[
- model root:nil.
- ^ self
+ root := self itemClass pathName:path.
+ model root:root keepRoot:keep.
+ model expand:root.
+
+ keep ifTrue:[
+ self selectPathname:(dir pathName)
].
- root := self itemClass pathName:aPathname.
- model root:root.
- model expand:root.
!
itemClass
@@ -280,6 +325,17 @@
].
].
+!
+
+pathnameAtIndex:anIndex
+ "returns pathname at an index or nil
+ "
+ |node|
+
+ (node := self nodeAtIndex:anIndex) notNil ifTrue:[
+ ^ node pathName
+ ].
+ ^ nil
! !
!FileSelectionTree methodsFor:'drawing basics'!
@@ -328,22 +384,6 @@
! !
-!FileSelectionTree methodsFor:'queries'!
-
-canSelect:aFilename
- "returns true if a file is selectable dependant on
- filter ...
- "
- |root|
-
- (itemClass isSelectableFile:aFilename) ifTrue:[
- (root := self directory) notNil ifTrue:[
- ^ aFilename asString startsWith:root
- ]
- ].
- ^ false
-! !
-
!FileSelectionTree methodsFor:'selection'!
selectPathname:aPath
@@ -351,7 +391,7 @@
"
|node comp rdwNd path|
- (self canSelect:aPath) ifFalse:[
+ (aPath notNil and:[aPath asFilename exists]) ifFalse:[
^ self selection:nil
].
((path := aPath asString) = self selectedPathname) ifTrue:[
@@ -402,5 +442,5 @@
!FileSelectionTree class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/FileSelectionTree.st,v 1.2 1997-08-07 13:28:47 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/FileSelectionTree.st,v 1.3 1997-08-11 11:02:30 ca Exp $'
! !