Hi all,
one more stupid question. I've been building a UI mockup happily quoting the sample that reads tree := (Iliad.Tree new) item: Object; childrenBlock: [:class | class subclasses]; contentsBlock: [:e :class | e text: class name] it works perfectly. Then I spent quite a long time getting stuff out of PG, decoding the XML to make it in objects and I finally have something I can use. It's anOrderedCollection of symbols (uuids, actually) that I will later turn into properly localized objects depending on what language the users has chosen. It looks like: An instance of OrderedCollection firstIndex: 8 lastIndex: 16 contents: [ [1]: #'1aa75482-4e61-11de-a0cb-e7dd9793c483' [2]: #'d39605ea-7929-11de-9575-839884ebf70c' [3]: #'d3973a46-7929-11de-b337-4fd741cce41e' [4]: #'d3984bca-7929-11de-a337-bb66b2b01db0' [5]: #'d39968f2-7929-11de-bb33-83f0278053f7' [6]: #'d39a6ebe-7929-11de-8ea2-5bd631a2b97f' [7]: #'d39c66b0-7929-11de-9f31-1fcdae4e56a0' [8]: #'d39d7e24-7929-11de-8f93-733ef5534d68' [9]: #'d39e76a8-7929-11de-ad21-73754236fffa' ] Now, my idea was to move up the mock a bit by showing the uuids. Note that in this case it's not really a tree, yet. It will probably get to be one, but even if it doesn't I'd rather have the same widget for all lists, so users do not have to learn too much stuff before they can use the app. Now, I probably need some sleep badly, but for the life of me I cannot figure out how to pass this collection to the tree and have it shown as a simple list. So while I wait for someone to shed light on my dumbness I'll go on with other parts of the code. Berto _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
Hi,
Since it's a tree widget, it expects an item of the tree to know its children. This part is done in #childrenBlock: The thing is that you're OrderedCollection is not a tree, so objects of the collection don't have children. So I don't think a tree widget is what you need, I would rather use a simple list in your case. Is there a reason why you want to use a tree widget? Cheers! Nico Le mardi 10 novembre 2009 à 08:46 +0200, Bèrto ëd Sèra a écrit : > Hi all, > > one more stupid question. I've been building a UI mockup happily > quoting the sample that reads > > tree := (Iliad.Tree new) > item: Object; > childrenBlock: [:class | class subclasses]; > contentsBlock: [:e :class | e text: class name] > > it works perfectly. Then I spent quite a long time getting stuff out > of PG, decoding the XML to make it in objects and I finally have > something I can use. It's anOrderedCollection of symbols (uuids, > actually) that I will later turn into properly localized objects > depending on what language the users has chosen. > > It looks like: > An instance of OrderedCollection > firstIndex: 8 > lastIndex: 16 > contents: [ > [1]: #'1aa75482-4e61-11de-a0cb-e7dd9793c483' > [2]: #'d39605ea-7929-11de-9575-839884ebf70c' > [3]: #'d3973a46-7929-11de-b337-4fd741cce41e' > [4]: #'d3984bca-7929-11de-a337-bb66b2b01db0' > [5]: #'d39968f2-7929-11de-bb33-83f0278053f7' > [6]: #'d39a6ebe-7929-11de-8ea2-5bd631a2b97f' > [7]: #'d39c66b0-7929-11de-9f31-1fcdae4e56a0' > [8]: #'d39d7e24-7929-11de-8f93-733ef5534d68' > [9]: #'d39e76a8-7929-11de-ad21-73754236fffa' > ] > > Now, my idea was to move up the mock a bit by showing the uuids. Note > that in this case it's not really a tree, yet. It will probably get to > be one, but even if it doesn't I'd rather have the same widget for all > lists, so users do not have to learn too much stuff before they can > use the app. > > Now, I probably need some sleep badly, but for the life of me I cannot > figure out how to pass this collection to the tree and have it shown > as a simple list. So while I wait for someone to shed light on my > dumbness I'll go on with other parts of the code. > > Berto > > > _______________________________________________ > help-smalltalk mailing list > [hidden email] > http://lists.gnu.org/mailman/listinfo/help-smalltalk _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk signature.asc (205 bytes) Download Attachment |
In reply to this post by Bèrto ëd Sèra
Le mardi 10 novembre 2009 à 08:46 +0200, Bèrto ëd Sèra a écrit :
> Note > that in this case it's not really a tree, yet. It will probably get to > be one, but even if it doesn't I'd rather have the same widget for all > lists, so users do not have to learn too much stuff before they can > use the app. But what's the point of using a tree widget to represent a list? Also, I think you can make a list and a tree feel the same with some css, list item won't be expandable, that's all. Nico _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk signature.asc (205 bytes) Download Attachment |
In reply to this post by Bèrto ëd Sèra
On Tue, 10 Nov 2009 08:46:10 +0200
Bèrto ëd Sèra <[hidden email]> wrote: > Hi all, > > one more stupid question. I've been building a UI mockup happily > quoting the sample that reads > > tree := (Iliad.Tree new) > item: Object; > childrenBlock: [:class | class subclasses]; > contentsBlock: [:e :class | e text: class name] I guess the main problem is that the above combination of Object and #subclasses leads to a tree of objects implementing the message #subclasses, while you have a collection (responding to #contents) and symbols (not responding to #contents). One way to get around this is to wrap your different objects into a thin decorator providing a common interface, so that the following would work: tree := (Iliad.Tree new) item: myTreeViewableCollectionOfLocalizableSymbols childrenBlock: [:item | item children ] contentsBlock: [:e :item | e text: item displayString ] I apologize for that looong name :-) Object subclass: TreeNodeHolder [ | model getter | class [ on: anObject getter: aBlock [ ^ self basicNew model: anObject; getter: aBlock; yourself ] ] children [ ^ getter value: model ] ] treeModel := TreeNodeHolder on: myTVCOLS getter: [:coll | coll collect: [:elt | TreeNodeHolder on: elt getter: [:sym | OrderedCollection new ] ]. tree := (Iliad.Tree new) item: treeModel childrenBlock: [:item | item children ] contentsBlock: [:e :item | e text: item displayString ] Mind you, this snippet was written with dangerously low blood sugar levels, so beware :-) You can also avoid a lot of the uglyness if your application classes implement a consistent interface for this purpose from the start. HTH s. _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
Free forum by Nabble | Edit this page |