[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] Re: having trouble using ViewerSorter

From Tiger's first post, it looks like he's not using a content provider.

Tiger, you should be using setContentProvider and setInput() rather than
adding items directly to the viewer.
When the sorter changes, or when refresh() is called, the viewer asks the
content provider for the elements.
It then sorts them using the sorter and shows them.
The add(), remove() and update() methods on the viewers are intended to be
called by the content provider in response to model changes.
They should not be called by the model itself.

Nick

"Eduardo Pereira" <eduardo_pereira@xxxxxxx> wrote in message
news:9u8mju$v5c$1@xxxxxxxxxxxxxxxx
> > > do I have to save (in an ArrayList, or something else) the content of
> the
> > > table before appling the sorter and then restore the datas ??
>
> TableViewer will refresh the contents when a sorter is set. Then the
method
> getElements(..) in your content provider should be called. Is getElements
> returning the array with all elements?
>
> Eduardo.
>
> "John Arthorne" <john_arthorne@xxxxxxxx> wrote in message
> news:3C07AE38.C3E0B881@xxxxxxxxxxx
> > Adding a sorter shouldn't be removing anything from your table.  It
should
> be as
> > simple as calling viewer.setSorter(...).  Could you post a code snippet
> from your
> > table and sorter?  Maybe someone on the UI team will be able to help you
> diagnose
> > your problem...
> >
> >
> > Tiger wrote:
> >
> > > Thanks for the trick ...
> > >
> > > but I still have my problem .... when I select a Column the content of
> the
> > > table disappeared :-(
> > > do I have to save (in an ArrayList, or something else) the content of
> the
> > > table before appling the sorter and then restore the datas ??
> > >
> >
>
>