|
Re: Why ColumnViewerEditorActivationListener isn't called [message #330322 is a reply to message #330321] |
Fri, 25 July 2008 10:38 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
David Pérez![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=david.perez.ingeniero%40gmail.com) Messages: 228 Registered: July 2009 |
Senior Member |
|
|
I'm going to explain more in depth my problem.
In my TableViewer, when the user changes the current row, its contents are
validated, and saved. If they aren't correct, the selection is set back
to the edited row.
I do this thru a selection listener:
viewer.addSelectionChangedListener(selChanged = new
ISelectionChangedListener() {
public void selectionChanged(final SelectionChangedEvent event) {
selectionChanged();
}
});
int lastIndex;
Object lastSel;
protected void selectionChanged() {
if (ignoreSel > 0) {
return;
}
ignoreSel++;
try {
IStructuredSelection sel =
(IStructuredSelection)viewer.getSelection();
Object sel1 = sel.getFirstElement();
if (sel1 == lastSel || saveCurrentRow()) {
lastSel = sel1;
lastIndex = viewer.getTable().getSelectionIndex();
} else {
viewer.cancelEditing();
// If we cannot save current row, then come back
viewer.getTable().setSelection(lastIndex);
}
} finally {
ignoreSel--;
}
}
The problem:
One the user double clicks a cell in another row, that cell is activated,
even though I set the selection back to the old row.
How can I stop the activation going to that cell?
Any help will be grealty appreciated.
David Perez wrote:
> I have created a TableViewer and register a listener, which isn't called
> at all, even when I double click a cell in order to edit it.
> tableViewer.getColumnViewerEditor().addEditorActivationListe ner(new
> ColumnViewerEditorActivationListener() {
> @Override public void
> afterEditorActivated(ColumnViewerEditorActivationEvent event) {
> }
> @Override public void
> afterEditorDeactivated(ColumnViewerEditorDeactivationEvent event) {
> }
> @Override public void
> beforeEditorActivated(ColumnViewerEditorActivationEvent event) {
> CrudContentProvider.this.beforeEditorActivated(event);
> }
> @Override public void
> beforeEditorDeactivated(ColumnViewerEditorDeactivationEvent event) {
> }
> });
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03618 seconds