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

Bug 342648

Summary: On Linux in RTL mode Tree.getItem(Point) gives incorrect results
Product: [Eclipse Project] Platform Reporter: Chris Goldthorpe <cgold>
Component: SWTAssignee: Felipe Heidrich <eclipse.felipe>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, eclipse.felipe, Mike_Wilson, Silenio_Quarti
Version: 3.7Keywords: polish
Target Milestone: 3.7 M7   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
plug-in which reproduces the problem
none
patch none

Description Chris Goldthorpe CLA 2011-04-12 18:57:36 EDT
N20110410-2000

Unzip the attached plug-in project and import as existing project
Launch a new runtime workbench with the parameter -dir rtl 
Verify that Eclipse is in right to left mode
Show the view TreeViewCategory/RTL tree view
In the view click on an expander node
Expected Result: Tree item.getItem() is null is written to the console
Actual result: Tree item.getItem() is not null is written to the console

This works correctly in ltr
Comment 1 Chris Goldthorpe CLA 2011-04-12 18:59:18 EDT
Created attachment 193104 [details]
plug-in which reproduces the problem
Comment 2 Chris Goldthorpe CLA 2011-04-13 12:52:26 EDT
I have marked this as a polish item because it causes problems for the help view in RTL mode - see Bug 342617.
Comment 3 Mike Wilson CLA 2011-04-20 10:42:20 EDT
Silenio, any idea what's going on here?
Comment 4 Felipe Heidrich CLA 2011-04-20 11:59:08 EDT
Works for me on Fedora 14 (gtk 2.22),

Chris please try my snippet and let me know if it works or it fails on your machine.

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

public class PR342648 {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());
		
		Listener listener = new Listener () {
			public void handleEvent(Event event) {
				Tree tree = (Tree)event.widget;
				Point p = new Point(event.x, event.y);
				TreeItem item = tree.getItem(p);
				System.out.println("point " + p + " item " + item);
			}
		};
		
		final Tree tree = new Tree(shell, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
		for (int i = 0; i < 4; i++) {
			TreeItem item = new TreeItem(tree, SWT.NONE);
			item.setText("root " + i);
			for (int j = 0; j < 4; j++) {
				TreeItem subItem = new TreeItem(item, SWT.NONE);
				subItem.setText("item " + j);
				for (int k = 0; k < 4; k++) {
					TreeItem subsubItem = new TreeItem(subItem, SWT.NONE);
					subsubItem.setText("subsubitem " + k);
				}
			}
		}
		tree.addListener(SWT.MouseDown, listener);
		final Tree treeRTL = new Tree(shell, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.RIGHT_TO_LEFT);
		for (int i = 0; i < 4; i++) {
			TreeItem item = new TreeItem(treeRTL, SWT.NONE);
			item.setText("rootRTL " + i);
			for (int j = 0; j < 4; j++) {
				TreeItem subItem = new TreeItem(item, SWT.NONE);
				subItem.setText("itemRTL " + j);
				for (int k = 0; k < 4; k++) {
					TreeItem subsubItem = new TreeItem(subItem, SWT.NONE);
					subsubItem.setText("subsubitemRTL " + k);
				}
			}
		}
		treeRTL.addListener(SWT.MouseDown, listener);
		shell.setSize(400, 400);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
	}
}
Comment 5 Chris Goldthorpe CLA 2011-04-20 13:28:13 EDT
On my machine the test fails in the following way: If I click on an expander in the RTL side of the screen I do not see "item null" as expected, instead I see item TreeItem.
Comment 6 Felipe Heidrich CLA 2011-04-21 14:18:24 EDT
Created attachment 193870 [details]
patch
Comment 7 Felipe Heidrich CLA 2011-04-21 14:18:51 EDT
Fixed in HEAD
Comment 8 Chris Goldthorpe CLA 2011-04-22 12:20:41 EDT
Verified in I20110421-1800
Comment 9 Chris Goldthorpe CLA 2011-04-22 12:22:25 EDT
*** Bug 342617 has been marked as a duplicate of this bug. ***