[Seaside] Generalizing WATree Update--with files selectable.

John Chludzinski john.chludzinski at gmail.com
Thu Aug 19 15:37:45 UTC 2010


Tim,

I plugged the code into "Functional Tests":

WATreeFunctionalTest>>initialize
super initialize.
tree := WATree new
 root: (DirTreeNode on: 'C:\cygwin\');
labelBlock: [ :node | node getLabel ];
childrenBlock: [ :node | node children ];
 "root: Collection;
labelBlock: [ :class | class name ];
childrenBlock: [ :class | class subclasses ];
selectBlock: [ :class | selected := class name ];
canSelectBlock: [ :class | class subclasses notEmpty ];"
 yourself

The code is the absolute minimal code needed to support a directory tree via
WATree.  BUT it WORKS!

On Thu, Aug 19, 2010 at 11:25 AM, John Chludzinski <
john.chludzinski at gmail.com> wrote:

> Tim, I believe something as simple as the class below would solve your
> problem without modifying the WATree implementation (much simpler than
> bending CFIleDirectoryTreeItems to your will):
>
>
> Object subclass: #DirTreeNode
> instanceVariableNames: 'children name entry'
> classVariableNames: ''
>  poolDictionaries: ''
> category: 'Misc'!
>
> !DirTreeNode methodsFor: 'accessing' stamp: 'jtc'!
> children
>
> self isLeaf ifTrue: [ ^ nil ].
> children
>  ifNil: [
> children := OrderedCollection new.
> name entries do: [ :entry |
>  children add: ((self class on: entry fullName) entry: entry) ]
> ].
>
>  ^ children! !
>
> !DirTreeNode methodsFor: 'accessing' stamp: 'jtc'!
> entry
>
> ^ entry! !
>
> !DirTreeNode methodsFor: 'accessing' stamp: 'jtc7'!
> entry: e
>
> entry := e! !
>
> !DirTreeNode methodsFor: 'accessing' stamp: 'jtc'!
> getLabel
>
> ^ (name pathName findTokens: '\') last! !
>
> !DirTreeNode methodsFor: 'accessing' stamp: 'jtc'!
> isLeaf
>
> entry ifNil: [ ^ false ].
>  ^ self entry isDirectory not! !
>
> !DirTreeNode methodsFor: 'accessing' stamp: 'jtc'!
> name: n
>
>  name := n! !
>
> "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
>
> DirTreeNode class
>  instanceVariableNames: ''!
>
> !DirTreeNode class methodsFor: 'instance creation' stamp: 'jtc'!
> on: pathString
>
> ^ self new
> name: (FileDirectory on: pathString)! !
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20100819/7509e683/attachment.htm


More information about the seaside mailing list