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

Bug 352693

Summary: CDateTimeCellEditor steals focus as CellEditor
Product: z_Archived Reporter: Jermaine Rattray <jermaine.rattray>
Component: NebulaAssignee: Wim Jongman <wim.jongman>
Status: CLOSED NOT_ECLIPSE QA Contact:
Severity: minor    
Priority: P3 CC: peter, strider80
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

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.