Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 267829 - [working sets] [package explorer] Working sets not resorted when name changes
Summary: [working sets] [package explorer] Working sets not resorted when name changes
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Raksha Vasisht CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-10 07:43 EDT by Markus Keller CLA
Modified: 2009-03-16 10:27 EDT (History)
1 user (show)

See Also:


Attachments
Fixed both cases. (2.53 KB, patch)
2009-03-12 10:02 EDT, Raksha Vasisht CLA
daniel_megert: review-
Details | Diff
Patch with the fix. (5.57 KB, patch)
2009-03-16 07:42 EDT, Raksha Vasisht CLA
daniel_megert: iplog+
daniel_megert: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2009-03-10 07:43:55 EDT
I20090310-0100

Have Package Explorer in working set mode, sorted.

Change the name of a working set via context menu > Properties.
=> Working sets are not sorted alphabetically any more in the Package Explorer.

Open the Configure Working Sets dialog and edit a working set's name
=> Working sets are not sorted alphabetically any more in the dialog.
Comment 1 Raksha Vasisht CLA 2009-03-12 10:02:49 EDT
Created attachment 128551 [details]
Fixed both cases.
Comment 2 Dani Megert CLA 2009-03-13 04:31:24 EDT
Raksha the patch is not good as it does way too much in both classes.
- there's no need to set a sorter if a sorter is already set. Simply refresh the
  viewer.
- what is the reason that you reset the active PE working sets on label change if
  they are not sorted? In my opinion the current code in jdt.ui is wrong as the
  WorkingSetModel currently handles the change of a working set name instead of 
  handling the label update. The PE already listens for that, so you only need
  to make a smarter update when the label gets changed in sorting mode.
Comment 3 Raksha Vasisht CLA 2009-03-16 03:33:35 EDT
(In reply to comment #2)
> Raksha the patch is not good as it does way too much in both classes.
> - there's no need to set a sorter if a sorter is already set. Simply refresh
> the
>   viewer.

Done. Now we refresh the viewer if sorting is enabled.

> - what is the reason that you reset the active PE working sets on label change
> if
>   they are not sorted? In my opinion the current code in jdt.ui is wrong as the
>   WorkingSetModel currently handles the change of a working set name instead of 
>   handling the label update. The PE already listens for that, so you only need
>   to make a smarter update when the label gets changed in sorting mode.
> 

Right now, we listen to only name change in the model. I added the label change listener in my previous patch since it is triggered after the label of the working set is changed to the new label. If we do the sorting in the name change listener , then the sorting would happen with the old label and the new working set would appear in PE in the same place as the old one and not in its sorted place. (So the working sets would no longer be alphabetically sorted in PE)

Also, since we are planning to change the entire jdt/ui code to listen to label update instead of name change , I can add the "resetting active working sets" code to label change listener, right?
Comment 4 Dani Megert CLA 2009-03-16 04:04:11 EDT
>Also, since we are planning to change the entire jdt/ui code to listen to label
>update instead of name change , I can add the "resetting active working sets"
>code to label change listener, right?
No, it's the other way around: since we're going to change it later, you can add it to the name change for now. Otherwise the view would be updated twice: once for label and once for name change event.
Comment 5 Raksha Vasisht CLA 2009-03-16 07:42:47 EDT
Created attachment 128906 [details]
Patch with the fix.
Comment 6 Raksha Vasisht CLA 2009-03-16 07:43:32 EDT
(In reply to comment #4)
> >Also, since we are planning to change the entire jdt/ui code to listen to label
> >update instead of name change , I can add the "resetting active working sets"
> >code to label change listener, right?
> No, it's the other way around: since we're going to change it later, you can
> add it to the name change for now. Otherwise the view would be updated twice:
> once for label and once for name change event.
> 

Made the changes in jdt/ui code to replace all occurances of name change event listeners (CHANGE_WORKING_SET_NAME_CHANGE)to label change listeners (CHANGE_WORKING_SET_LABEL_CHANGE). The resetting of active working sets happens now in label change in the model (org.eclipse.jdt.internal.ui.workingsets.WorkingSetModel.workingSetManagerChanged(PropertyChangeEvent event)) if sorting is enabled, so that the new/updated label is considered for sorting and the working sets are automatically sorted in PE after edit.
Comment 7 Dani Megert CLA 2009-03-16 10:26:38 EDT
Thanks Raksha for the updated patch.

It is good with one exception: in WorkingSetConfigurationDialog.editSelectedWorkingSet() it is not needed to first update the edited element and then do a full refresh in case of sorting i.e. in case of sorting do the refresh and otherwise we do update the element.

Fixed this and committed to HEAD.
Available in builds > N20090315-2000.