Community
Participate
Working Groups
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.
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.
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.
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.
Adam, the patch unfortunately conflicts with the patch I just released for bug 196878.
Created attachment 74954 [details] synched patch
Patch released. Thanks Adam.