TableViewerImpl - edit element bug? [message #290002] |
Tue, 16 August 2005 22:57 |
Eclipse User |
|
|
|
Originally posted by: bomadapusi75.yahoo.com
I am trying to add a traverse listener on a table. When a row is selected
and someone presses Enter key, then I want the cell editor in the first
column to be activated.
What I did was add a traverse listener to the table as follows
table.addTraverseListener(new TraverseListener(){
public void keyTraversed(TraverseEvent e) {
if(e.detail == SWT.TRAVERSE_RETURN){
e.doit=false;
TableItem tableItem =
table.getItem(table.getSelectionIndex());
tableViewer.editElement(new
StructuredSelection(tableItem.getData()), 1);
}
}
});
But the TableViewerImpl.editElement() returns without activating the cell
editor. Culprit seems to be getSelection(), it returns TabItem[0] (zero
length array) even though a table item is selected. Am I missing something
or is this some kind of bug in the Table.getSelection() method?
TableViewerImpl.editElement()
/**
* Start editing the given element.
*/
public void editElement(Object element, int column) {
if (cellEditor != null)
applyEditorValue();
setSelection(new StructuredSelection(element), true);
Item[] selection = getSelection();
if (selection.length != 1)
return;
tableItem = selection[0];
// Make sure selection is visible
showSelection();
columnNumber = column;
activateCellEditor();
}
|
|
|
Powered by
FUDForum. Page generated in 0.02200 seconds