Bug 253982 - TreeItem with no children should never be expanded
Summary: TreeItem with no children should never be expanded
Status: RESOLVED DUPLICATE of bug 40797
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords: consistency
Depends on:
Blocks:
 
Reported: 2008-11-05 15:03 EST by Grant Gayed CLA
Modified: 2009-05-13 09:18 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Grant Gayed CLA 2008-11-05 15:03:13 EST
- run the snippet below
- on gtk and motif it behaves correctly and prints "true, false"
- but on win32 and carbon is prints "true,"true"

public static void main(String[] args) {
	final Display display = new Display();
	Shell shell = new Shell(display);
	shell.setBounds(10,10,200,200);
	Tree tree = new Tree(shell, SWT.NONE);
	tree.setBounds(10,10,100,100);
	final TreeItem root = new TreeItem(tree, SWT.NONE);
	root.setText("General");
	final TreeItem child = new TreeItem(root, SWT.NONE);
	child.setText("Error");
	shell.open();
	root.setExpanded(true);
	System.out.println(root.getExpanded());
	child.dispose();
	System.out.println(root.getExpanded()); // <----
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep();
	}
	display.dispose();
}
Comment 1 Felipe Heidrich CLA 2009-02-06 15:17:07 EST
I agree we have inconsistency in here. My question is:

This code:
TreeItem root = new TreeItem(tree, SWT.NONE);
root.setText("General");
root.setExpanded(true);
TreeItem child = new TreeItem(root, SWT.NONE);
child.setText("Error");

And this code here:
TreeItem root = new TreeItem(tree, SWT.NONE);
root.setText("General");
TreeItem child = new TreeItem(root, SWT.NONE);
child.setText("Error");
root.setExpanded(true);

When the shell opens and tree is visible, is root expanded ? Note that not allowing a childless item to be expand should cause the first snippet to be collapsed.

see also Bug 40797
Comment 2 Felipe Heidrich CLA 2009-05-12 16:44:11 EDT
Steve, some platforms automatically change the expand state of a treeitem to false when the last child item is disposed. Other don't.

Is that something we should make consistent across platforms ?
Or just close this as platform behaviour ?


(need to check if calling setExpand(true) works when an item has no children).

Comment 3 Steve Northover CLA 2009-05-12 17:45:37 EDT
We need to make this consistent but not for 3.5.
Comment 4 Felipe Heidrich CLA 2009-05-13 09:18:42 EDT

*** This bug has been marked as a duplicate of bug 40797 ***