Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Why ColumnViewerEditorActivationListener isn't called
Why ColumnViewerEditorActivationListener isn't called [message #330321] Fri, 25 July 2008 10:26 Go to next message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
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) {
}
});
Re: Why ColumnViewerEditorActivationListener isn't called [message #330322 is a reply to message #330321] Fri, 25 July 2008 10:38 Go to previous messageGo to next message
David  Pérez is currently offline David PérezFriend
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) {
> }
> });
Re: Is this the best place to JFace questions [message #330333 is a reply to message #330322] Fri, 25 July 2008 15:40 Go to previous messageGo to next message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
I wonder if this is the right forum for JFace questions.
Re: Is this the best place to JFace questions [message #330339 is a reply to message #330333] Fri, 25 July 2008 18:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

David Perez wrote:
> I wonder if this is the right forum for JFace questions.
>

Yes, it is.
Re: Why ColumnViewerEditorActivationListener isn't called [message #330357 is a reply to message #330321] Sat, 26 July 2008 03:06 Go to previous messageGo to next message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
Have you created TableViewerColumn objects and called setEditingSupport on
them?

"David Perez" <craquerpro@yahoo.es> wrote in message
news:97d3a0a17f893b9a8b7abf57dc88b011$1@www.eclipse.org...
>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) {
> }
> });
>
Re: Why ColumnViewerEditorActivationListener isn't called [message #330385 is a reply to message #330357] Mon, 28 July 2008 09:06 Go to previous messageGo to next message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
Thanks Boris.
Yes, I've done so. Otherwise, editing a cell wouldn't work at all.

Boris Bokowski wrote:

> Have you created TableViewerColumn objects and called setEditingSupport on
> them?

> "David Perez" <craquerpro@yahoo.es> wrote in message
> news:97d3a0a17f893b9a8b7abf57dc88b011$1@www.eclipse.org...
>>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) {
>> }
>> });
>>
Re: Why ColumnViewerEditorActivationListener isn't called [message #330389 is a reply to message #330322] Mon, 28 July 2008 09:41 Go to previous messageGo to next message
David  Pérez is currently offline David PérezFriend
Messages: 228
Registered: July 2009
Senior Member
If necessary, I can provide a full example.

David Perez wrote:

> 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.
Re: Why ColumnViewerEditorActivationListener isn't called [message #330580 is a reply to message #330385] Mon, 04 August 2008 12:23 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Please provide a fully running snippet and then file a bug. CC me and
Boris and we'll have a look.

Tom

David Perez schrieb:
> Thanks Boris.
> Yes, I've done so. Otherwise, editing a cell wouldn't work at all.
>
> Boris Bokowski wrote:
>
>> Have you created TableViewerColumn objects and called
>> setEditingSupport on them?
>
>> "David Perez" <craquerpro@yahoo.es> wrote in message
>> news:97d3a0a17f893b9a8b7abf57dc88b011$1@www.eclipse.org...
>>> 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) {
>>> }
>>> });
>>>
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Previous Topic:Default behaviour for find TableItem associated to a TableViewer element
Next Topic:JFace snippet doesn't compile
Goto Forum:
  


Current Time: Wed Jul 17 20:22:04 GMT 2024

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

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

Back to the top