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

Bug 440554

Summary: Implement the deletion of selected content parts (of the focused viewer) within the MVC example via the <DELETE> key.
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: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Matthias Wienand CLA 2014-07-28 09:49:16 EDT
The implementation requires (1) a pair of KeyTool and KeyPolicy for the general processing of keyboard events, and (2) a pair of DeleteOnKeyPolicy and ContentOperation for the specific delete action (with undo functionality).
Comment 1 Matthias Wienand CLA 2014-08-01 05:32:28 EDT
I implemented a delete mechanism in the MVC example. A focused shape or curve can be deleted via the <DELETE> key. Currently, not the whole selection is deleted, but only the focused part. A TypeTool forwards keyboard events to the focused part. A TypePolicy processes those events. A general DeleteOnTypePolicy (updating selection etc.) is provided within the example and specialized in the individual example content parts (for deleting the content of the parts, respectively).

The mechanism has to be altered a little to simplify deletion in general and allow for the deletion of the whole selection:

1. A DeleteFromContentChildrenPolicy has to provide an IUndoableOperation for the deletion of the adaptee part's content from its parent's model content children.

    IUndoableOperation getDeleteOperation();

2. A DeleteContentAnchoragesPolicy has to provide an IUndoableOperation for the deletion of specific content anchorages of the adaptee.

    IUndoableOperation getDeleteOperation(anchorage, role);
    IUndoableOperation getDeleteOperation(List<Entry<anchorage, role>>);

3. A generic DeleteOnTypePolicy can then be bound to an IContentPart to initiate deletion when the <DELETE> key is pressed. This policy uses the DeleteFromContentChildrenPolicy and DeleteContentAnchoragesPolicy of all selected parts to get corresponding delete operations. Every delete operation is assembled together with a synchronization operation. Moreover, the individual interaction models are changed here as well (advancement of focused part, clearing selection, clearing hover).
Comment 2 Matthias Wienand CLA 2014-08-01 12:08:19 EDT
I changed the delete mechanism accordingly, but transferred the responsibility for deleting content children from the children to the parent. The mechanism consists of the following classes:

1. AbstractDeleteContentChildrenPolicy

This policy constructs an operation to delete the content of a specific content part from the content children of the adaptee.

2. AbstractDetachContentAnchoragesPolicy

This policy constructs an operation to delete a specific (anchorage, role) tupel from the content anchorages of the adaptee.

3. FXDeleteSelectedOnTypePolicy

Uses the other two policies to compose a giant delete operation for all selected parts. It should be easy to replace or extend the functionality provided here by sub-classing.

The code is published on the master branch. Therefore, I change the status of this ticket to RESOLVED, FIXED.