|Is it the same Command? [message #489749]
||Mon, 05 October 2009 14:53
| Millard Ellingsworth
Registered: July 2009
Simple application. View with list of tasks, Editor to modify task properties. Editor uses a Scrolled/Managed/Form. |
From the Task List View, I want to offer a popup menu choice to run the task (Task does not have to be open in an Editor to run it). From an open Editor for the task, I want to provide a Run command (so it is not necessary to go to the View, right-click, Run). Feels reasonable.
Using existing docs/examples (thanks, Lars), View side pretty easy to wire up and works fine. One command, one handler, one menu appearance. Handler enables when activeMenuSelection is a task item. Handler code uses selection and casts to appropriate object type. All good.
But I'm not quite following (and I can't find any examples or docs) about how to handle the Form/Editor side. For one thing, it feels like I need a different handler, yet isn't it one handler per command? The Editor handler would have different conditions for enabling the command (it at least wouldn't care about the activeMenuSelection). And it would need a different way to understand which task was to be executed since there may not be an active selection (and if there was, it might not match the active editor). [Thanks to folks here for help in figuring out how to wire declaratively into the Form's menu.]
My current approach, though I'm not certain it is reasonable or appropriate is to gum up the handler with an or condition that enables it from either possible angle (though I'm a little concerned about a false positive here). And then in the handler code, if casting against the exception doesn't work, look at the EditorInput of the currently active Editor (if one is open). But this has sort of a sad, hacky feel to it. I'm fumbling with an AbstractSourceProvider that can provide the editor input so that I can find the task object, but even when (if?) I get that working, it's still not clear I can successfully wire it all in.
Anyone done something like this? Any suggestions?
I guess I could do a RunTaskFromView and RunTaskFromEditor command/handler and just delegate the work to a common runner (probably simpler than where I'm headed now), but that also doesn't feel quite right.
Powered by FUDForum
. Page generated in 0.01745 seconds