Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 120561 - [working sets] Allow to have the working sets automatically sorted in the Package Explorer
Summary: [working sets] Allow to have the working sets automatically sorted in the Pac...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Raksha Vasisht CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-13 08:41 EST by Maik Schreiber CLA
Modified: 2009-02-13 07:34 EST (History)
5 users (show)

See Also:


Attachments
Fixed. Added a new checkbox for sorting all working sets in the configuration dialog and also sort any newly added working sets. (15.49 KB, patch)
2009-02-04 12:21 EST, Raksha Vasisht CLA
no flags Details | Diff
Fixed the conflicts with 190438 (13.84 KB, patch)
2009-02-05 05:21 EST, Raksha Vasisht CLA
daniel_megert: review-
Details | Diff
copyrights Update (14.25 KB, patch)
2009-02-05 07:14 EST, Raksha Vasisht CLA
daniel_megert: review-
Details | Diff
Looks like the last patch was corrupt :( Hope this one works ! (16.53 KB, patch)
2009-02-05 11:00 EST, Raksha Vasisht CLA
no flags Details | Diff
Pls take this one. (15.60 KB, patch)
2009-02-05 11:04 EST, Raksha Vasisht CLA
daniel_megert: review-
Details | Diff
Added new comparator class , other minor changes. (18.15 KB, patch)
2009-02-06 06:53 EST, Raksha Vasisht CLA
daniel_megert: review-
Details | Diff
Fixed the minor changes. (17.36 KB, patch)
2009-02-06 11:00 EST, Raksha Vasisht CLA
daniel_megert: review-
Details | Diff
Patch with review changes. (18.48 KB, patch)
2009-02-10 10:09 EST, Raksha Vasisht CLA
daniel_megert: review-
Details | Diff
Patch with review changes. (16.99 KB, patch)
2009-02-12 00:04 EST, 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 Maik Schreiber CLA 2005-12-13 08:41:36 EST
In the dialog where you can chose the working sets to be displayed in the Package Explorer view, please add a button to sort working sets alphabetically.
Comment 1 Kim Horne CLA 2005-12-13 13:07:23 EST
Both WorkingSet dialogs available from the package explorer are already sorted alphabetically for with the exception of the first element in one case.  Could you take a screencapture to show me what the dialog looks like to you?
Comment 2 Maik Schreiber CLA 2005-12-13 13:39:39 EST
I simply mean the one you get when you open the Package Explorer view's menu, then select "Select Working Sets...". The dialog's header says "Check working sets visible in Package Explorer:". You can also add new working sets there, but they won't be sorted in any way (aside from moving then up and down manually). In the Package Explorer view itself, the working sets are also not sorted alphabetically.
Comment 3 Kim Horne CLA 2005-12-13 13:48:12 EST
Aha, you're referring to the state it gets into after a new set is added and the dialog is still open.  Gotcha.  The dialog provided by the workbench does insert at the proper point  - the JDT specific dialog does not.  Redirecting.
Comment 4 Maik Schreiber CLA 2005-12-13 14:24:45 EST
Yes, but I wasn't complaining that it not sorts alphabetically automatically, that's fine with me. I'd just like to have a sort button :) But if you guys decide to change it to automatic sorting, that would be fine with me as well.

Also, what's a bit funny: When you add a new working set, close the dialog, then reopen it, the new project is no longer the last one in the last (as it used to be before closing the dialog), but it will be the last one of the _selected_ working sets, right before the first working set which is not selected. That's really a bit odd.
Comment 5 Simon Archer CLA 2007-08-03 23:48:19 EDT
+1.  I have at least 35 working sets these days, and being able to sort them alphabetically would be great.  Nevertheless, I still like the fact that I can also re-arrange my working sets to my heart's content.  This is the first comment in over 18 months...  I am hoping this can get picked up for inclusion in Eclipse 3.4.
Comment 6 Dani Megert CLA 2008-12-15 05:53:42 EST
There are two thing here:
1) have an option in the 'Configure Working Set' dialog to keep the PE working
   sets sorted (except 'Other Projects' which should always be on top)
   ==> this bug

2) a bug in the 'Working Set Assignments' dialog that gets out of alpha sort
   order when a new working set is created out of that dialog
   ==> see new bug 258792

