[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: How to forbid changing an attribute value via property sheet? or How to intercept a SetCommand?

Hi Alexander,

There is a way how to consistently make it impossible to set an attribute no matter how the change is attempted. You will need to register a ResourceSetListener to the transactional editing domain of your diagram. In #transactionAboutToCommit() method, check if the change is allowed and, if not, throw a RollbackException.

Note that although DiagramEventBrocker is meant to be a centralized place for dispatching notifications for a diagram editing domain, you may not throw exceptions from a NotificationPreCommitListener, so this cannot be used for transaction validation.

Best regards,
Boris


Alexander Dotor wrote:
Hello,

I want to forbid the setting of an attribute value via the property sheet depending on the state of my semantic model.

As far as I can see it is not possible to replace the SetCommand as it is working directly on the model. I tried to install an EditPolicy as EditPolicyRoles.PROPERTY_HANDLER_ROLE, EditPolicyRoles.SEMANTIC_ROLE or even EditPolicy.DIRECT_EDIT_ROLE. If I debug into the creation of the SetCommand it seems to be indepent of any EditPolicy.

What can I do now?

Why is using the PropertyView not calling the getBeforeSetCommand of an EditHelper for example?

Currently I have to adapt different startegies for implementing my dynamic constraints for every kind of command. Why is the edit helper offering all these methods if they aren't used? This is very annoying.

Cheers,
Alexander