Bug 196675 - [Schema][Editors] Selection behaviour wrong after schema object deletion
Summary: [Schema][Editors] Selection behaviour wrong after schema object deletion
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M1   Edit
Assignee: Adam Archer CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-07-16 11:45 EDT by Mike Pawlowski CLA
Modified: 2007-07-26 10:37 EDT (History)
1 user (show)

See Also:
mike.pawlowski: review+


Attachments
patch (9.36 KB, patch)
2007-07-25 15:50 EDT, Adam Archer CLA
no flags Details | Diff
patch (9.66 KB, patch)
2007-07-25 16:28 EDT, Adam Archer CLA
mike.pawlowski: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Pawlowski CLA 2007-07-16 11:45:31 EDT
Selection behaviour is wrong after the deletion of the following schema object types:

* Element references
* Sequence or Choice compositors
* Attributes

Currently when you delete any of those elements the selection jumps to their parents.  This is particularly annoying when deleting multiple objects.

The correct selection behaviour after the deletion is as follows:

* If there are N objects on the same level in the hierarchy and the 
  Nth object is deleted, the N-1th object should be selected

* If there are N objects on the same level in the hierarchy and any 
  object 1 to N-1 is deleted, the N+1th object should be selected

* If N=1 objects on the same level in the hierarchy and object 1 is
  deleted, the parent object should be selected (no more children on the 
  same level)

This behaviour is applicable when the delete is performed using the corresponding keyboard shortcut, button or context menu and when invoking a cut operation.

This behaviour is implemented by the Simple Cheat Sheet Editor - if you need a reference.

Now currently, multiple selection is allowed in the tree viewer.  
This complicates things.  I recommend disabling multiple selection unless
Wassim objects because there are a number of other bugs that exist because of it.
Comment 1 Mike Pawlowski CLA 2007-07-16 13:12:35 EDT
Curtis finds the multiple selection useful for copy and paste operations.  Plus, the deletion of multiple objects at the same time is convenient.

Therefore, if we can overlay the behaviour outlined in Comment #0 on a multi-selection enabled tree viewer that would be ideal.

A set of heuristics would have to be defined as all edge cases where more than one object is selected probably will not be solved.
Comment 2 Adam Archer CLA 2007-07-25 15:50:41 EDT
Created attachment 74613 [details]
patch

The new selection was being set in the model change handler for the ElementSection. I removed the call to set the selection here and left it up to the handleDelete method. This method is used for cuts and deletes, so both of those cases are fine. Doing this actually fixed a flicker that occurred on a move operation because the selection was changed on both the model remove and the model insert. I cannot think of any other edge cases where the handleDelete event is not used and we would actually want the model change handler to set the new selection.

The selection algorithm for deletes now works as suggested in comment 0. It is, of course, slightly modified to allow for multiple deletes at once. It will base the new selection on the object selected for deletion that is highest up in the hierarchy (elements > compositors = attributes > references). If multiple items are selected for deletion that are at the same level, the algorithm will use the first it comes across. If, however, a subsequent delete removes the new selection candidate, the selection will be regenerated based on that object. That was a little wordy. I hope it made sense. If it didn't, it will when you see it in action.  ;)
Comment 3 Adam Archer CLA 2007-07-25 16:28:46 EDT
Created attachment 74621 [details]
patch

Modified the logic to determine what's higher in the hierarchy. It is now based entirely on how deeply nested a SchemaObject is from an element. For instance, attributes are now considered higher in the hierarchy than nested compositors and references on the root compositor are considered higher than compositors nested at lower levels. A compositor and a reference are considered equal if they have a parent compositor at the same level.
Comment 4 Mike Pawlowski CLA 2007-07-26 10:35:27 EDT
Comment on attachment 74621 [details]
patch

Tested very well.  Excellent work Adam.
Comment 5 Mike Pawlowski CLA 2007-07-26 10:37:28 EDT
Patch released to HEAD.

Target:  3.4 M1