Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » TableViewerColume and editing
TableViewerColume and editing [message #328265] Tue, 20 May 2008 14:33 Go to next message
Carmelo  is currently offline Carmelo Friend
Messages: 224
Registered: July 2009
Senior Member
Hi all

I'm using TableViewerColum to set label provider and editing support for my
table viewer. (see snippet 19 about new api)

What I find annoying is that each time the cursor goes on the editable cell
immediately the cell goes in editing . is there any way to stop this
behaviors and use F2 (via keylistener to fire the editing) or a rename
action from the context menu?


Thanks
Kar
Re: TableViewerColume and editing [message #328267 is a reply to message #328265] Tue, 20 May 2008 14:40 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Sure. You'll have to tweak your ColumnViewerEditorActivationStrategy and
only allow editor activation on PROGRAMMATIC and TABBING Events.
Afterwards you activate an editor using TableViewer#editElement() to
fire up the editor on keypress.

Tom

KarSc schrieb:
> Hi all
>
> I'm using TableViewerColum to set label provider and editing support for
> my table viewer. (see snippet 19 about new api)
>
> What I find annoying is that each time the cursor goes on the editable
> cell immediately the cell goes in editing . is there any way to stop
> this behaviors and use F2 (via keylistener to fire the editing) or a
> rename action from the context menu?
>
>
> Thanks
> Kar
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: TableViewerColume and editing [message #328271 is a reply to message #328267] Tue, 20 May 2008 15:26 Go to previous messageGo to next message
Carmelo  is currently offline Carmelo Friend
Messages: 224
Registered: July 2009
Senior Member
Hi Tom thanks for ur help but still not able to let table works as I want
....

I'm sure I'm using the ColumnViewerEditorActionStrategy class in a wrong way
....

here is my code ... what have I done wrong (the class is not called) ???

thanks
Kar


private void initLabelProvider(TableViewer viewer)
{
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new NameLabelProvider(viewer));
column.setEditingSupport(new NameEditing(viewer));
column.getColumn().setWidth(200);
column.getColumn().setText("Name");
column.getColumn().setMoveable(true);

column = new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new SizeLabelProvider());
column.getColumn().setWidth(150);
column.getColumn().setText("Size");
column.getColumn().setMoveable(true);

column = new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new TypeLabelProvider());
column.getColumn().setWidth(100);
column.getColumn().setText("Type");
column.getColumn().setMoveable(true);

column = new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new LockedByLabelProvider());
column.getColumn().setWidth(100);
column.getColumn().setText("Locked by");
column.getColumn().setMoveable(true);

column = new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new StatusLabelProvider());
column.getColumn().setWidth(150);
column.getColumn().setText("Status");
column.getColumn().setMoveable(true);

new ColumnViewerEditorActivationStrategy(viewer)
{
@Override
protected boolean
isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
{
return event.keyCode == SWT.F2;
}
};

}

"Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
news:g0unt8$hd3$1@build.eclipse.org...
> Sure. You'll have to tweak your ColumnViewerEditorActivationStrategy and
> only allow editor activation on PROGRAMMATIC and TABBING Events.
> Afterwards you activate an editor using TableViewer#editElement() to fire
> up the editor on keypress.
>
> Tom
>
> KarSc schrieb:
>> Hi all
>>
>> I'm using TableViewerColum to set label provider and editing support for
>> my table viewer. (see snippet 19 about new api)
>>
>> What I find annoying is that each time the cursor goes on the editable
>> cell immediately the cell goes in editing . is there any way to stop this
>> behaviors and use F2 (via keylistener to fire the editing) or a rename
>> action from the context menu?
>>
>>
>> Thanks
>> Kar
>>
>>
>
>
> --
> B e s t S o l u t i o n . at
> ------------------------------------------------------------ --------
> Tom Schindl JFace-Committer
> ------------------------------------------------------------ --------
Re: TableViewerColume and editing [message #328273 is a reply to message #328271] Tue, 20 May 2008 15:33 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Take a look at this snippet
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet044NoColumnTableViewerKeyboardEditing.java? view=markup

Tom

KarSc schrieb:
> Hi Tom thanks for ur help but still not able to let table works as I
> want ...
>
> I'm sure I'm using the ColumnViewerEditorActionStrategy class in a wrong
> way ...
>
> here is my code ... what have I done wrong (the class is not called) ???
>
> thanks
> Kar
>
>
> private void initLabelProvider(TableViewer viewer)
> {
> TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
> column.setLabelProvider(new NameLabelProvider(viewer));
> column.setEditingSupport(new NameEditing(viewer));
> column.getColumn().setWidth(200);
> column.getColumn().setText("Name");
> column.getColumn().setMoveable(true);
>
> column = new TableViewerColumn(viewer, SWT.NONE);
> column.setLabelProvider(new SizeLabelProvider());
> column.getColumn().setWidth(150);
> column.getColumn().setText("Size");
> column.getColumn().setMoveable(true);
>
> column = new TableViewerColumn(viewer, SWT.NONE);
> column.setLabelProvider(new TypeLabelProvider());
> column.getColumn().setWidth(100);
> column.getColumn().setText("Type");
> column.getColumn().setMoveable(true);
>
> column = new TableViewerColumn(viewer, SWT.NONE);
> column.setLabelProvider(new LockedByLabelProvider());
> column.getColumn().setWidth(100);
> column.getColumn().setText("Locked by");
> column.getColumn().setMoveable(true);
>
> column = new TableViewerColumn(viewer, SWT.NONE);
> column.setLabelProvider(new StatusLabelProvider());
> column.getColumn().setWidth(150);
> column.getColumn().setText("Status");
> column.getColumn().setMoveable(true);
>
> new ColumnViewerEditorActivationStrategy(viewer)
> {
> @Override
> protected boolean
> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
> {
> return event.keyCode == SWT.F2;
> }
> };
>
> }
>
> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
> news:g0unt8$hd3$1@build.eclipse.org...
>> Sure. You'll have to tweak your ColumnViewerEditorActivationStrategy
>> and only allow editor activation on PROGRAMMATIC and TABBING Events.
>> Afterwards you activate an editor using TableViewer#editElement() to
>> fire up the editor on keypress.
>>
>> Tom
>>
>> KarSc schrieb:
>>> Hi all
>>>
>>> I'm using TableViewerColum to set label provider and editing support
>>> for my table viewer. (see snippet 19 about new api)
>>>
>>> What I find annoying is that each time the cursor goes on the
>>> editable cell immediately the cell goes in editing . is there any way
>>> to stop this behaviors and use F2 (via keylistener to fire the
>>> editing) or a rename action from the context menu?
>>>
>>>
>>> Thanks
>>> Kar
>>>
>>>
>>
>>
>> --
>> B e s t S o l u t i o n . at
>> ------------------------------------------------------------ --------
>> Tom Schindl JFace-Committer
>> ------------------------------------------------------------ --------
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: TableViewerColume and editing [message #328274 is a reply to message #328273] Tue, 20 May 2008 15:50 Go to previous messageGo to next message
Carmelo  is currently offline Carmelo Friend
Messages: 224
Registered: July 2009
Senior Member
I did found the example but I was using the TableViewerEditor.create without
the focus cell manager ...
guess without doesn't work ...
but where do I get the FocusBorderCellHighlighter is it part of 3.4Mx?

thanks

"Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
news:g0uqvq$dvn$1@build.eclipse.org...
> Take a look at this snippet
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet044NoColumnTableViewerKeyboardEditing.java? view=markup
>
> Tom
>
> KarSc schrieb:
>> Hi Tom thanks for ur help but still not able to let table works as I want
>> ...
>>
>> I'm sure I'm using the ColumnViewerEditorActionStrategy class in a wrong
>> way ...
>>
>> here is my code ... what have I done wrong (the class is not called) ???
>>
>> thanks
>> Kar
>>
>>
>> private void initLabelProvider(TableViewer viewer)
>> {
>> TableViewerColumn column = new TableViewerColumn(viewer,
>> SWT.NONE);
>> column.setLabelProvider(new NameLabelProvider(viewer));
>> column.setEditingSupport(new NameEditing(viewer));
>> column.getColumn().setWidth(200);
>> column.getColumn().setText("Name");
>> column.getColumn().setMoveable(true);
>>
>> column = new TableViewerColumn(viewer, SWT.NONE);
>> column.setLabelProvider(new SizeLabelProvider());
>> column.getColumn().setWidth(150);
>> column.getColumn().setText("Size");
>> column.getColumn().setMoveable(true);
>>
>> column = new TableViewerColumn(viewer, SWT.NONE);
>> column.setLabelProvider(new TypeLabelProvider());
>> column.getColumn().setWidth(100);
>> column.getColumn().setText("Type");
>> column.getColumn().setMoveable(true);
>>
>> column = new TableViewerColumn(viewer, SWT.NONE);
>> column.setLabelProvider(new LockedByLabelProvider());
>> column.getColumn().setWidth(100);
>> column.getColumn().setText("Locked by");
>> column.getColumn().setMoveable(true);
>>
>> column = new TableViewerColumn(viewer, SWT.NONE);
>> column.setLabelProvider(new StatusLabelProvider());
>> column.getColumn().setWidth(150);
>> column.getColumn().setText("Status");
>> column.getColumn().setMoveable(true);
>>
>> new ColumnViewerEditorActivationStrategy(viewer)
>> {
>> @Override
>> protected boolean
>> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
>> {
>> return event.keyCode == SWT.F2;
>> }
>> };
>>
>> }
>>
>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
>> news:g0unt8$hd3$1@build.eclipse.org...
>>> Sure. You'll have to tweak your ColumnViewerEditorActivationStrategy and
>>> only allow editor activation on PROGRAMMATIC and TABBING Events.
>>> Afterwards you activate an editor using TableViewer#editElement() to
>>> fire up the editor on keypress.
>>>
>>> Tom
>>>
>>> KarSc schrieb:
>>>> Hi all
>>>>
>>>> I'm using TableViewerColum to set label provider and editing support
>>>> for my table viewer. (see snippet 19 about new api)
>>>>
>>>> What I find annoying is that each time the cursor goes on the editable
>>>> cell immediately the cell goes in editing . is there any way to stop
>>>> this behaviors and use F2 (via keylistener to fire the editing) or a
>>>> rename action from the context menu?
>>>>
>>>>
>>>> Thanks
>>>> Kar
>>>>
>>>>
>>>
>>>
>>> --
>>> B e s t S o l u t i o n . at
>>> ------------------------------------------------------------ --------
>>> Tom Schindl JFace-Committer
>>> ------------------------------------------------------------ --------
>>
>
>
> --
> B e s t S o l u t i o n . at
> ------------------------------------------------------------ --------
> Tom Schindl JFace-Committer
> ------------------------------------------------------------ --------
Re: TableViewerColume and editing [message #328275 is a reply to message #328274] Tue, 20 May 2008 15:59 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
No you don't need the highlighter. It should work without it.

Tom

KarSc schrieb:
> I did found the example but I was using the TableViewerEditor.create
> without the focus cell manager ...
> guess without doesn't work ...
> but where do I get the FocusBorderCellHighlighter is it part of 3.4Mx?
>
> thanks
>
> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
> news:g0uqvq$dvn$1@build.eclipse.org...
>> Take a look at this snippet
>> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet044NoColumnTableViewerKeyboardEditing.java? view=markup
>>
>>
>> Tom
>>
>> KarSc schrieb:
>>> Hi Tom thanks for ur help but still not able to let table works as I
>>> want ...
>>>
>>> I'm sure I'm using the ColumnViewerEditorActionStrategy class in a
>>> wrong way ...
>>>
>>> here is my code ... what have I done wrong (the class is not called) ???
>>>
>>> thanks
>>> Kar
>>>
>>>
>>> private void initLabelProvider(TableViewer viewer)
>>> {
>>> TableViewerColumn column = new TableViewerColumn(viewer,
>>> SWT.NONE);
>>> column.setLabelProvider(new NameLabelProvider(viewer));
>>> column.setEditingSupport(new NameEditing(viewer));
>>> column.getColumn().setWidth(200);
>>> column.getColumn().setText("Name");
>>> column.getColumn().setMoveable(true);
>>>
>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>> column.setLabelProvider(new SizeLabelProvider());
>>> column.getColumn().setWidth(150);
>>> column.getColumn().setText("Size");
>>> column.getColumn().setMoveable(true);
>>>
>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>> column.setLabelProvider(new TypeLabelProvider());
>>> column.getColumn().setWidth(100);
>>> column.getColumn().setText("Type");
>>> column.getColumn().setMoveable(true);
>>>
>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>> column.setLabelProvider(new LockedByLabelProvider());
>>> column.getColumn().setWidth(100);
>>> column.getColumn().setText("Locked by");
>>> column.getColumn().setMoveable(true);
>>>
>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>> column.setLabelProvider(new StatusLabelProvider());
>>> column.getColumn().setWidth(150);
>>> column.getColumn().setText("Status");
>>> column.getColumn().setMoveable(true);
>>>
>>> new ColumnViewerEditorActivationStrategy(viewer)
>>> {
>>> @Override
>>> protected boolean
>>> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
>>> {
>>> return event.keyCode == SWT.F2;
>>> }
>>> };
>>>
>>> }
>>>
>>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
>>> news:g0unt8$hd3$1@build.eclipse.org...
>>>> Sure. You'll have to tweak your ColumnViewerEditorActivationStrategy
>>>> and only allow editor activation on PROGRAMMATIC and TABBING Events.
>>>> Afterwards you activate an editor using TableViewer#editElement() to
>>>> fire up the editor on keypress.
>>>>
>>>> Tom
>>>>
>>>> KarSc schrieb:
>>>>> Hi all
>>>>>
>>>>> I'm using TableViewerColum to set label provider and editing
>>>>> support for my table viewer. (see snippet 19 about new api)
>>>>>
>>>>> What I find annoying is that each time the cursor goes on the
>>>>> editable cell immediately the cell goes in editing . is there any
>>>>> way to stop this behaviors and use F2 (via keylistener to fire the
>>>>> editing) or a rename action from the context menu?
>>>>>
>>>>>
>>>>> Thanks
>>>>> Kar
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> B e s t S o l u t i o n . at
>>>> ------------------------------------------------------------ --------
>>>> Tom Schindl JFace-Committer
>>>> ------------------------------------------------------------ --------
>>>
>>
>>
>> --
>> B e s t S o l u t i o n . at
>> ------------------------------------------------------------ --------
>> Tom Schindl JFace-Committer
>> ------------------------------------------------------------ --------
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: TableViewerColume and editing [message #328301 is a reply to message #328275] Wed, 21 May 2008 07:46 Go to previous messageGo to next message
Carmelo  is currently offline Carmelo Friend
Messages: 224
Registered: July 2009
Senior Member
Hi Tom ... it doesn't work ... can u help me ... please.

Ciao
Kar


protected TableViewer createViewer(Composite parent)
{
TableViewer viewer = new TableViewer(parent, SWT.H_SCROLL |
SWT.V_SCROLL | SWT.BORDER
| SWT.VIRTUAL | SWT.FULL_SELECTION);
viewer.setUseHashlookup(true);

Table table = viewer.getTable();

// Turn on the header and the lines
table.setHeaderVisible(true);
table.setLinesVisible(true);

initContentProvider(viewer);
initLabelProvider(viewer);
return viewer;
}


private void initLabelProvider(TableViewer viewer)
{
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new NameLabelProvider(viewer));
column.setEditingSupport(new NameEditing(viewer));
column.getColumn().setWidth(200);
column.getColumn().setText("Name");
column.getColumn().setMoveable(true);

column = new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new SizeLabelProvider());
column.getColumn().setWidth(150);
column.getColumn().setText("Size");
column.getColumn().setMoveable(true);

column = new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new TypeLabelProvider());
column.getColumn().setWidth(100);
column.getColumn().setText("Type");
column.getColumn().setMoveable(true);

column = new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new LockedByLabelProvider());
column.getColumn().setWidth(100);
column.getColumn().setText("Locked by");
column.getColumn().setMoveable(true);

column = new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new StatusLabelProvider());
column.getColumn().setWidth(150);
column.getColumn().setText("Status");
column.getColumn().setMoveable(true);

