Bug 203427

Summary: [PropertiesView] Two Apply Events When Enter Pressed - Enter Does Not call deactivateCellEditor
Product: [Eclipse Project] Platform Reporter: Marcus O'Brien <marcusobrien>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: ASSIGNED --- QA Contact:
Severity: normal    
Priority: P3 CC: cchen, tom.schindl
Version: 3.3Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 202378    

Description Marcus O'Brien CLA 2007-09-14 07:04:36 EDT
Ok,

All code is in the org.eclipse.ui.views.

We have some properties in a PropertySheetViewer. It is possible to edit the values. Using the mouse click to move out of a cell after editing works fine.

There is a problem however with the following series of actions...

1. Click on a cell
2. Edit the cell's values
3. Press enter

At this stage the following has occured..

CellEditor::run
ICellEditorListener::applyEditorValue
PropertySheetEntry::applyEditorValue - This applies the new value

Now we click on a different cell - MouseDown event

PropertySheetViewer::hookControl - see comment in code "// Part2: handle single click activation of cell editor"
PropertySheetViewer::handleSelect

In PropertySheetViewer::handleSelect, the first couple of lines are

if (cellEditor != null) {
            applyEditorValue();
            deactivateCellEditor();
        }

And guess what ? The cellEditor has not been disposed of. It is disposed when using the mouse clicking mechanism (ie after editing cell immediately click on another cell, as opposed to enter key). So the applyEditorValue is done twice.

Proposed fix is....

In PropertySheetViewer::hookControl

Add the following...

        //when we move off the cell via the enter key the changes will have been applied
        //we now need to clean up the editor, so we dont apply the changes twice
        tree.addKeyListener(new KeyAdapter() {
            public void keyReleased(KeyEvent e) {
                if (e.character == SWT.CR) {
			deactivateCellEditor();
		}
            }
        });


I will attempt to commit (submit for review) this code, but it's my first attempt at changing the eclipse source....

Marcus.
Comment 1 Eric Moffatt CLA 2007-09-18 13:46:39 EDT
Thanks Marcus, I'll be glad to review (and appreciate) any patch you might supply. If applied it also gets you an 'attribution' in the eclipse source...;-).
Comment 2 Chen Chao CLA 2007-10-29 04:33:43 EDT
I found the bug also. It always apply value twice every time. It just reproduces on eclipse 3.4.
Comment 3 Eclipse Webmaster CLA 2019-09-06 16:12:14 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.