Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 55275 - [Viewers] JFace TableViewer passing the wrong property to CellModifier
Summary: [Viewers] JFace TableViewer passing the wrong property to CellModifier
Status: RESOLVED DUPLICATE of bug 55485
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1.2   Edit
Hardware: PC Windows XP
: P4 normal (vote)
Target Milestone: ---   Edit
Assignee: Tod Creasey CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-18 15:08 EST by Chris Nagy CLA
Modified: 2004-04-14 15:41 EDT (History)
1 user (show)

See Also:


Attachments
Test Case (31.25 KB, application/octet-stream)
2004-03-18 15:09 EST, Chris Nagy CLA
no flags Details
Patch to org.eclipse.jface.viewers.TableViewerImpl (2.1.2) (737 bytes, patch)
2004-03-18 15:31 EST, Chris Nagy CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Nagy CLA 2004-03-18 15:08:43 EST
If the TableViewer has some columns that are readonly, it will pass the wrong
property to the CellModifier in the following case:

1. Click on ComboBoxCellEditor's column to initiate the editing.
2. Click on the read only column to cancel editing and the value of the
ComboBoxCellEditor will be passed to CellModifier with the read only column's
property.

I've attached a modification to the 'Building and delivering a table editor with
SWT/JFace' which illustrates this problem. In this modification, all columns
except the last one are editable. To reproduce,

1. Click on a value in the 'owner' column to initiate editing.
2. Click on the value in the '% complete' column to cause a ClassCastException
to be thrown.
Comment 1 Chris Nagy CLA 2004-03-18 15:09:35 EST
Created attachment 8665 [details]
Test Case
Comment 2 Chris Nagy CLA 2004-03-18 15:28:49 EST
I've also been able to figure out why this bug is happening and propose a patch
for the TableViewerImpl.
Basically, the columnNumber and the cellEditor members have to be kept in synch.
If the user clicks on a column, the columnNumber property automatically changes
and the cellEditor may not change (if it is read only).

This results into following changes

- activateCellEditor() should be changed to activateCellEditor(int) where the
first param is the newColumnNumber
- in the activateCellEditor method, the columnNumber property should be set
after the cellEditor is assigned.

This problem may also appear in 3.0 (I briefly looked at 3.0M7 and found the
same code).
Comment 3 Chris Nagy CLA 2004-03-18 15:31:24 EST
Created attachment 8666 [details]
Patch to org.eclipse.jface.viewers.TableViewerImpl (2.1.2)
Comment 4 Ines Khelifi CLA 2004-04-14 14:16:59 EDT
I think this is a duplicate of Bug# 34819, which is now fixed.
Comment 5 Tod Creasey CLA 2004-04-14 14:26:22 EDT
Ines please verify if this is now fixed.
Comment 6 Ines Khelifi CLA 2004-04-14 15:29:23 EDT
This bug has been verified. It's now fixed. It's a duplicate of Bug# 5548. 
While trying to fix the "ESC" problem, I ran into this bug with the Class Cast 
Exception. It now has been fixed, with the focus fix for Bug# 34819. 
Comment 7 Ines Khelifi CLA 2004-04-14 15:35:14 EDT
It's a duplicate of Bug#:55485. My mistake. I was getting the same cast 
exception running the same example you attached. It's now fixed and verified.
Comment 8 Tod Creasey CLA 2004-04-14 15:41:34 EDT

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