Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352693 - CDateTimeCellEditor steals focus as CellEditor
Summary: CDateTimeCellEditor steals focus as CellEditor
Status: CLOSED NOT_ECLIPSE
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Nebula (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 minor with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Wim Jongman CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-20 23:29 EDT by Jermaine Rattray CLA
Modified: 2021-07-05 11:40 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jermaine Rattray CLA 2011-07-20 23:29:35 EDT
Build Identifier: 20110615-0604

If a CDateTimeCellEditor is used as the editor in an EdtiSupport implementation the selection is not passed on if the drop down is activated, as the editor loses focus.

The fix found was to override org.eclipse.jface.viewers.CellEditor#dependsOnExternalFocusListener() and have it return false (as was suggested in the javadoc).

/* (non-Javadoc)
* @see org.eclipse.jface.viewers.CellEditor#dependsOnExternalFocusListener()
*/
@Override
protected boolean dependsOnExternalFocusListener() {
	//Prevent the popup from stealing focus.
	return false;
}




Reproducible: Always

Steps to Reproduce:
1.Instantiate a table viewer table (may be the same for trees as well, not tested though).
2.Add a table viewer column, then add editing support the column. Have the editing support return a CDateTimeComboCellEditor as its cell editor.
3.Populate the table and launch the application. 
4.Select a cell which would trigger the editor in question. Once the drop down button becomes visible, select it. 
The cell editor should now lose focus with the drop down visible.
Subsequent selections are not propagated to the underlying object.
Comment 1 Emil Crumhorn CLA 2011-07-21 07:12:13 EDT
Reassigned as it was filed against wrong component.
Comment 2 Wim Jongman CLA 2011-11-16 17:04:32 EST
Hi, since you have found a fix, can we close this? If not, please provide code that exposes the bug so that we can have a look.
Comment 3 Henno Vermeulen CLA 2013-01-16 12:26:33 EST
I am having the same issue. Unfortunately the proposed fix introduces a new bug where the cell editor does not apply the value + deactivate in case the focus is lost.

I think the best solution to the bug would be to change CDateTime so that it does not fire a focusLost event when it's text field loses focus to the graphical date selector.

In the meantime, this should help to fix the additional issue:

	protected Control createControl(Composite parent) {
		final CDateTime cdt = (CDateTime) super.createControl(parent);
		cdt.addFocusListener(new FocusAdapter() {
			public void focusLost(FocusEvent e) {
				if (!cdt.isOpen()) {
					fireApplyEditorValue();
					deactivate();
				}
			}
		});
		return cdt;
	}
Comment 4 Henno Vermeulen CLA 2013-01-17 04:52:38 EST
The focus issue I mentioned was already reported as bug 287511.