Comment 7 Raksha Vasisht CLA 2009-02-04 12:21:18 EST
Created attachment 124696 [details]
Fixed. Added a new checkbox for sorting all working sets in the configuration dialog and also sort any newly added working sets.
Comment 8 Raksha Vasisht CLA 2009-02-05 05:21:01 EST
Created attachment 124789 [details]
Fixed the conflicts with 190438
Comment 9 Raksha Vasisht CLA 2009-02-05 07:14:18 EST
Created attachment 124794 [details]
copyrights Update
Comment 10 Dani Megert CLA 2009-02-05 09:47:55 EST
Comment on attachment 124789 [details]
Fixed the conflicts with 190438

Missing copyright update.
Comment 11 Dani Megert CLA 2009-02-05 09:49:48 EST
Comment on attachment 124794 [details]
copyrights Update

This patch is not good. After I apply it I get warnings because the patch adds private members that are never used:

WorkingSetConfigurationDialog.sortWorkingSetList()
WorkingSetConfigurationDialog.fIsWorkingSetsSorted

Either it is a bug that you don't use them or it is a bug that they are in the patch.
Comment 12 Raksha Vasisht CLA 2009-02-05 11:00:53 EST
Created attachment 124817 [details]
Looks like the last patch was corrupt :( Hope this one works !
Comment 13 Raksha Vasisht CLA 2009-02-05 11:04:36 EST
Created attachment 124818 [details]
Pls take this one.
Comment 14 Dani Megert CLA 2009-02-05 12:18:29 EST
Please make the patch minimal i.e. don't change things which are not essential to this fix, e.g. don't make field or variables final. The patch has too many changes!

Some other issues:
- sortWorkingSetList() is a hack. Instead make a subclass of the comparator that handles the 'Other Projects' working set.
- the sort code is duplicated. Duplicated code is always bad. You can solve this
  with your own comparator that can be used at both places
- I mentioned that before: only use 'f' prefix for field (fSettings)
- store and read the setting in the model and not in the dialog (add an 
  isSortingEnabled() to the dialog and pass the value in the constructor
Comment 15 Raksha Vasisht CLA 2009-02-06 06:53:46 EST
Created attachment 124950 [details]
Added new comparator class , other minor changes.
Comment 16 Dani Megert CLA 2009-02-06 09:17:18 EST
The patch looks pretty good. Some minor issues:
- the comparator has nothing to do with 'search'. Please move it to the working 
  set package
- why does the comparator inherit WorkingSetComparator from if he doesn't use any 
  of its code?
- "model" means headless (no UI) and hence mentioning "checkbox" in the Javadoc
  is not good. This also applies to the method/Javadoc in the dialog. Just 
  mention the what the method returns.
- delete the outdated and unused constructor
Comment 17 Raksha Vasisht CLA 2009-02-06 11:00:39 EST
Created attachment 124970 [details]
Fixed the minor changes.
Comment 18 Dani Megert CLA 2009-02-09 12:19:56 EST
Raksha, here some more details on your latest patch:

You don't need to sort the list manually in the dialog: simply set the comparator on the table viewer.

The comparator should not re-implement the normal working set sorting but only extend org.eclipse.jdt.internal.ui.search.WorkingSetComparator to handle the OthersWorkingSetUpdater.ID.

The new WorkingSetModel.isSortingEnabled() has a problem: it does not update the model but required that setActiveWorkingSets is called afterwards. I suggest you get rid of that method and add setActiveWorkingSets(IWorkingSet[], boolean) where you pass in both values.

Don't make the public static final IElementComparer COMPARER as this is dangerous if more instances of the model are created.

Don't add dialog settings to the model, simply store the sort flag along with the other working set properties (see the TAG_* constants).

Please fix the copyright on the new comparator class:
 * Copyright (c) 2000, 2009 IBM Corporation and others.
==>
 * Copyright (c) 2009 IBM Corporation and others.

Javadoc:
  <code>true</code> if the sorting is enabled, else <code>false</code>
we normally write:
  <code>true</code> if sorting is enabled, <code>false</code> otherwise
Comment 19 Raksha Vasisht CLA 2009-02-10 10:09:05 EST
Created attachment 125248 [details]
Patch with review changes.
Comment 20 Dani Megert CLA 2009-02-11 08:26:11 EST
>Javadoc:
>  <code>true</code> if the sorting is enabled, else <code>false</code>
>we normally write:
>  <code>true</code> if sorting is enabled, <code>false</code> otherwise
This is still not fixed. Please make sure that newer patches do not exhibit issues that got previously mentioned. Ah, and please add the (class) Javadoc that's missing. Missing Javadoc is a NO GO.

- in WorkingSetModel all keys begin with "TAG". Why did you not stick to that 
  convention?

- the following code in WorkingSetModel is broken (can cause NPE):
		if (isSortingEnabled == null) {
			fIsSortingEnabled= false;
		}
		fIsSortingEnabled= Boolean.valueOf(isSortingEnabled).booleanValue();

- WorkingSetsViewerComparator is to simple for its own CU. Such types should
  be directly written as anonymous class where used

- WorkingSetConfigurationDialog: the else code is useless:
		} else {
			fTableViewer.setComparator(null);
		}

- I have no clue why you added the code to WorkingSetConfigurationDialog.createWorkingSet(). In my opinion this is not needed at all.

- there's no need to set the input again when changing a comparator

Comment 21 Dani Megert CLA 2009-02-11 08:36:35 EST
Raksha, did you ever test your last patch? Upon exit you will always get the following exception because the key contains invalid characters (spaces):

!ENTRY org.eclipse.ui.workbench 4 2 2009-02-11 14:33:43.916
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 0
org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. 
	at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createAttribute(CoreDocumentImpl.java:554)
	at com.sun.org.apache.xerces.internal.dom.ElementImpl.setAttribute(ElementImpl.java:495)
	at org.eclipse.ui.XMLMemento.putBoolean(XMLMemento.java:438)
	at org.eclipse.jdt.internal.ui.workingsets.WorkingSetModel.saveState(WorkingSetModel.java:398)
	at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.saveState(PackageExplorerPart.java:928)
	at org.eclipse.ui.internal.ViewFactory$1.run(ViewFactory.java:329)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.ui.internal.ViewFactory.saveViewState(ViewFactory.java:311)
	at org.eclipse.ui.internal.ViewFactory.saveState(ViewFactory.java:290)
	at org.eclipse.ui.internal.WorkbenchPage.saveState(WorkbenchPage.java:3395)
	at org.eclipse.ui.internal.WorkbenchWindow.saveState(WorkbenchWindow.java:2738)
	at org.eclipse.ui.internal.Workbench.saveState(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench.recordWorkbenchState(Workbench.java:2039)
	at org.eclipse.ui.internal.Workbench.access$11(Workbench.java:2036)
	at org.eclipse.ui.internal.Workbench$15.run(Workbench.java:889)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.ui.internal.Workbench.busyClose(Workbench.java:887)
	at org.eclipse.ui.internal.Workbench.access$15(Workbench.java:844)
	at org.eclipse.ui.internal.Workbench$23.run(Workbench.java:1088)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.Workbench.close(Workbench.java:1086)
	at org.eclipse.ui.internal.Workbench.close(Workbench.java:1058)
	at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:720)
	at org.eclipse.ui.internal.WorkbenchWindow.access$0(WorkbenchWindow.java:699)
	at org.eclipse.ui.internal.WorkbenchWindow$5.run(WorkbenchWindow.java:815)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:813)
	at org.eclipse.jface.window.Window.handleShellCloseEvent(Window.java:741)
	at org.eclipse.jface.window.Window$3.shellClosed(Window.java:687)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:92)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
	at org.eclipse.swt.widgets.Decorations.closeWidget(Decorations.java:307)
	at org.eclipse.swt.widgets.Decorations.WM_CLOSE(Decorations.java:1644)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3914)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1577)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1937)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4588)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2389)
	at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:477)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4002)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1577)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1937)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4588)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2389)
	at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:477)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4002)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1577)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1937)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4588)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2394)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3470)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2388)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2352)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2204)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:499)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:333)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:492)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:556)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:511)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1270)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1246)
Comment 22 Raksha Vasisht CLA 2009-02-12 00:04:10 EST
Created attachment 125488 [details]
Patch with review changes.
Comment 23 Dani Megert CLA 2009-02-12 12:09:36 EST
Patch is good. I opened two trivial bugs:
- bug 264720: remove duplicate creation of the comparator
- bug 264722: Get rid of duplicate working set comparators

Fixed in HEAD.
Available in builds > N20090211-2000.