--- a/AbstractDirectoryBrowser.st Wed Aug 21 17:24:03 2019 +0200
+++ b/AbstractDirectoryBrowser.st Wed Aug 21 17:24:13 2019 +0200
@@ -62,6 +62,10 @@
"Created: / 23-07-2018 / 12:49:38 / Stefan Vogel"
!
+fileList
+ self subclassResponsibility
+!
+
updateToExternFileHolderLock
updateToExternFileHolderLock isNil ifTrue:[
updateToExternFileHolderLock := self class newLock.
@@ -107,60 +111,6 @@
^ matching
"Created: / 02-05-2019 / 18:58:30 / Claus Gittinger"
-!
-
-findNextFileMatching:aGLOBPattern startingAt:anItemOrNil
- "search files which match aGLOBPattern."
-
- |searchFolder searchIndex stack|
-
- stack := OrderedCollection new.
- anItemOrNil isRootItem ifFalse:[
- |i|
-
- i := anItemOrNil.
- [i isRootItem] whileFalse:[
- stack addFirst:(i parent -> (i parent children indexOf:i)).
- i := i parent.
- ].
- ].
-
- anItemOrNil isDirectory ifTrue:[
- searchFolder := anItemOrNil.
- searchIndex := 0.
- ] ifFalse:[
- searchFolder := anItemOrNil parent.
- searchIndex := anItemOrNil parent children indexOf:anItemOrNil.
- ].
- stack add:(searchFolder -> searchIndex).
-
- [stack notEmpty] whileTrue:[
- |work children|
-
- work := stack removeLast.
- searchFolder := work key.
- searchIndex := work value.
-
- children := searchFolder children.
- searchIndex+1 to:(children size) doWithExit:[:childIndex :exit|
- |child|
-
- child := children at:childIndex.
-Transcript showCR:'search %1' with:child pathName.
- child isDirectory ifFalse:[
- (aGLOBPattern match:child baseName) ifTrue:[
- ^ child pathName asFilename
- ].
- ] ifTrue:[
- stack add:(searchFolder -> childIndex).
- stack add:(child -> 0).
- exit value:nil.
- ]
- ].
- ].
- ^ nil
-
- "Created: / 02-05-2019 / 20:39:58 / Claus Gittinger"
! !
!AbstractDirectoryBrowser methodsFor:'drag & drop'!
@@ -298,15 +248,97 @@
!
findAndSelectNextFileMatching:aGLOBPattern
+ self
+ findAndSelectNextFileMatching:aGLOBPattern
+ under:(self theSingleSelectedItemOrNil ? self fileList root)
+ searchInfoInto:nil
+!
+
+findAndSelectNextFileMatching:aGLOBPattern under:topDirectoryItem
+ self findAndSelectNextFileMatching:aGLOBPattern under:topDirectoryItem searchInfoInto:nil
+!
+
+findAndSelectNextFileMatching:aGLOBPattern under:topDirectoryItem searchInfoInto:aBlockOrNil
|fileOrNil|
- fileOrNil := self findNextFileMatching:aGLOBPattern
- startingAt:(self theSingleSelectedItemOrNil ? self fileList root).
+ fileOrNil := self findNextFileMatching:aGLOBPattern startingAt:topDirectoryItem searchInfoInto:aBlockOrNil.
self selectFiles:(fileOrNil isNil
ifTrue:[#()]
ifFalse:[{ fileOrNil }])
"Created: / 02-05-2019 / 20:43:41 / Claus Gittinger"
+!
+
+findNextFileMatching:aGLOBPattern startingAt:anItemOrNil
+ "search files which match aGLOBPattern in the tree."
+
+ ^ self findNextFileMatching:aGLOBPattern startingAt:anItemOrNil searchInfoInto:nil
+
+ "Created: / 02-05-2019 / 20:39:58 / Claus Gittinger"
+!
+
+findNextFileMatching:aGLOBPattern startingAt:anItemOrNil searchInfoInto:aBlockOrNil
+ "search files which match aGLOBPattern in the tree.
+ If not nil, aBlockOrNil is called whenever a new folder is searched (for visual feeedback)"
+
+ |searchFolder searchIndex stack|
+
+ stack := OrderedCollection new.
+ anItemOrNil isRootItem ifFalse:[
+ |i|
+
+ i := anItemOrNil.
+ [i isRootItem] whileFalse:[
+ stack addFirst:(i parent -> (i parent children indexOf:i)).
+ i := i parent.
+ ].
+ ].
+
+ anItemOrNil isDirectory ifTrue:[
+ searchFolder := anItemOrNil.
+ searchIndex := 0.
+ ] ifFalse:[
+ searchFolder := anItemOrNil parent.
+ searchIndex := anItemOrNil parent children indexOf:anItemOrNil.
+ ].
+
+ stack add:(searchFolder -> searchIndex).
+
+ [stack notEmpty] whileTrue:[
+ |work children|
+
+ work := stack removeLast.
+ searchFolder := work key.
+ searchIndex := work value.
+
+ (searchFolder pathName startsWith:'/Appl') ifTrue:[self halt].
+
+ aBlockOrNil notNil ifTrue:[aBlockOrNil value:searchFolder pathName].
+
+ children := searchFolder children.
+ searchIndex+1 to:(children size) doWithExit:[:childIndex :exit|
+ |child fn|
+
+ child := children at:childIndex.
+ Transcript showCR:'search %1' with:child pathName.
+ fn := child fileName.
+ fn isSymbolicLink ifFalse:[
+ fn isDirectory ifFalse:[
+ (aGLOBPattern match:fn baseName) ifTrue:[
+ ^ fn pathName asFilename
+ ].
+ ] ifTrue:[
+ "/ deeper, but remember to proceed here
+ stack add:(searchFolder -> childIndex).
+ stack add:(child -> 0).
+ exit value:nil.
+ ]
+ ]
+ ].
+ ].
+ ^ nil
+
+ "Created: / 02-05-2019 / 20:39:58 / Claus Gittinger"
! !
!AbstractDirectoryBrowser methodsFor:'selection'!