Bug 196874 - [Manifest][Editors] Selection behaviour is wrong after delete in Extension section tree viewer
Summary: [Manifest][Editors] Selection behaviour is wrong after delete in Extension se...
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-17 16:12 EDT by Mike Pawlowski CLA
Modified: 2007-07-30 14:36 EDT (History)
1 user (show)

See Also:
mike.pawlowski: review? (wassim.melhem)


Attachments
patch (6.13 KB, patch)
2007-07-26 19:57 EDT, Adam Archer CLA
no flags Details | Diff
patch (7.25 KB, patch)
2007-07-30 11:27 EDT, Adam Archer CLA
no flags Details | Diff
synched patch (7.25 KB, patch)
2007-07-30 13:46 EDT, Adam Archer CLA
no flags 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-17 16:12:17 EDT
Steps To Reproduce:

(1) Open manifest editor
(2) Switch to "Extensions" page
(3) Select any object within the tree viewer in the "All Extensions" section
(4) Press delete
    -> BUG: Selection is lost and details section goes blank

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, or context menu and when invoking a cut
operation.

This behaviour is implemented by the Simple Cheat Sheet Editor - if you need a
reference.
Comment 1 Adam Archer CLA 2007-07-26 19:57:05 EDT
Created attachment 74751 [details]
patch

Implements the selection algorithm for the Extensions and Extension Points sections.

Moves some utility methods used by the algorithm from ElementSection (Schema editor) to StructuredViewerSection for generality.
Comment 2 Wassim Melhem CLA 2007-07-27 23:27:25 EDT
Adam, it would be better if resetting the selection took place in the modelChanged(..) method.

This way, the selection would be reset correctly whichever way an object has been deleted (via the delete button, via undo/redo (when it gets implemented), via some external operation, etc...).

Forcing the selection in a handleDelete() method will work only when done via that button/context menu item.
Comment 3 Adam Archer CLA 2007-07-30 11:27:16 EDT
Created attachment 74937 [details]
patch

Determining the new selection after the item has been removed from the model is much more complex. This is because we cannot ask the model for the object's index, etc.

Due to the additional complexity involved in implementing the selection determination in the modelChanged method, it has been left in the handleDelete.

This patch adds support for the case where the sort action is on. Previously, because the model index was used (not the sorted list index), the new selection would be seemingly random. To solve this, the array of elements in the model is copied and sorted using the viewer's comparator. This array is then used to determine the new selection.
Comment 4 Wassim Melhem CLA 2007-07-30 13:39:03 EDT
Adam, the patch unfortunately conflicts with the patch I just released for bug 196878.
Comment 5 Adam Archer CLA 2007-07-30 13:46:22 EDT
Created attachment 74954 [details]
synched patch
Comment 6 Wassim Melhem CLA 2007-07-30 14:36:28 EDT
Patch released.  Thanks Adam.