Community
Participate
Working Groups
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.
Sorry, replace 'A' with 'C' in the above.
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 (); } } }
Felipe, is this now consistent across platforms?
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.
*** This bug has been marked as a duplicate of 40797 ***