Bug 26410 - TreeItem.setExpanded(false) has no effect if item has no children
Summary: TreeItem.setExpanded(false) has no effect if item has no children
Status: RESOLVED DUPLICATE of bug 40797
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Christophe Cornu CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-14 15:14 EST by Nick Edgar CLA
Modified: 2005-03-29 10:50 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Edgar CLA 2002-11-14 15:14:42 EST
build I20021114

- create a tree with a parent item P with one child C
- manually expand P
- programmatically do the following:
   - C.dispose()
   - P.setExpanded(false)
   - add A back
- P is still expanded and A is visible

This is confusing behaviour.
See bug 3840 for more context.
Comment 1 Nick Edgar CLA 2002-11-14 15:15:10 EST
Sorry, replace 'A' with 'C' in the above.
Comment 2 Christophe Cornu CLA 2002-11-15 10:07:37 EST
Chrix to investigate and advise.

Added testcase:

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class PR26410 {

public static void main (String [] args) {
	Display display = new Display ();
	Shell shell = new Shell (display);
	final Tree tree = new Tree (shell, SWT.BORDER);
	tree.setSize (100, 100);
	shell.setSize (300, 300);
	final TreeItem itemP = new TreeItem (tree, 0);
	itemP.setText("itemP");
	final TreeItem itemC = new TreeItem (itemP, 0);
	itemC.setText("itemC");
	
	Button b = new Button(shell, SWT.PUSH);
	b.setBounds(0,200,50,50);
	b.setText("test");
	b.addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event e) {
			itemC.dispose();
			itemP.setExpanded(false);
			new TreeItem (itemP, 0).setText("itemCbis");
		}
	});
	
	shell.open ();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
}
}
Comment 3 Steve Northover CLA 2004-10-07 19:37:45 EDT
Felipe, is this now consistent across platforms?
Comment 4 Felipe Heidrich CLA 2004-10-08 13:46:16 EDT
I can't reproduce this problem, works as expected for me.

The actual problem is Bug40797, where the tree item is (automatically) collapse
after the last subitem is disposed, thus is not necessary to call setExpand
(false) after disposing the last item (like the snippet does), thus "P is still
expanded and A is visible" is not possible.
Comment 5 Christophe Cornu CLA 2005-03-29 10:50:51 EST

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