Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 514066

Summary: [Cocoa] Tree: inconsistent selection problem when collapsing parent node
Product: [Eclipse Project] Platform Reporter: Thomas Singer <eclipse>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: lshanmug, ts-swt
Version: 4.7Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard: stalebug
Attachments:
Description Flags
Sample code
none
Initial situation
none
After closing the first node programmatically on OS X 10.11
none
After closing the first node programmatically on Windows 10 none

Description Thomas Singer CLA 2017-03-22 10:27:55 EDT
- have a tree with multiple levels and a child node is selected
- programmatically collapse a parent node of a selected child
=> on Windows the parent node will be selected, on OS X nothing
Comment 1 Thomas Singer CLA 2017-03-22 10:28:42 EDT
Created attachment 267404 [details]
Sample code
Comment 2 Thomas Singer CLA 2017-03-22 10:29:38 EDT
Created attachment 267405 [details]
Initial situation
Comment 3 Thomas Singer CLA 2017-03-22 10:30:12 EDT
Created attachment 267406 [details]
After closing the first node programmatically on OS X 10.11
Comment 4 Thomas Singer CLA 2017-03-22 10:31:40 EDT
Created attachment 267408 [details]
After closing the first node programmatically on Windows 10
Comment 5 Thomas Singer CLA 2017-03-22 11:43:14 EDT
Even when changing the button's listener to

button.addListener(SWT.Selection, new Listener() {
	@Override
	public void handleEvent(Event event) {
		final TreeItem nodeToCollapse = tree.getItem(0);
		if (!nodeToCollapse.getExpanded()) {
			return;
		}

		final TreeItem[] selection = tree.getSelection();
		for (TreeItem selectedItem : selection) {
			if (selectedItem.getParentItem() == nodeToCollapse) {
				tree.deselect(selectedItem);
			}
		}

		nodeToCollapse.setExpanded(false);
	}
});

will select the collapsed node on Windows.
Comment 6 Thomas Singer CLA 2017-03-22 13:27:07 EDT
If I'd have the choice, I would take the approach OS X is using, because if I would want to have the parent selected, I easily can do it, but on Windows I can't.
Comment 7 Eclipse Genie CLA 2020-12-11 14:04:41 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.