Community
Participate
Working Groups
Bug appeared on migration from M4 to RC2 - Linux GTK platform, JDK 1.3.1 Table has 2 columns, multiple rows column 0 : text display with TextCellEditor (arbitary text) column 1 : text display with subclass of DialogCellEditor - opens a FileDialog Steps: 1 - all rows/column have data set 2 - select column 1 - DialogCellEditor displayed as expected 3 - do not change anything but immediately select column 0 - TextCellEditor displays as expected 4 - then select column 0 of any other row BUG : the original column 0 now displays the DialogCellEditor for its row. Need sample code? Could strip out with a bit of work.
Please provide sample code.
Sample code provided by Mike: import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnLayoutData; import org.eclipse.jface.viewers.ColumnWeightData; import org.eclipse.jface.viewers.DialogCellEditor; import org.eclipse.jface.viewers.ICellModifier; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.EditorPart; /** * Bug demo : * 1 : Add the following to plugin.xml * <extension point="org.eclipse.ui.editors"> <editor name="BugDemo" icon="dummy.gif" extensions="bugdemo" class="BugDemo" id="BugDemo"> </editor> </extension> 2: compile and deploy this class 3 : in runtime workspace, create empty (actually any) file ending '.bugdemo'. 4 : 'open' the file - i.e. this editor 5 : follow three steps given in displayed text. Regards, MikeE * @author mikee */ public class BugDemo extends EditorPart { private static final String COLUMN0 = "Text Column"; private static final String COLUMN1 = "File Dialog Column"; private TableViewer viewer; public BugDemo() { super(); viewer = null; } public void doSave(IProgressMonitor monitor) {} public void doSaveAs() {} public void gotoMarker(IMarker marker) {} public void init(IEditorSite site, IEditorInput input) throws PartInitException { setSite( site ); setInput( input ); } public boolean isDirty() { return false; } public boolean isSaveAsAllowed() { return false; } public void createPartControl(Composite parent) { viewer = new TableViewer( parent, SWT.MULTI | SWT.FULL_SELECTION); // table gui setup Table table = viewer.getTable(); TableColumn column0 = new TableColumn( table, SWT.LEFT ); column0.setText( COLUMN0 ); ColumnLayoutData column0Data = new ColumnWeightData( 1, true ); TableColumn column1 = new TableColumn( table, SWT.LEFT ); column1.setText( COLUMN1 ); ColumnLayoutData column1Data = new ColumnWeightData ( 1, true ); TableLayout layout = new TableLayout(); layout.addColumnData( column0Data ); layout.addColumnData( column1Data ); table.setLayout( layout ); table.setLinesVisible( true ); table.setHeaderVisible( true ); // viewer setup viewer.setColumnProperties( new String[] { COLUMN0, COLUMN1 } ); viewer.setContentProvider( new BugDemoContentProvider() ); viewer.setCellModifier( new BugDemoCellModifier() ); viewer.setLabelProvider( new BugDemoLabelProvider() ); // crucially for bug demo - cell editors CellEditor editor0 = new TextCellEditor( table ); CellEditor editor1 = new FileSelectCellEditor( table ); viewer.setCellEditors( new CellEditor[]{ editor0, editor1 } ); viewer.setInput( new Object() ); } public void setFocus() { viewer.getTable().setFocus(); } /* private subclass of DialogCellEditor - the one of interest in bug */ private class FileSelectCellEditor extends DialogCellEditor { private FileSelectCellEditor(Composite parent) { super(parent); } protected Object openDialogBox(Control cellEditorWindow) { return null; } } /* private boilerplate classes */ // content provider private class BugDemoContentProvider implements IStructuredContentProvider { public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} public Object[] getElements(Object inputElement) { return new RowData[] { new RowData( "click here second", "click here first"), new RowData( "click here third - when you do look at the value above", "do not click here") }; } } // model row private class RowData { public String column0Value; public String column1Value; RowData( String val0, String val1){ column0Value = val0; column1Value = val1; } } // cell modifier private class BugDemoCellModifier implements ICellModifier { public boolean canModify(Object element, String property) { return true; } public void modify(Object element, String property, Object value) {} public Object getValue(Object element, String property) { if ( property.equals( COLUMN0) ){ return ((RowData)element).column0Value; } else { return ((RowData)element).column1Value; } } } // label provider private class BugDemoLabelProvider extends LabelProvider implements ITableLabelProvider { public Image getColumnImage(Object element, int columnIndex) { return null; } public String getColumnText(Object element, int columnIndex) { if ( columnIndex == 0 ) { return ((RowData)element).column0Value; } else { return ((RowData)element).column1Value; } } } }
The same bug appears with Version 2.1 and Windows 2000
Same here! The problem is not shown in 2.0.1 but shown in 2.1. I traced it in debug mode and seems the actions are like this: 1. select a DialogCellEditor A, this fires the MouseDown event on A 2. leave A by selecting another table column B without doing anything on A, this will fire another MouseDown event on B 3. after MouseDown event on B finish, in TableViewerImpl, it begin to run those deferred event, which is FocusLost on A, here, it calls applyEditorValue which actually apply editor A's value to B!
I think I have a solution for this bug (or it may be a solution to another bug which annoys me). In my dialog editor (a subclass of DialogCellEditor) I have added the following code: /* (non-Javadoc) * @see org.eclipse.jface.viewers.CellEditor#createControl (org.eclipse.swt.widgets.Composite) */ protected Control createControl(Composite parent) { Control cont = super.createControl(parent); cont.addListener(SWT.Deactivate, new Listener() { public void handleEvent(Event event) { MyDialogCellEditor.this.focusLost(); } }); return cont; } Now the focus lost events are received correctly and the editor is properly deactivated.
We've noticed the same behaviour and have observed that we get an activateCellEditor method call in TableViewerImpl before the previous cell editor is deactivated. The handleMouseDown method does not do an explicit deactivation of a cell editor that may still be active in the table.
My previous post had a problem. Here is a code that really works: Override the createButton() method: protected Button createButton(Composite parent) { Button dialogButton = super.createButton(parent); dialogButton.addListener(SWT.FocusOut, new Listener() { public void handleEvent(Event event) { if (!isDialogOpen) { System.out.println("focus lost"); URLListCellEditor.this.focusLost(); } } }); return dialogButton; } Now in the #openDialogBox() method i have the following code protected Object openDialogBox(Control cellEditorWindow) { .......... .... isDialogOpen = true; int res = dlg.open(); isDialogOpen = false; if (res != Dialog.OK) { ...... } .... .......... } This is a hack ... I hope to see it fixed in 2.1.1 ....
*** Bug 39517 has been marked as a duplicate of this bug. ***
Created attachment 5360 [details] Another ugly Workaround Bug still in 2.1.1 :( Another Workaround seems to change the TableViewer so it activly deactivates the CellEditor if another cell is selected. See Attachment. Only tested on linux-gtk and linux-motif
This bug is occasion in windows platform... :-(
Is this possibly a JFace cell editor bug? Note the same bug exists on both Windows and GTK.
This is quite annoying. If one has a large table with lots of editors and clicks quite fast on lots of different cells one ends up with several stale editors. Code from comment 7 seems to work.
This seems to be a JFace bug - moving to the UI team.
Created attachment 8876 [details] Add a FocusListener which disposes of the button on loss of focus The focuslistener has been added to the button within the createontrol() method
I believe the problem happens on the handleMouseDown method in the TableViewerImpl class. Its implementation changed between 2.0.1 and the following releases. The 2.0.1 implementation of that method used to deactivate the cell by calling the applyEditorValue. That method does not get called in the current implementation of handleMouseDown, which could be causing these activations problems.
Created attachment 9342 [details] Proposed patch for cell bug Added a check to disable the cell is it's enaled.
Regression that occured due to other changes. The apply code for the mouseDown has been restored. Fixed in build >20040412
Can we have it in the 2.1.x stream as well ?
We won't be patching the 2.1.x stream any more to the best of my knowledge.
*** Bug 55485 has been marked as a duplicate of this bug. ***
*** Bug 59040 has been marked as a duplicate of this bug. ***
Hi, is this patched in 3.0
Marking to verify in 3.1 M5.
Verified in 20050215-1200