Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » bug in table / table viewer
bug in table / table viewer [message #459945] Fri, 19 August 2005 21:11 Go to next message
Bhadri Madapusi is currently offline Bhadri MadapusiFriend
Messages: 18
Registered: July 2009
Junior Member
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();

}
Re: bug in table / table viewer [message #460068 is a reply to message #459945] Sun, 21 August 2005 23:38 Go to previous messageGo to next message
Chris is currently offline ChrisFriend
Messages: 17
Registered: July 2009
Junior Member
Hi Bhadri,

in your editElement method, why do you call setSelection()? If you remove
this line it should work.
Re: bug in table / table viewer [message #460201 is a reply to message #460068] Mon, 22 August 2005 16:24 Go to previous messageGo to next message
Bhadri Madapusi is currently offline Bhadri MadapusiFriend
Messages: 18
Registered: July 2009
Junior Member
editElement method is provided by jface's TableViewerImpl class. I do not
know why they call setSelection. I will create my own version of impl and
play around with your suggestion. Thanks.

"Chris" <chrisgumms@hotmail.com> wrote in message
news:a0aaaa1aa34c7dd6a1b249aec9b2eae3$1@www.eclipse.org...
> Hi Bhadri,
>
> in your editElement method, why do you call setSelection()? If you remove
> this line it should work.
>
Re: bug in table / table viewer [message #460225 is a reply to message #460201] Mon, 22 August 2005 22:57 Go to previous message
Chris is currently offline ChrisFriend
Messages: 17
Registered: July 2009
Junior Member
Bhadri Madapusi wrote:

> editElement method is provided by jface's TableViewerImpl class. I do not
> know why they call setSelection. I will create my own version of impl and
> play around with your suggestion. Thanks.

OK, sorry I've never seen it anywhere and its not in CVS!?
Previous Topic:Image from an URL
Next Topic:How to Minisized A CTabFolder in SashForm
Goto Forum:
  


Current Time: Tue Apr 23 12:53:45 GMT 2024

Powered by FUDForum. Page generated in 0.02888 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top