| insert in tableviewer [message #55163] | 
Wed, 24 October 2007 09:08   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 #55409 is a reply to message #55220] | 
Thu, 25 October 2007 05:11    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 05:23    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 03:30   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 
>>> 
>>> 
>  
>
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.04880 seconds