Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » insert in tableviewer
insert in tableviewer [message #55163] Wed, 24 October 2007 13:08 Go to next message
Eclipse UserFriend
Originally posted by: wen.ai.gillardon.de

Hi,

I have a tableviewer in my program. I selected one row in the
tableviewer, then I tried to add this row into the next position like this:

IStructuredSelection selection =
(IStructuredSelection)viewer.getSelection();
if (selection.isEmpty()) return;

for(Object o:selection.toList()){
viewer.insert(o, viewer.getTable().getSelectionIndex() + 1);
}

As result I got it, but the next row is missing. However, I got a prolem
when I sort this tableviewer. Exactly for that, the rows in the
tableviewer can be sorted in order, but the tableviewer displays just
the old information instead of the updated information.

Many thanks.

Greetings

Wen
Re: insert in tableviewer [message #55220 is a reply to message #55163] Wed, 24 October 2007 13:58 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Well I'm talking about JFaceViewers and expect that this is also true
for RAP:

1. One instance more than once in Viewer
------------------------------------------
TableViewer doesn't support putting the same instance more than once in
the Table-Model. TreeViewer supports it but only under different TreePaths.

2. Only inserting the Object
----------------------------
From your code below I see that you are only adding the new instance to
the Viewer but not your model, whenever the TableViewer is refreshed
your changes are lost.

3. Sorting in Viewers:
----------------------
Is done using setSorter/setComparator.


Tom

Wen Ai schrieb:
> Hi,
>
> I have a tableviewer in my program. I selected one row in the
> tableviewer, then I tried to add this row into the next position like this:
>
> IStructuredSelection selection =
> (IStructuredSelection)viewer.getSelection();
> if (selection.isEmpty()) return;
>
> for(Object o:selection.toList()){
> viewer.insert(o, viewer.getTable().getSelectionIndex() + 1);
> }
>
> As result I got it, but the next row is missing. However, I got a prolem
> when I sort this tableviewer. Exactly for that, the rows in the
> tableviewer can be sorted in order, but the tableviewer displays just
> the old information instead of the updated information.
>
> Many thanks.
>
> Greetings
>
> Wen


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: insert in tableviewer [message #55409 is a reply to message #55220] Thu, 25 October 2007 09:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wen.ai.gillardon.de

Hi,

thanks for your infos. But I still face to the problem, how can I add
something new in my table model or delete a row from it. I know two
methods in the ContentProvider are very important for that: getElements
and inputChanged. I'm still testing this and I can't find some examples
exactly for this thema from the google. Can anyone help?

Wen

Tom Schindl schrieb:
> Well I'm talking about JFaceViewers and expect that this is also true
> for RAP:
>
> 1. One instance more than once in Viewer
> ------------------------------------------
> TableViewer doesn't support putting the same instance more than once in
> the Table-Model. TreeViewer supports it but only under different TreePaths.
>
> 2. Only inserting the Object
> ----------------------------
> From your code below I see that you are only adding the new instance to
> the Viewer but not your model, whenever the TableViewer is refreshed
> your changes are lost.
>
> 3. Sorting in Viewers:
> ----------------------
> Is done using setSorter/setComparator.
>
>
> Tom
>
> Wen Ai schrieb:
>> Hi,
>>
>> I have a tableviewer in my program. I selected one row in the
>> tableviewer, then I tried to add this row into the next position like
>> this:
>>
>> IStructuredSelection selection =
>> (IStructuredSelection)viewer.getSelection();
>> if (selection.isEmpty()) return;
>>
>> for(Object o:selection.toList()){
>> viewer.insert(o, viewer.getTable().getSelectionIndex() + 1);
>> }
>>
>> As result I got it, but the next row is missing. However, I got a
>> prolem when I sort this tableviewer. Exactly for that, the rows in
>> the tableviewer can be sorted in order, but the tableviewer displays
>> just the old information instead of the updated information.
>>
>> Many thanks.
>>
>> Greetings
>>
>> Wen
>
>
Re: insert in tableviewer [message #55435 is a reply to message #55409] Thu, 25 October 2007 09:23 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

If Viewer#insert() / Viewer#remove() doesn't work you can do it brute
force by removing/adding the Model-Element from/to your content-model
and calling Viewer#refresh().

The best you can do to get help is to provide a standalone snippet which
we can run to see the problem. To make sure your code can work at all
I'd first test against Standard-JFace libs who are using SWT because if
it doesn't work there it won't either in RAP (I assume that JFace/SWT is
much more tested than RAP's widget libs :-).

Tom

Wen Ai schrieb:
> Hi,
>
> thanks for your infos. But I still face to the problem, how can I add
> something new in my table model or delete a row from it. I know two
> methods in the ContentProvider are very important for that: getElements
> and inputChanged. I'm still testing this and I can't find some examples
> exactly for this thema from the google. Can anyone help?
>
> Wen
>
> Tom Schindl schrieb:
>> Well I'm talking about JFaceViewers and expect that this is also true
>> for RAP:
>>
>> 1. One instance more than once in Viewer
>> ------------------------------------------
>> TableViewer doesn't support putting the same instance more than once
>> in the Table-Model. TreeViewer supports it but only under different
>> TreePaths.
>>
>> 2. Only inserting the Object
>> ----------------------------
>> From your code below I see that you are only adding the new instance
>> to the Viewer but not your model, whenever the TableViewer is
>> refreshed your changes are lost.
>>
>> 3. Sorting in Viewers:
>> ----------------------
>> Is done using setSorter/setComparator.
>>
>>
>> Tom
>>
>> Wen Ai schrieb:
>>> Hi,
>>>
>>> I have a tableviewer in my program. I selected one row in the
>>> tableviewer, then I tried to add this row into the next position like
>>> this:
>>>
>>> IStructuredSelection selection =
>>> (IStructuredSelection)viewer.getSelection();
>>> if (selection.isEmpty()) return;
>>>
>>> for(Object o:selection.toList()){
>>> viewer.insert(o, viewer.getTable().getSelectionIndex() + 1);
>>> }
>>>
>>> As result I got it, but the next row is missing. However, I got a
>>> prolem when I sort this tableviewer. Exactly for that, the rows in
>>> the tableviewer can be sorted in order, but the tableviewer displays
>>> just the old information instead of the updated information.
>>>
>>> Many thanks.
>>>
>>> Greetings
>>>
>>> Wen
>>
>>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: insert in tableviewer [message #55682 is a reply to message #55435] Fri, 26 October 2007 07:30 Go to previous message
Eclipse UserFriend
Originally posted by: wen.ai.gillardon.de

Hi,

the problem was resolved. I have defined the table data inside the
method getElements() in the ContentProvider before. Then I change this
and put the data with viewer.setInput(getInputData()). If I delete or
add rows into the table view, just generate a new input data(or change
this data), and use the method setInput(newInputData) again. It works fine.

Thanks for all the helps :-)

Greetings

Wen

Tom Schindl schrieb:
> Hi,
>
> If Viewer#insert() / Viewer#remove() doesn't work you can do it brute
> force by removing/adding the Model-Element from/to your content-model
> and calling Viewer#refresh().
>
> The best you can do to get help is to provide a standalone snippet which
> we can run to see the problem. To make sure your code can work at all
> I'd first test against Standard-JFace libs who are using SWT because if
> it doesn't work there it won't either in RAP (I assume that JFace/SWT is
> much more tested than RAP's widget libs :-).
>
> Tom
>
> Wen Ai schrieb:
>> Hi,
>>
>> thanks for your infos. But I still face to the problem, how can I add
>> something new in my table model or delete a row from it. I know two
>> methods in the ContentProvider are very important for that:
>> getElements and inputChanged. I'm still testing this and I can't find
>> some examples exactly for this thema from the google. Can anyone help?
>>
>> Wen
>>
>> Tom Schindl schrieb:
>>> Well I'm talking about JFaceViewers and expect that this is also true
>>> for RAP:
>>>
>>> 1. One instance more than once in Viewer
>>> ------------------------------------------
>>> TableViewer doesn't support putting the same instance more than once
>>> in the Table-Model. TreeViewer supports it but only under different
>>> TreePaths.
>>>
>>> 2. Only inserting the Object
>>> ----------------------------
>>> From your code below I see that you are only adding the new instance
>>> to the Viewer but not your model, whenever the TableViewer is
>>> refreshed your changes are lost.
>>>
>>> 3. Sorting in Viewers:
>>> ----------------------
>>> Is done using setSorter/setComparator.
>>>
>>>
>>> Tom
>>>
>>> Wen Ai schrieb:
>>>> Hi,
>>>>
>>>> I have a tableviewer in my program. I selected one row in the
>>>> tableviewer, then I tried to add this row into the next position
>>>> like this:
>>>>
>>>> IStructuredSelection selection =
>>>> (IStructuredSelection)viewer.getSelection();
>>>> if (selection.isEmpty()) return;
>>>>
>>>> for(Object o:selection.toList()){
>>>> viewer.insert(o, viewer.getTable().getSelectionIndex() + 1);
>>>> }
>>>>
>>>> As result I got it, but the next row is missing. However, I got a
>>>> prolem when I sort this tableviewer. Exactly for that, the rows in
>>>> the tableviewer can be sorted in order, but the tableviewer displays
>>>> just the old information instead of the updated information.
>>>>
>>>> Many thanks.
>>>>
>>>> Greetings
>>>>
>>>> Wen
>>>
>>>
>
>
Previous Topic:Exception unloading sessions to persistent storage
Next Topic:PreferenceStore not supported?
Goto Forum:
  


Current Time: Sat Nov 09 01:02:24 GMT 2024

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

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

Back to the top