ColumnViewerEditorActivationStrategy actSupport = new
ColumnViewerEditorActivationStrategy(
viewer)
{
protected boolean
isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
{
return event.eventType ==
ColumnViewerEditorActivationEvent.TRAVERSAL
|| event.eventType ==
ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTI ON
|| (event.eventType ==
ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR)
|| event.eventType ==
ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};

TableViewerEditor.create(viewer, actSupport,
ColumnViewerEditor.TABBING_HORIZONTAL
| ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
| ColumnViewerEditor.TABBING_VERTICAL
| ColumnViewerEditor.KEYBOARD_ACTIVATION);

TableViewerEditor.create(viewer, new
ColumnViewerEditorActivationStrategy(viewer)
{
@Override
protected boolean
isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
{
System.out.println("here ..." + event.keyCode);
return event.keyCode == SWT.F2;
}
}, ColumnViewerEditor.TABBING_HORIZONTAL
| ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
| ColumnViewerEditor.TABBING_VERTICAL |
ColumnViewerEditor.KEYBOARD_ACTIVATION);
}

"Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
news:g0ushv$fk$1@build.eclipse.org...
> No you don't need the highlighter. It should work without it.
>
> Tom
>
> KarSc schrieb:
>> I did found the example but I was using the TableViewerEditor.create
>> without the focus cell manager ...
>> guess without doesn't work ...
>> but where do I get the FocusBorderCellHighlighter is it part of 3.4Mx?
>>
>> thanks
>>
>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
>> news:g0uqvq$dvn$1@build.eclipse.org...
>>> Take a look at this snippet
>>> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet044NoColumnTableViewerKeyboardEditing.java? view=markup
>>>
>>> Tom
>>>
>>> KarSc schrieb:
>>>> Hi Tom thanks for ur help but still not able to let table works as I
>>>> want ...
>>>>
>>>> I'm sure I'm using the ColumnViewerEditorActionStrategy class in a
>>>> wrong way ...
>>>>
>>>> here is my code ... what have I done wrong (the class is not called)
>>>> ???
>>>>
>>>> thanks
>>>> Kar
>>>>
>>>>
>>>> private void initLabelProvider(TableViewer viewer)
>>>> {
>>>> TableViewerColumn column = new TableViewerColumn(viewer,
>>>> SWT.NONE);
>>>> column.setLabelProvider(new NameLabelProvider(viewer));
>>>> column.setEditingSupport(new NameEditing(viewer));
>>>> column.getColumn().setWidth(200);
>>>> column.getColumn().setText("Name");
>>>> column.getColumn().setMoveable(true);
>>>>
>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>> column.setLabelProvider(new SizeLabelProvider());
>>>> column.getColumn().setWidth(150);
>>>> column.getColumn().setText("Size");
>>>> column.getColumn().setMoveable(true);
>>>>
>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>> column.setLabelProvider(new TypeLabelProvider());
>>>> column.getColumn().setWidth(100);
>>>> column.getColumn().setText("Type");
>>>> column.getColumn().setMoveable(true);
>>>>
>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>> column.setLabelProvider(new LockedByLabelProvider());
>>>> column.getColumn().setWidth(100);
>>>> column.getColumn().setText("Locked by");
>>>> column.getColumn().setMoveable(true);
>>>>
>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>> column.setLabelProvider(new StatusLabelProvider());
>>>> column.getColumn().setWidth(150);
>>>> column.getColumn().setText("Status");
>>>> column.getColumn().setMoveable(true);
>>>>
>>>> new ColumnViewerEditorActivationStrategy(viewer)
>>>> {
>>>> @Override
>>>> protected boolean
>>>> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
>>>> {
>>>> return event.keyCode == SWT.F2;
>>>> }
>>>> };
>>>>
>>>> }
>>>>
>>>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
>>>> news:g0unt8$hd3$1@build.eclipse.org...
>>>>> Sure. You'll have to tweak your ColumnViewerEditorActivationStrategy
>>>>> and only allow editor activation on PROGRAMMATIC and TABBING Events.
>>>>> Afterwards you activate an editor using TableViewer#editElement() to
>>>>> fire up the editor on keypress.
>>>>>
>>>>> Tom
>>>>>
>>>>> KarSc schrieb:
>>>>>> Hi all
>>>>>>
>>>>>> I'm using TableViewerColum to set label provider and editing support
>>>>>> for my table viewer. (see snippet 19 about new api)
>>>>>>
>>>>>> What I find annoying is that each time the cursor goes on the
>>>>>> editable cell immediately the cell goes in editing . is there any way
>>>>>> to stop this behaviors and use F2 (via keylistener to fire the
>>>>>> editing) or a rename action from the context menu?
>>>>>>
>>>>>>
>>>>>> Thanks
>>>>>> Kar
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> B e s t S o l u t i o n . at
>>>>> ------------------------------------------------------------ --------
>>>>> Tom Schindl JFace-Committer
>>>>> ------------------------------------------------------------ --------
>>>>
>>>
>>>
>>> --
>>> B e s t S o l u t i o n . at
>>> ------------------------------------------------------------ --------
>>> Tom Schindl JFace-Committer
>>> ------------------------------------------------------------ --------
>>
>
>
> --
> B e s t S o l u t i o n . at
> ------------------------------------------------------------ --------
> Tom Schindl JFace-Committer
> ------------------------------------------------------------ --------
Re: TableViewerColume and editing [message #328303 is a reply to message #328275] Wed, 21 May 2008 08:20 Go to previous messageGo to next message
Carmelo  is currently offline Carmelo Friend
Messages: 224
Registered: July 2009
Senior Member
Messaggio multiparte in formato MIME.

------=_NextPart_000_002C_01C8BB2C.58BBD8C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

sorry I forgot to remove the comment bit ...


private void initLabelProvider(TableViewer viewer)
{
TableViewerColumn column =3D new TableViewerColumn(viewer, =
SWT.NONE);
column.setLabelProvider(new NameLabelProvider(viewer));
column.setEditingSupport(new NameEditing(viewer));
column.getColumn().setWidth(200);
column.getColumn().setText("Name");
column.getColumn().setMoveable(true);

column =3D new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new SizeLabelProvider());
column.getColumn().setWidth(150);
column.getColumn().setText("Size");
column.getColumn().setMoveable(true);

column =3D new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new TypeLabelProvider());
column.getColumn().setWidth(100);
column.getColumn().setText("Type");
column.getColumn().setMoveable(true);

column =3D new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new LockedByLabelProvider());
column.getColumn().setWidth(100);
column.getColumn().setText("Locked by");
column.getColumn().setMoveable(true);

column =3D new TableViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new StatusLabelProvider());
column.getColumn().setWidth(150);
column.getColumn().setText("Status");
column.getColumn().setMoveable(true);

ColumnViewerEditorActivationStrategy actSupport =3D new =
ColumnViewerEditorActivationStrategy(
viewer)
{
protected boolean =
isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
{
return event.eventType =3D=3D =
ColumnViewerEditorActivationEvent.TRAVERSAL
|| event.eventType =3D=3D =
ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTI ON
|| (event.eventType =3D=3D =
ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode =3D=3D =
SWT.F2)
|| event.eventType =3D=3D =
ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};

TableViewerEditor.create(viewer, actSupport,
ColumnViewerEditor.TABBING_HORIZONTAL
| =
ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
| ColumnViewerEditor.TABBING_VERTICAL
| ColumnViewerEditor.KEYBOARD_ACTIVATION);

=20
}
------=_NextPart_000_002C_01C8BB2C.58BBD8C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dunicode">
<META content=3D"MSHTML 6.00.6000.16587" name=3DGENERATOR></HEAD>
<BODY id=3DMailContainerBody=20
style=3D"PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-TOP: 15px"=20
bgColor=3D#ffffff leftMargin=3D0 topMargin=3D0 CanvasTabStop=3D"true"=20
name=3D"Compose message area"><FONT face=3DCalibri size=3D2>sorry I =
forgot to remove=20
the comment bit ...<BR><BR><BR>&nbsp;private void =
initLabelProvider(TableViewer=20
viewer)<BR>&nbsp;&nbsp;&nbsp; =
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
TableViewerColumn column =3D new TableViewerColumn(viewer,=20
SWT.NONE);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
column.setLabelProvider(new=20
NameLabelProvider(viewer));<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=
=20
column.setEditingSupport(new=20
NameEditing(viewer));<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
column.getColumn().setWidth(200);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;=20
column.getColumn().setText("Name");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
column.getColumn().setMoveable(true);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
column =3D new TableViewerColumn(viewer,=20
SWT.NONE);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
column.setLabelProvider(new=20
SizeLabelProvider());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
column.getColumn().setWidth(150);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;=20
column.getColumn().setText("Size");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
column.getColumn().setMoveable(true);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
column =3D new TableViewerColumn(viewer,=20
SWT.NONE);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
column.setLabelProvider(new=20
TypeLabelProvider());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
column.getColumn().setWidth(100);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;=20
column.getColumn().setText("Type");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
column.getColumn().setMoveable(true);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
column =3D new TableViewerColumn(viewer,=20
SWT.NONE);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
column.setLabelProvider(new=20
LockedByLabelProvider());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
column.getColumn().setWidth(100);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;=20
column.getColumn().setText("Locked=20
by");<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
column.getColumn().setMoveable(true);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
column =3D new TableViewerColumn(viewer,=20
SWT.NONE);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
column.setLabelProvider(new=20
StatusLabelProvider());<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
column.getColumn().setWidth(150);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;=20
column.getColumn().setText("Status");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
column.getColumn().setMoveable(true);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
ColumnViewerEditorActivationStrategy actSupport =3D new=20
ColumnViewerEditorActivationStrategy(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;=20
viewer)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
protected boolean =
isEditorActivationEvent(ColumnViewerEditorActivationEvent=20
event)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
return event.eventType =3D=3D=20
ColumnViewerEditorActivationEvent.TRAVERSAL<BR>&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n b=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;=20
|| event.eventType =3D=3D=20
ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTI ON <BR>&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;=20
|| (event.eventType =3D=3D ColumnViewerEditorActivationEvent.KEY_PRESSED =
&amp;&amp;=20
event.keyCode =3D=3D=20
SWT.F2)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n b=
sp;=20
|| event.eventType =3D=3D=20
ColumnViewerEditorActivationEvent.PROGRAMMATIC;<BR>&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;=20
}<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
};<BR><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
TableViewerEditor.create(viewer,=20
actSupport,<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
ColumnViewerEditor.TABBING_HORIZONTAL<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n b=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
|=20
ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR<BR>&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;=20
|=20
ColumnViewerEditor.TABBING_VERTICAL<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
|=20
ColumnViewerEditor.KEYBOARD_ACTIVATION);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp; }</FONT></BODY></HTML>

------=_NextPart_000_002C_01C8BB2C.58BBD8C0--
Re: TableViewerColume and editing [message #328304 is a reply to message #328301] Wed, 21 May 2008 08:22 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Ah I see you have multiple columns. I thought you have only one column
and do the activation always using TableViewer#editElement(). In this
case you need a the SWTCellFocusManager like it is shown in [1]. Of
course you'll need to replace TreeViewerCellFocusManager through
TableViewerCellFocusManager the rest is the same.

Because your columns are moveable you'll have to use JFace 3.4 because
we had bugs in the case in 3.3.

Tom

[1] http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet026TreeViewerTabEditing.java?view=markup

KarSc schrieb:
> Hi Tom ... it doesn't work ... can u help me ... please.
>
> Ciao
> Kar
>
>
> protected TableViewer createViewer(Composite parent)
> {
> TableViewer viewer = new TableViewer(parent, SWT.H_SCROLL |
> SWT.V_SCROLL | SWT.BORDER
> | SWT.VIRTUAL | SWT.FULL_SELECTION);
> viewer.setUseHashlookup(true);
>
> Table table = viewer.getTable();
>
> // Turn on the header and the lines
> table.setHeaderVisible(true);
> table.setLinesVisible(true);
>
> initContentProvider(viewer);
> initLabelProvider(viewer);
> return viewer;
> }
>
>
> private void initLabelProvider(TableViewer viewer)
> {
> TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
> column.setLabelProvider(new NameLabelProvider(viewer));
> column.setEditingSupport(new NameEditing(viewer));
> column.getColumn().setWidth(200);
> column.getColumn().setText("Name");
> column.getColumn().setMoveable(true);
>
> column = new TableViewerColumn(viewer, SWT.NONE);
> column.setLabelProvider(new SizeLabelProvider());
> column.getColumn().setWidth(150);
> column.getColumn().setText("Size");
> column.getColumn().setMoveable(true);
>
> column = new TableViewerColumn(viewer, SWT.NONE);
> column.setLabelProvider(new TypeLabelProvider());
> column.getColumn().setWidth(100);
> column.getColumn().setText("Type");
> column.getColumn().setMoveable(true);
>
> column = new TableViewerColumn(viewer, SWT.NONE);
> column.setLabelProvider(new LockedByLabelProvider());
> column.getColumn().setWidth(100);
> column.getColumn().setText("Locked by");
> column.getColumn().setMoveable(true);
>
> column = new TableViewerColumn(viewer, SWT.NONE);
> column.setLabelProvider(new StatusLabelProvider());
> column.getColumn().setWidth(150);
> column.getColumn().setText("Status");
> column.getColumn().setMoveable(true);
>
> ColumnViewerEditorActivationStrategy actSupport = new
> ColumnViewerEditorActivationStrategy(
> viewer)
> {
> protected boolean
> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
> {
> return event.eventType ==
> ColumnViewerEditorActivationEvent.TRAVERSAL
> || event.eventType ==
> ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTI ON
> || (event.eventType ==
> ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR)
> || event.eventType ==
> ColumnViewerEditorActivationEvent.PROGRAMMATIC;
> }
> };
>
> TableViewerEditor.create(viewer, actSupport,
> ColumnViewerEditor.TABBING_HORIZONTAL
> | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
> | ColumnViewerEditor.TABBING_VERTICAL
> | ColumnViewerEditor.KEYBOARD_ACTIVATION);
>
> TableViewerEditor.create(viewer, new
> ColumnViewerEditorActivationStrategy(viewer)
> {
> @Override
> protected boolean
> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
> {
> System.out.println("here ..." + event.keyCode);
> return event.keyCode == SWT.F2;
> }
> }, ColumnViewerEditor.TABBING_HORIZONTAL
> | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
> | ColumnViewerEditor.TABBING_VERTICAL |
> ColumnViewerEditor.KEYBOARD_ACTIVATION);
> }
>
> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
> news:g0ushv$fk$1@build.eclipse.org...
>> No you don't need the highlighter. It should work without it.
>>
>> Tom
>>
>> KarSc schrieb:
>>> I did found the example but I was using the TableViewerEditor.create
>>> without the focus cell manager ...
>>> guess without doesn't work ...
>>> but where do I get the FocusBorderCellHighlighter is it part of 3.4Mx?
>>>
>>> thanks
>>>
>>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
>>> news:g0uqvq$dvn$1@build.eclipse.org...
>>>> Take a look at this snippet
>>>> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet044NoColumnTableViewerKeyboardEditing.java? view=markup
>>>>
>>>>
>>>> Tom
>>>>
>>>> KarSc schrieb:
>>>>> Hi Tom thanks for ur help but still not able to let table works as
>>>>> I want ...
>>>>>
>>>>> I'm sure I'm using the ColumnViewerEditorActionStrategy class in a
>>>>> wrong way ...
>>>>>
>>>>> here is my code ... what have I done wrong (the class is not
>>>>> called) ???
>>>>>
>>>>> thanks
>>>>> Kar
>>>>>
>>>>>
>>>>> private void initLabelProvider(TableViewer viewer)
>>>>> {
>>>>> TableViewerColumn column = new TableViewerColumn(viewer,
>>>>> SWT.NONE);
>>>>> column.setLabelProvider(new NameLabelProvider(viewer));
>>>>> column.setEditingSupport(new NameEditing(viewer));
>>>>> column.getColumn().setWidth(200);
>>>>> column.getColumn().setText("Name");
>>>>> column.getColumn().setMoveable(true);
>>>>>
>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>> column.setLabelProvider(new SizeLabelProvider());
>>>>> column.getColumn().setWidth(150);
>>>>> column.getColumn().setText("Size");
>>>>> column.getColumn().setMoveable(true);
>>>>>
>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>> column.setLabelProvider(new TypeLabelProvider());
>>>>> column.getColumn().setWidth(100);
>>>>> column.getColumn().setText("Type");
>>>>> column.getColumn().setMoveable(true);
>>>>>
>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>> column.setLabelProvider(new LockedByLabelProvider());
>>>>> column.getColumn().setWidth(100);
>>>>> column.getColumn().setText("Locked by");
>>>>> column.getColumn().setMoveable(true);
>>>>>
>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>> column.setLabelProvider(new StatusLabelProvider());
>>>>> column.getColumn().setWidth(150);
>>>>> column.getColumn().setText("Status");
>>>>> column.getColumn().setMoveable(true);
>>>>>
>>>>> new ColumnViewerEditorActivationStrategy(viewer)
>>>>> {
>>>>> @Override
>>>>> protected boolean
>>>>> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
>>>>> {
>>>>> return event.keyCode == SWT.F2;
>>>>> }
>>>>> };
>>>>>
>>>>> }
>>>>>
>>>>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel
>>>>> messaggio news:g0unt8$hd3$1@build.eclipse.org...
>>>>>> Sure. You'll have to tweak your
>>>>>> ColumnViewerEditorActivationStrategy and only allow editor
>>>>>> activation on PROGRAMMATIC and TABBING Events. Afterwards you
>>>>>> activate an editor using TableViewer#editElement() to fire up the
>>>>>> editor on keypress.
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>> KarSc schrieb:
>>>>>>> Hi all
>>>>>>>
>>>>>>> I'm using TableViewerColum to set label provider and editing
>>>>>>> support for my table viewer. (see snippet 19 about new api)
>>>>>>>
>>>>>>> What I find annoying is that each time the cursor goes on the
>>>>>>> editable cell immediately the cell goes in editing . is there any
>>>>>>> way to stop this behaviors and use F2 (via keylistener to fire
>>>>>>> the editing) or a rename action from the context menu?
>>>>>>>
>>>>>>>
>>>>>>> Thanks
>>>>>>> Kar
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> B e s t S o l u t i o n . at
>>>>>> ------------------------------------------------------------ --------
>>>>>> Tom Schindl JFace-Committer
>>>>>> ------------------------------------------------------------ --------
>>>>>
>>>>
>>>>
>>>> --
>>>> B e s t S o l u t i o n . at
>>>> ------------------------------------------------------------ --------
>>>> Tom Schindl JFace-Committer
>>>> ------------------------------------------------------------ --------
>>>
>>
>>
>> --
>> B e s t S o l u t i o n . at
>> ------------------------------------------------------------ --------
>> Tom Schindl JFace-Committer
>> ------------------------------------------------------------ --------
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: TableViewerColume and editing [message #328309 is a reply to message #328304] Wed, 21 May 2008 11:26 Go to previous messageGo to next message
Carmelo  is currently offline Carmelo Friend
Messages: 224
Registered: July 2009
Senior Member
I see ... thanks for ur help ... but right now I cannot move to use 3.4 so
guess I will use the old celleditor

:-) many thanks tom
Ciao


"Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
news:g10m3o$17s$1@build.eclipse.org...
> Ah I see you have multiple columns. I thought you have only one column and
> do the activation always using TableViewer#editElement(). In this case you
> need a the SWTCellFocusManager like it is shown in [1]. Of course you'll
> need to replace TreeViewerCellFocusManager through
> TableViewerCellFocusManager the rest is the same.
>
> Because your columns are moveable you'll have to use JFace 3.4 because we
> had bugs in the case in 3.3.
>
> Tom
>
> [1] http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet026TreeViewerTabEditing.java?view=markup
>
> KarSc schrieb:
>> Hi Tom ... it doesn't work ... can u help me ... please.
>>
>> Ciao
>> Kar
>>
>>
>> protected TableViewer createViewer(Composite parent)
>> {
>> TableViewer viewer = new TableViewer(parent, SWT.H_SCROLL |
>> SWT.V_SCROLL | SWT.BORDER
>> | SWT.VIRTUAL | SWT.FULL_SELECTION);
>> viewer.setUseHashlookup(true);
>>
>> Table table = viewer.getTable();
>>
>> // Turn on the header and the lines
>> table.setHeaderVisible(true);
>> table.setLinesVisible(true);
>>
>> initContentProvider(viewer);
>> initLabelProvider(viewer);
>> return viewer;
>> }
>>
>>
>> private void initLabelProvider(TableViewer viewer)
>> {
>> TableViewerColumn column = new TableViewerColumn(viewer,
>> SWT.NONE);
>> column.setLabelProvider(new NameLabelProvider(viewer));
>> column.setEditingSupport(new NameEditing(viewer));
>> column.getColumn().setWidth(200);
>> column.getColumn().setText("Name");
>> column.getColumn().setMoveable(true);
>>
>> column = new TableViewerColumn(viewer, SWT.NONE);
>> column.setLabelProvider(new SizeLabelProvider());
>> column.getColumn().setWidth(150);
>> column.getColumn().setText("Size");
>> column.getColumn().setMoveable(true);
>>
>> column = new TableViewerColumn(viewer, SWT.NONE);
>> column.setLabelProvider(new TypeLabelProvider());
>> column.getColumn().setWidth(100);
>> column.getColumn().setText("Type");
>> column.getColumn().setMoveable(true);
>>
>> column = new TableViewerColumn(viewer, SWT.NONE);
>> column.setLabelProvider(new LockedByLabelProvider());
>> column.getColumn().setWidth(100);
>> column.getColumn().setText("Locked by");
>> column.getColumn().setMoveable(true);
>>
>> column = new TableViewerColumn(viewer, SWT.NONE);
>> column.setLabelProvider(new StatusLabelProvider());
>> column.getColumn().setWidth(150);
>> column.getColumn().setText("Status");
>> column.getColumn().setMoveable(true);
>>
>> ColumnViewerEditorActivationStrategy actSupport = new
>> ColumnViewerEditorActivationStrategy(
>> viewer)
>> {
>> protected boolean
>> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
>> {
>> return event.eventType ==
>> ColumnViewerEditorActivationEvent.TRAVERSAL
>> || event.eventType ==
>> ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTI ON
>> || (event.eventType ==
>> ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR)
>> || event.eventType ==
>> ColumnViewerEditorActivationEvent.PROGRAMMATIC;
>> }
>> };
>>
>> TableViewerEditor.create(viewer, actSupport,
>> ColumnViewerEditor.TABBING_HORIZONTAL
>> | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
>> | ColumnViewerEditor.TABBING_VERTICAL
>> | ColumnViewerEditor.KEYBOARD_ACTIVATION);
>>
>> TableViewerEditor.create(viewer, new
>> ColumnViewerEditorActivationStrategy(viewer)
>> {
>> @Override
>> protected boolean
>> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
>> {
>> System.out.println("here ..." + event.keyCode);
>> return event.keyCode == SWT.F2;
>> }
>> }, ColumnViewerEditor.TABBING_HORIZONTAL
>> | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
>> | ColumnViewerEditor.TABBING_VERTICAL |
>> ColumnViewerEditor.KEYBOARD_ACTIVATION);
>> }
>>
>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
>> news:g0ushv$fk$1@build.eclipse.org...
>>> No you don't need the highlighter. It should work without it.
>>>
>>> Tom
>>>
>>> KarSc schrieb:
>>>> I did found the example but I was using the TableViewerEditor.create
>>>> without the focus cell manager ...
>>>> guess without doesn't work ...
>>>> but where do I get the FocusBorderCellHighlighter is it part of 3.4Mx?
>>>>
>>>> thanks
>>>>
>>>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
>>>> news:g0uqvq$dvn$1@build.eclipse.org...
>>>>> Take a look at this snippet
>>>>> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet044NoColumnTableViewerKeyboardEditing.java? view=markup
>>>>>
>>>>> Tom
>>>>>
>>>>> KarSc schrieb:
>>>>>> Hi Tom thanks for ur help but still not able to let table works as I
>>>>>> want ...
>>>>>>
>>>>>> I'm sure I'm using the ColumnViewerEditorActionStrategy class in a
>>>>>> wrong way ...
>>>>>>
>>>>>> here is my code ... what have I done wrong (the class is not called)
>>>>>> ???
>>>>>>
>>>>>> thanks
>>>>>> Kar
>>>>>>
>>>>>>
>>>>>> private void initLabelProvider(TableViewer viewer)
>>>>>> {
>>>>>> TableViewerColumn column = new TableViewerColumn(viewer,
>>>>>> SWT.NONE);
>>>>>> column.setLabelProvider(new NameLabelProvider(viewer));
>>>>>> column.setEditingSupport(new NameEditing(viewer));
>>>>>> column.getColumn().setWidth(200);
>>>>>> column.getColumn().setText("Name");
>>>>>> column.getColumn().setMoveable(true);
>>>>>>
>>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>>> column.setLabelProvider(new SizeLabelProvider());
>>>>>> column.getColumn().setWidth(150);
>>>>>> column.getColumn().setText("Size");
>>>>>> column.getColumn().setMoveable(true);
>>>>>>
>>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>>> column.setLabelProvider(new TypeLabelProvider());
>>>>>> column.getColumn().setWidth(100);
>>>>>> column.getColumn().setText("Type");
>>>>>> column.getColumn().setMoveable(true);
>>>>>>
>>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>>> column.setLabelProvider(new LockedByLabelProvider());
>>>>>> column.getColumn().setWidth(100);
>>>>>> column.getColumn().setText("Locked by");
>>>>>> column.getColumn().setMoveable(true);
>>>>>>
>>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>>> column.setLabelProvider(new StatusLabelProvider());
>>>>>> column.getColumn().setWidth(150);
>>>>>> column.getColumn().setText("Status");
>>>>>> column.getColumn().setMoveable(true);
>>>>>>
>>>>>> new ColumnViewerEditorActivationStrategy(viewer)
>>>>>> {
>>>>>> @Override
>>>>>> protected boolean
>>>>>> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
>>>>>> {
>>>>>> return event.keyCode == SWT.F2;
>>>>>> }
>>>>>> };
>>>>>>
>>>>>> }
>>>>>>
>>>>>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
>>>>>> news:g0unt8$hd3$1@build.eclipse.org...
>>>>>>> Sure. You'll have to tweak your ColumnViewerEditorActivationStrategy
>>>>>>> and only allow editor activation on PROGRAMMATIC and TABBING Events.
>>>>>>> Afterwards you activate an editor using TableViewer#editElement() to
>>>>>>> fire up the editor on keypress.
>>>>>>>
>>>>>>> Tom
>>>>>>>
>>>>>>> KarSc schrieb:
>>>>>>>> Hi all
>>>>>>>>
>>>>>>>> I'm using TableViewerColum to set label provider and editing
>>>>>>>> support for my table viewer. (see snippet 19 about new api)
>>>>>>>>
>>>>>>>> What I find annoying is that each time the cursor goes on the
>>>>>>>> editable cell immediately the cell goes in editing . is there any
>>>>>>>> way to stop this behaviors and use F2 (via keylistener to fire the
>>>>>>>> editing) or a rename action from the context menu?
>>>>>>>>
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>> Kar
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> B e s t S o l u t i o n . at
>>>>>>> ------------------------------------------------------------ --------
>>>>>>> Tom Schindl JFace-Committer
>>>>>>> ------------------------------------------------------------ --------
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> B e s t S o l u t i o n . at
>>>>> ------------------------------------------------------------ --------
>>>>> Tom Schindl JFace-Committer
>>>>> ------------------------------------------------------------ --------
>>>>
>>>
>>>
>>> --
>>> B e s t S o l u t i o n . at
>>> ------------------------------------------------------------ --------
>>> Tom Schindl JFace-Committer
>>> ------------------------------------------------------------ --------
>>
>
>
> --
> B e s t S o l u t i o n . at
> ------------------------------------------------------------ --------
> Tom Schindl JFace-Committer
> ------------------------------------------------------------ --------
Re: TableViewerColume and editing [message #328311 is a reply to message #328309] Wed, 21 May 2008 11:46 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Well at least you can avoid the single click activation because this
doesn't need a focus manager, only keyboard activation needs to know
which cell holds the focus to activate the appropriate one. Activation
on double click doesn't need it because it knows which cell the user
clicked.

Tom

KarSc schrieb:
> I see ... thanks for ur help ... but right now I cannot move to use 3.4
> so guess I will use the old celleditor
>
> :-) many thanks tom
> Ciao
>
>
> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
> news:g10m3o$17s$1@build.eclipse.org...
>> Ah I see you have multiple columns. I thought you have only one column
>> and do the activation always using TableViewer#editElement(). In this
>> case you need a the SWTCellFocusManager like it is shown in [1]. Of
>> course you'll need to replace TreeViewerCellFocusManager through
>> TableViewerCellFocusManager the rest is the same.
>>
>> Because your columns are moveable you'll have to use JFace 3.4 because
>> we had bugs in the case in 3.3.
>>
>> Tom
>>
>> [1] http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet026TreeViewerTabEditing.java?view=markup
>>
>>
>> KarSc schrieb:
>>> Hi Tom ... it doesn't work ... can u help me ... please.
>>>
>>> Ciao
>>> Kar
>>>
>>>
>>> protected TableViewer createViewer(Composite parent)
>>> {
>>> TableViewer viewer = new TableViewer(parent, SWT.H_SCROLL |
>>> SWT.V_SCROLL | SWT.BORDER
>>> | SWT.VIRTUAL | SWT.FULL_SELECTION);
>>> viewer.setUseHashlookup(true);
>>>
>>> Table table = viewer.getTable();
>>>
>>> // Turn on the header and the lines
>>> table.setHeaderVisible(true);
>>> table.setLinesVisible(true);
>>>
>>> initContentProvider(viewer);
>>> initLabelProvider(viewer);
>>> return viewer;
>>> }
>>>
>>>
>>> private void initLabelProvider(TableViewer viewer)
>>> {
>>> TableViewerColumn column = new TableViewerColumn(viewer,
>>> SWT.NONE);
>>> column.setLabelProvider(new NameLabelProvider(viewer));
>>> column.setEditingSupport(new NameEditing(viewer));
>>> column.getColumn().setWidth(200);
>>> column.getColumn().setText("Name");
>>> column.getColumn().setMoveable(true);
>>>
>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>> column.setLabelProvider(new SizeLabelProvider());
>>> column.getColumn().setWidth(150);
>>> column.getColumn().setText("Size");
>>> column.getColumn().setMoveable(true);
>>>
>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>> column.setLabelProvider(new TypeLabelProvider());
>>> column.getColumn().setWidth(100);
>>> column.getColumn().setText("Type");
>>> column.getColumn().setMoveable(true);
>>>
>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>> column.setLabelProvider(new LockedByLabelProvider());
>>> column.getColumn().setWidth(100);
>>> column.getColumn().setText("Locked by");
>>> column.getColumn().setMoveable(true);
>>>
>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>> column.setLabelProvider(new StatusLabelProvider());
>>> column.getColumn().setWidth(150);
>>> column.getColumn().setText("Status");
>>> column.getColumn().setMoveable(true);
>>>
>>> ColumnViewerEditorActivationStrategy actSupport = new
>>> ColumnViewerEditorActivationStrategy(
>>> viewer)
>>> {
>>> protected boolean
>>> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
>>> {
>>> return event.eventType ==
>>> ColumnViewerEditorActivationEvent.TRAVERSAL
>>> || event.eventType ==
>>> ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTI ON
>>> || (event.eventType ==
>>> ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode ==
>>> SWT.CR)
>>> || event.eventType ==
>>> ColumnViewerEditorActivationEvent.PROGRAMMATIC;
>>> }
>>> };
>>>
>>> TableViewerEditor.create(viewer, actSupport,
>>> ColumnViewerEditor.TABBING_HORIZONTAL
>>> | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
>>> | ColumnViewerEditor.TABBING_VERTICAL
>>> | ColumnViewerEditor.KEYBOARD_ACTIVATION);
>>>
>>> TableViewerEditor.create(viewer, new
>>> ColumnViewerEditorActivationStrategy(viewer)
>>> {
>>> @Override
>>> protected boolean
>>> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
>>> {
>>> System.out.println("here ..." + event.keyCode);
>>> return event.keyCode == SWT.F2;
>>> }
>>> }, ColumnViewerEditor.TABBING_HORIZONTAL
>>> | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
>>> | ColumnViewerEditor.TABBING_VERTICAL |
>>> ColumnViewerEditor.KEYBOARD_ACTIVATION);
>>> }
>>>
>>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel messaggio
>>> news:g0ushv$fk$1@build.eclipse.org...
>>>> No you don't need the highlighter. It should work without it.
>>>>
>>>> Tom
>>>>
>>>> KarSc schrieb:
>>>>> I did found the example but I was using the
>>>>> TableViewerEditor.create without the focus cell manager ...
>>>>> guess without doesn't work ...
>>>>> but where do I get the FocusBorderCellHighlighter is it part of 3.4Mx?
>>>>>
>>>>> thanks
>>>>>
>>>>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel
>>>>> messaggio news:g0uqvq$dvn$1@build.eclipse.org...
>>>>>> Take a look at this snippet
>>>>>> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet044NoColumnTableViewerKeyboardEditing.java? view=markup
>>>>>>
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>> KarSc schrieb:
>>>>>>> Hi Tom thanks for ur help but still not able to let table works
>>>>>>> as I want ...
>>>>>>>
>>>>>>> I'm sure I'm using the ColumnViewerEditorActionStrategy class in
>>>>>>> a wrong way ...
>>>>>>>
>>>>>>> here is my code ... what have I done wrong (the class is not
>>>>>>> called) ???
>>>>>>>
>>>>>>> thanks
>>>>>>> Kar
>>>>>>>
>>>>>>>
>>>>>>> private void initLabelProvider(TableViewer viewer)
>>>>>>> {
>>>>>>> TableViewerColumn column = new TableViewerColumn(viewer,
>>>>>>> SWT.NONE);
>>>>>>> column.setLabelProvider(new NameLabelProvider(viewer));
>>>>>>> column.setEditingSupport(new NameEditing(viewer));
>>>>>>> column.getColumn().setWidth(200);
>>>>>>> column.getColumn().setText("Name");
>>>>>>> column.getColumn().setMoveable(true);
>>>>>>>
>>>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>>>> column.setLabelProvider(new SizeLabelProvider());
>>>>>>> column.getColumn().setWidth(150);
>>>>>>> column.getColumn().setText("Size");
>>>>>>> column.getColumn().setMoveable(true);
>>>>>>>
>>>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>>>> column.setLabelProvider(new TypeLabelProvider());
>>>>>>> column.getColumn().setWidth(100);
>>>>>>> column.getColumn().setText("Type");
>>>>>>> column.getColumn().setMoveable(true);
>>>>>>>
>>>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>>>> column.setLabelProvider(new LockedByLabelProvider());
>>>>>>> column.getColumn().setWidth(100);
>>>>>>> column.getColumn().setText("Locked by");
>>>>>>> column.getColumn().setMoveable(true);
>>>>>>>
>>>>>>> column = new TableViewerColumn(viewer, SWT.NONE);
>>>>>>> column.setLabelProvider(new StatusLabelProvider());
>>>>>>> column.getColumn().setWidth(150);
>>>>>>> column.getColumn().setText("Status");
>>>>>>> column.getColumn().setMoveable(true);
>>>>>>>
>>>>>>> new ColumnViewerEditorActivationStrategy(viewer)
>>>>>>> {
>>>>>>> @Override
>>>>>>> protected boolean
>>>>>>> isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
>>>>>>> {
>>>>>>> return event.keyCode == SWT.F2;
>>>>>>> }
>>>>>>> };
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>> "Tom Schindl" <tom.schindl@bestsolution.at> ha scritto nel
>>>>>>> messaggio news:g0unt8$hd3$1@build.eclipse.org...
>>>>>>>> Sure. You'll have to tweak your
>>>>>>>> ColumnViewerEditorActivationStrategy and only allow editor
>>>>>>>> activation on PROGRAMMATIC and TABBING Events. Afterwards you
>>>>>>>> activate an editor using TableViewer#editElement() to fire up
>>>>>>>> the editor on keypress.
>>>>>>>>
>>>>>>>> Tom
>>>>>>>>
>>>>>>>> KarSc schrieb:
>>>>>>>>> Hi all
>>>>>>>>>
>>>>>>>>> I'm using TableViewerColum to set label provider and editing
>>>>>>>>> support for my table viewer. (see snippet 19 about new api)
>>>>>>>>>
>>>>>>>>> What I find annoying is that each time the cursor goes on the
>>>>>>>>> editable cell immediately the cell goes in editing . is there
>>>>>>>>> any way to stop this behaviors and use F2 (via keylistener to
>>>>>>>>> fire the editing) or a rename action from the context menu?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>> Kar
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> B e s t S o l u t i o n . at
>>>>>>>> ------------------------------------------------------------ --------
>>>>>>>>
>>>>>>>> Tom Schindl
>>>>>>>> JFace-Committer
>>>>>>>> ------------------------------------------------------------ --------
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> B e s t S o l u t i o n . at
>>>>>> ------------------------------------------------------------ --------
>>>>>> Tom Schindl JFace-Committer
>>>>>> ------------------------------------------------------------ --------
>>>>>
>>>>
>>>>
>>>> --
>>>> B e s t S o l u t i o n . at
>>>> ------------------------------------------------------------ --------
>>>> Tom Schindl JFace-Committer
>>>> ------------------------------------------------------------ --------
>>>
>>
>>
>> --
>> B e s t S o l u t i o n . at
>> ------------------------------------------------------------ --------
>> Tom Schindl JFace-Committer
>> ------------------------------------------------------------ --------
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Previous Topic:listener on editor (close event)
Next Topic:Regarding plugin Signing info and certificate
Goto Forum:
  


Current Time: Fri Jul 19 14:27:13 GMT 2024

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

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

Back to the top