Nesting Commands

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

Nesting Commands

Günther Schmidt
Hi,

is there a way to 'nest' Commands/CommandDescriptions into each other,
to somehow chain them?

Günther


Reply | Threaded
Open this post in threaded view
|

Re: Nesting Commands

altodorado
You could have a CommandCollection object that contains a collection of
Commands. The protocol you have to conform to is #forwardTo: and
#queryCommand:. So, you could simply forwardsthe #queryCommand: message
to each Command inside of your collection. The same goes for the
#forwardTo:. For example:

forwardTo: aReceiver
    self commandCollection do: [:eachCommand | eachCommand forwardTo:
aReceiver]

Or you could have a LinkedCommand that has instance variable for the
next Command. And you could do the same as above. Just keep the same
protocol.

I recently blogged on the Command framework in Dolphin:
http://www.blainebuxton.com/weblog/2005/09/dolphins-command-framework.html
http://www.blainebuxton.com/weblog/2005/09/re-dolphins-command-framework.html

Let me know if this helps. Feel free to email me.
--
Blaine Buxton, Mad Scientist In Training
"You're as beautiful as your thoughts"-EW&F
http://www.blainebuxton.com

Günther Schmidt wrote:
> Hi,
>
> is there a way to 'nest' Commands/CommandDescriptions into each other,
> to somehow chain them?
>
> Günther


Reply | Threaded
Open this post in threaded view
|

Re: Nesting Commands

Günther Schmidt
Hi Blaine,

actually your blog has got me started on this.

I've solved the problem by now, not with a Collection Object though, I
think it should be strictly a chain.

So I put one command description object into the other, with the latest
one calling the value of the one before it and taking the result of that
as its single parameter.

The command descriptions in my case aren't properly forwarded, but, at
the moment, simply copied from the previous element in the chain.

Command isEnabled doesn't work this way yet either, but that's because I
haven't figured out yet how to implement it properly.

I think the original unmodified Command framework by OA already provides
this, I just haven't quite figured it out yet.

BTW I would be nice to have you back at the irc channel.


Günther