tree presentation: displayblock and childrenblock

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

tree presentation: displayblock and childrenblock

Nicolai Hess
Why does a displayblock affect the arguments used for accessing the
children of the nodes?

The following code creates a TreePresentation from the current working Directory:

    browser := GLMTabulator new.
    browser
        column: #tree;
        column: #text.
    browser transmit
        to: #tree;
        andShow: [ :a |
                    a tree
                        title: 'FS';
                        "display: [ :item | item basename ];"
                        children: [ :item |
                                    item isDirectory
                                        ifFalse: [ #() ]
                                        ifTrue: [ item children ] ] ].
    browser openOn: FileSystem disk workingDirectory.

As I don't want to see the FileReference printString, but the
name of the File, the first thing I tried is a displayblock like
the commented line above.

But after this change the children block does not work anymore.
The item it calls #isDirectory on, is not the FileSystem entry but the
name returned by the display block.

#format: instead of #display:  works:

    browser := GLMTabulator new.
    browser
        column: #tree;
        column: #text.
    browser transmit
        to: #tree;
        andShow: [ :a |
                    a tree
                        title: 'FS';
                        format: [ :item | item basename ];
                        children: [ :item |
                                    item isDirectory
                                        ifFalse: [ #() ]
                                        ifTrue: [ item children ] ] ].
    browser openOn: FileSystem disk workingDirectory

May examples from GLMBasicExamples are using #display: , thats why
I tried this first. What is the intention to use
the display block for accessing the children?

nicolai






_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: tree presentation: displayblock and childrenblock

Andrei Chis
Hi Nicolai,

All glamour browser open on a model object. The display block is used to extract from that model object the actual object that would be displayed. 
In the case of a tree presentation the display block should return the initial roots of three. So you can open the browser on any object, and then the display block would get that object as a parameter and return a list of objects that would be used as the roots of the tree.

For example, you could write 'browser openOn: FileSystem disk' and then have a display block that extracts the working directory from the file system (display: [ :filesystem | filesystem workingDirectory ];)
The whole example would look like:

   browser := GLMTabulator new.
    browser
        column: #tree;
        column: #text.
    browser transmit
        to: #tree;
        andShow: [ :a | 
                    a tree
                        title: 'FS';
display: [ :filesystem | filesystem workingDirectory ];
                        format: [ :item | item basename ];
                        children: [ :item | 
                                    item isDirectory
                                        ifFalse: [ #() ]
                                        ifTrue: [ item children ] ] ].
    browser openOn: FileSystem disk 


Cheers,
Andrei


On Tue, Feb 10, 2015 at 5:02 PM, Nicolai Hess <[hidden email]> wrote:
Why does a displayblock affect the arguments used for accessing the
children of the nodes?

The following code creates a TreePresentation from the current working Directory:

    browser := GLMTabulator new.
    browser
        column: #tree;
        column: #text.
    browser transmit
        to: #tree;
        andShow: [ :a |
                    a tree
                        title: 'FS';
                        "display: [ :item | item basename ];"
                        children: [ :item |
                                    item isDirectory
                                        ifFalse: [ #() ]
                                        ifTrue: [ item children ] ] ].
    browser openOn: FileSystem disk workingDirectory.

As I don't want to see the FileReference printString, but the
name of the File, the first thing I tried is a displayblock like
the commented line above.

But after this change the children block does not work anymore.
The item it calls #isDirectory on, is not the FileSystem entry but the
name returned by the display block.

#format: instead of #display:  works:

    browser := GLMTabulator new.
    browser
        column: #tree;
        column: #text.
    browser transmit
        to: #tree;
        andShow: [ :a |
                    a tree
                        title: 'FS';
                        format: [ :item | item basename ];
                        children: [ :item |
                                    item isDirectory
                                        ifFalse: [ #() ]
                                        ifTrue: [ item children ] ] ].
    browser openOn: FileSystem disk workingDirectory

May examples from GLMBasicExamples are using #display: , thats why
I tried this first. What is the intention to use
the display block for accessing the children?

nicolai






_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev



_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: tree presentation: displayblock and childrenblock

Nicolai Hess
2015-02-10 17:38 GMT+01:00 Andrei Chis <[hidden email]>:
Hi Nicolai,

All glamour browser open on a model object. The display block is used to extract from that model object the actual object that would be displayed. 
In the case of a tree presentation the display block should return the initial roots of three. So you can open the browser on any object, and then the display block would get that object as a parameter and return a list of objects that would be used as the roots of the tree.

For example, you could write 'browser openOn: FileSystem disk' and then have a display block that extracts the working directory from the file system (display: [ :filesystem | filesystem workingDirectory ];)
The whole example would look like:

   browser := GLMTabulator new.
    browser
        column: #tree;
        column: #text.
    browser transmit
        to: #tree;
        andShow: [ :a | 
                    a tree
                        title: 'FS';
display: [ :filesystem | filesystem workingDirectory ];
                        format: [ :item | item basename ];
                        children: [ :item | 
                                    item isDirectory
                                        ifFalse: [ #() ]
                                        ifTrue: [ item children ] ] ].
    browser openOn: FileSystem disk 


Cheers,
Andrei


Thank you for the explanation Andrei,
I thought the display block is used to convert the data to a displayable representation.
But if it is used to extract the data, then the described behavior makes sense of course.


nicolai
 


On Tue, Feb 10, 2015 at 5:02 PM, Nicolai Hess <[hidden email]> wrote:
Why does a displayblock affect the arguments used for accessing the
children of the nodes?

The following code creates a TreePresentation from the current working Directory:

    browser := GLMTabulator new.
    browser
        column: #tree;
        column: #text.
    browser transmit
        to: #tree;
        andShow: [ :a |
                    a tree
                        title: 'FS';
                        "display: [ :item | item basename ];"
                        children: [ :item |
                                    item isDirectory
                                        ifFalse: [ #() ]
                                        ifTrue: [ item children ] ] ].
    browser openOn: FileSystem disk workingDirectory.

As I don't want to see the FileReference printString, but the
name of the File, the first thing I tried is a displayblock like
the commented line above.

But after this change the children block does not work anymore.
The item it calls #isDirectory on, is not the FileSystem entry but the
name returned by the display block.

#format: instead of #display:  works:

    browser := GLMTabulator new.
    browser
        column: #tree;
        column: #text.
    browser transmit
        to: #tree;
        andShow: [ :a |
                    a tree
                        title: 'FS';
                        format: [ :item | item basename ];
                        children: [ :item |
                                    item isDirectory
                                        ifFalse: [ #() ]
                                        ifTrue: [ item children ] ] ].
    browser openOn: FileSystem disk workingDirectory

May examples from GLMBasicExamples are using #display: , thats why
I tried this first. What is the intention to use
the display block for accessing the children?

nicolai






_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev




_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: tree presentation: displayblock and childrenblock

Tudor Girba-2
Hi,

display: is a transformation used to convert the input object into an object that will act as a model for the presentation.

Cheers,
Doru



On Tue, Feb 10, 2015 at 7:55 PM, Nicolai Hess <[hidden email]> wrote:
2015-02-10 17:38 GMT+01:00 Andrei Chis <[hidden email]>:
Hi Nicolai,

All glamour browser open on a model object. The display block is used to extract from that model object the actual object that would be displayed. 
In the case of a tree presentation the display block should return the initial roots of three. So you can open the browser on any object, and then the display block would get that object as a parameter and return a list of objects that would be used as the roots of the tree.

For example, you could write 'browser openOn: FileSystem disk' and then have a display block that extracts the working directory from the file system (display: [ :filesystem | filesystem workingDirectory ];)
The whole example would look like:

   browser := GLMTabulator new.
    browser
        column: #tree;
        column: #text.
    browser transmit
        to: #tree;
        andShow: [ :a | 
                    a tree
                        title: 'FS';
display: [ :filesystem | filesystem workingDirectory ];
                        format: [ :item | item basename ];
                        children: [ :item | 
                                    item isDirectory
                                        ifFalse: [ #() ]
                                        ifTrue: [ item children ] ] ].
    browser openOn: FileSystem disk 


Cheers,
Andrei


Thank you for the explanation Andrei,
I thought the display block is used to convert the data to a displayable representation.
But if it is used to extract the data, then the described behavior makes sense of course.


nicolai
 


On Tue, Feb 10, 2015 at 5:02 PM, Nicolai Hess <[hidden email]> wrote:
Why does a displayblock affect the arguments used for accessing the
children of the nodes?

The following code creates a TreePresentation from the current working Directory:

    browser := GLMTabulator new.
    browser
        column: #tree;
        column: #text.
    browser transmit
        to: #tree;
        andShow: [ :a |
                    a tree
                        title: 'FS';
                        "display: [ :item | item basename ];"
                        children: [ :item |
                                    item isDirectory
                                        ifFalse: [ #() ]
                                        ifTrue: [ item children ] ] ].
    browser openOn: FileSystem disk workingDirectory.

As I don't want to see the FileReference printString, but the
name of the File, the first thing I tried is a displayblock like
the commented line above.

But after this change the children block does not work anymore.
The item it calls #isDirectory on, is not the FileSystem entry but the
name returned by the display block.

#format: instead of #display:  works:

    browser := GLMTabulator new.
    browser
        column: #tree;
        column: #text.
    browser transmit
        to: #tree;
        andShow: [ :a |
                    a tree
                        title: 'FS';
                        format: [ :item | item basename ];
                        children: [ :item |
                                    item isDirectory
                                        ifFalse: [ #() ]
                                        ifTrue: [ item children ] ] ].
    browser openOn: FileSystem disk workingDirectory

May examples from GLMBasicExamples are using #display: , thats why
I tried this first. What is the intention to use
the display block for accessing the children?

nicolai






_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev




_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev




--

"Every thing has its own flow"

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev