| Summary: | ArrayIndexOutofBoundsException when clicking on the Pixel Row just below the Table Header. | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Jeff <jeff.lau> | ||||
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | daniel.zweifel | ||||
| Version: | 1.2 | ||||||
| Target Milestone: | 1.3 M1 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 141584 [details]
Bugfix
Changes are in CVS HEAD. *** Bug 289975 has been marked as a duplicate of this bug. *** |
As an example let say I have a table with 2 rows and the row height is 20 pixels each. The first row is the header, since the height is 20 pixels the y coordinate goes from 0 to 19 and the y coordinate of the 2nd row goes from 20 to 39. If I click on the table where the y coordinate = 20, I would get a ArrayIndexOutofBoundsException in my log, with the following stacktrace: java.lang.ArrayIndexOutOfBoundsException: -1 at org.eclipse.swt.widgets.Table._getItem(Table.java:2101) at org.eclipse.swt.widgets.Table.getItem(Table.java:676) at org.eclipse.jface.viewers.TableViewer.getItemAt(TableViewer.java:197) at org.eclipse.jface.viewers.ColumnViewer.getViewerRow(ColumnViewer.java:150) at org.eclipse.jface.viewers.ColumnViewer.getCell(ColumnViewer.java:133) at org.eclipse.jface.viewers.ColumnViewer.handleMouseDown(ColumnViewer.java:649) at org.eclipse.jface.viewers.ColumnViewer.access$0(ColumnViewer.java:648) at org.eclipse.jface.viewers.ColumnViewer$1.mouseDown(ColumnViewer.java:88) The problem I believe is with the following code in the Table class. public TableItem getItem( final Point point ) { checkWidget(); TableItem result = null; int headerHeight = getHeaderHeight(); Rectangle itemArea = getClientArea(); itemArea.y += headerHeight; if( itemArea.contains( point ) ) { int itemHeight = getItemHeight(); int index = ( ( point.y - headerHeight ) / itemHeight ) - 1; if( point.y == 0 || point.y % itemHeight != 0 ) { index++; } index += topIndex; if( index < itemCount ) { result = _getItem( index ); } } return result; } The itemArea contains the point which is correct, but the calculation of the index is incorrect. In this case where point.y = 20, if u step through the above code u will see the index value at the end is -1, causing the exception. (topIndex is 0)