Bug 573221

Summary: ListSelectionDialog: Improve usability and extend its API
Product: [Eclipse Project] Platform Reporter: Holger Voormann <eclipse>
Component: UIAssignee: Holger Voormann <eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: kalyan_prasad, Lars.Vogel, loskutov
Version: 4.19Keywords: noteworthy
Target Milestone: 4.21 M3   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/179930
https://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=edd61880f7b9eafeb2a1d4b8693049687a646ab3
https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/183549
https://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=00a6d0f37629bd54561a487668d6658bcad318e4
https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/183564
https://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=91249f432c070c87710d88f65ca270e6401692cb
Whiteboard:
Bug Depends on:    
Bug Blocks: 572939, 574014    

Description Holger Voormann CLA 2021-04-28 11:34:37 EDT
Improve the usability of org.eclipse.ui.dialogs.ListSelectionDialog (which is used e.g. in the "Save Resources" dialog: see bug 572939) and extend its API in the following ways:

(a) Enabling/Disabling of the "Select All" and the "Deselect All" buttons
Actual: Both buttons are always enabled.
Expected:
- When all elements are selected, the "Select All" button should be disabled, otherwise enabled.
- When no elements are selected, the "Deselect All" button should be disabled, otherwise enabled.

(b) Shorten button labels: "Select All" => "All" and "Deselect All" => "None"
Shortening labels is a tradeoff between better readability (shorter and more distinguishable) and that button labels should be verbs. The shortening leads to the following new mnemonics:
- Alt+S for "Select All" => Alt+A for "All"
- Alt+D for "Deselect All" => Alt+N for "None"

(c) Extend API
The class is marked as "@noextend This class is not intended to be subclassed by clients.", but internally, it is extended several times for different purposes. The goal is that subclassing should no longer be necessary for customizations, to achieve more consistency and avoid duplicate code, and to give clients the same capabilities as the dialogs used internally.
The extended API should provide following additional possibilities:
- Dialog title: to avoid that it will be missed, even the title can also be set via setTitle()
- OK button label:
  - When nothing is selected: For example, "Launch without Saving"
  - When one or more elements are selected: With {0} as placeholder for the current selected elements and with {1} for the total number of elements; for example, "Save {0} of {1} and Launch"
- Whether the dialog can be canceled (via Cancel button or by closing the dialog window)
- Whether to use SWT#SHEET (modal dialog that is attached to a parent window)
- Optional checkbox:
  - Label
  - Default value
The existing constructor should be marked as deprecated in favor of the new API.
Comment 1 Eclipse Genie CLA 2021-04-28 11:38:34 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/179930
Comment 3 Lars Vogel CLA 2021-07-30 07:05:10 EDT
Thanks Holger for this contribution and Marcus for the review. 

Holger, please add to N&N. Please also create bug for using this new API in platform code and update the Gerrit for Bug 572939.
Comment 4 Eclipse Genie CLA 2021-07-30 09:03:49 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/183549
Comment 5 Andrey Loskutov CLA 2021-07-30 09:15:11 EDT
(In reply to Eclipse Genie from comment #4)
> New Gerrit change created:
> https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/183549

Reopening. Lars, please review.
Comment 7 Andrey Loskutov CLA 2021-07-31 02:40:28 EDT
https://download.eclipse.org/eclipse/downloads/drops4/I20210730-1800/compilelogs/platform.doc.isv.javadoc.txt

../../../eclipse.platform.ui/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/ListSelectionDialog.java:482: error: reference not found
	 * @see #ListSelectionDialog(Shell, Object, IStructuredContentProvider,
	        ^
1 error
Comment 8 Eclipse Genie CLA 2021-07-31 02:41:30 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/183564