|
Re: Guarding all commands in a custom editor [message #418601 is a reply to message #418597] |
Mon, 21 April 2008 20:56 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
Eric,
Perhaps you want to allow the command to be created, test if it's
executable, and only in that case do the additional check to see if it
should be disabled; doing that in the AdapterFactoryEditingDomain seems
like a good funnel point at which to cover everything. Or maybe all
your model objects inherit from a common root and you could put the
specialized command creation code in the item providers themselves...
Eric Rizzo wrote:
> I need to guard all commands that are created/executed from a custom
> editor. The guard needs to inspect the state of the model object and
> possibly warn the user and prevent the command from executing. In
> other words, our model contains some information that is intended to
> flag that model object as being semi-read-only; the user will have to
> explicitly choose to modify the object before changes to certain
> attributes are applied to the model.
> At first I thought I could do this with a custom CommandStack, but it
> turns out that the Command interface (nor any of the base Command
> implementations) doesn't give me the feature being modified by the
> Command, so I can't determine if that command is allowed or not (it
> depends on what feature is being modified). For the same reason, I
> can't use the resourceToReadOnlyMap of AdapterFactoryEditingDomain (if
> a model is semi-read-only, some commands must still allowed to execute).
>
> Then I thought a custom EditingDomain was the answer, where I would
> override the createCommand() method. But it seems that some "bogus"
> commands are being created during editor initialization and those
> commands are not relevant because they aren't actually touching the
> model. These "bogus" commands are coming from the
> EditingDomainActionBarContributor during initialization.
>
> So, am I even on the right track here? I am loathe to put special-case
> code in my createCommand() to look for certain kinds of commands and
> ignore others. Is there another mechanism altogether that I could hook
> into?
>
> TIA,
> Eric
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02859 seconds