Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 476285

Summary: Introduce a common base class for operations that allows checking the operation for any effects.
Product: [Tools] GEF Reporter: Matthias Wienand <matthias.wienand>
Component: GEF MVCAssignee: Matthias Wienand <matthias.wienand>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 0.1.0   
Target Milestone: 4.0.0 / 3.11.0 (Neon) M2   
Hardware: All   
OS: All   
Whiteboard:

Description Matthias Wienand CLA 2015-09-01 05:59:02 EDT
An operation can have no effects at all. When such an operation is added to the undo-stack, undoing/redoing that operation will not result in any changes. Therefore, such operations should not be added to the undo-stack in the first place. In order to determine if an operation has any effects/has no effects, a method should be added to the operations: hasEffect() : boolean. Many operations already provide such a method, however, it is not part of a common interface, yet. A new base class for operations could be added to provide such a method.
Comment 1 Matthias Wienand CLA 2015-09-25 10:18:39 EDT
I decided not to introduce a new base class, but rather define a new interface for operations which can be checked for having an effect. The new interface is called ITransactionalOperation. It defines one method isNoOp():boolean. When executing an operation via the domain (i.e. domain.execute(operation)) the operation is simplified as much as possible:
 1. If it is a composite operation, it is unwrapped.
 2. If it is a transactional operation, it is not executed if it is a no-op.
Therefore, users do not have to tediously clean-up their operations, but instead, the domain will take care of that when an operation is executed. An operation with no effects will not be added to the undo-stack.

The code is published on the master branch. Therefore, I resolve this ticket as fixed for 3.11.0M2.