Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Changing model for a TableViewer in a View
Changing model for a TableViewer in a View [message #333490] Mon, 15 December 2008 15:52 Go to next message
Eclipse UserFriend
Originally posted by: sean.mitchwood.com

Hi All..

I'm working on an RCP app that has a view which lists items in a
TableViewer.

The view is backed by a model which is provided as a service by OSGi
declarative services, and so typically it may or may not available.

My problem is that when the model turns up in my ServiceTracker, and I
call setInput(model) and then refresh() on the TableViewer, my View does
not refresh itself.

In the ContentProvider I can see that inputChanged() is being called,
but not getElements().

I'm not sure if I've approached this the right way, but it's certainly
not working as I expected.

Anyone have any insight on this problem?

Cheers,

Sean
Re: Changing model for a TableViewer in a View [message #333507 is a reply to message #333490] Tue, 16 December 2008 11:15 Go to previous messageGo to next message
Francois Fernandes is currently offline Francois FernandesFriend
Messages: 8
Registered: July 2009
Junior Member
did you call the setInput(model) and refresh on the SWT Event thread
using Display.asyncExec? Maybe this could solve the problem...

On Mon, 15 Dec 2008 10:52:32 -0500, Sean Mitchell <sean@mitchwood.com>
wrote:

>Hi All..
>
>I'm working on an RCP app that has a view which lists items in a
>TableViewer.
>
>The view is backed by a model which is provided as a service by OSGi
>declarative services, and so typically it may or may not available.
>
>My problem is that when the model turns up in my ServiceTracker, and I
>call setInput(model) and then refresh() on the TableViewer, my View does
>not refresh itself.
>
>In the ContentProvider I can see that inputChanged() is being called,
>but not getElements().
>
>I'm not sure if I've approached this the right way, but it's certainly
>not working as I expected.
>
>Anyone have any insight on this problem?
>
>Cheers,
>
>Sean
Re: Changing model for a TableViewer in a View [message #333524 is a reply to message #333507] Tue, 16 December 2008 14:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sean.mitchwood.com

Francois Fernandes wrote:

> did you call the setInput(model) and refresh on the SWT Event thread
> using Display.asyncExec? Maybe this could solve the problem...

Thanks, I did, still no luck, although it did get me past the thread
access exception I didn't realise I was having. I hate how all these
exceptions are quietly hidden away... is there any way in the PDE to
make exceptions a little more noticeable?

Cheers,

Sean
Re: Changing model for a TableViewer in a View [message #333526 is a reply to message #333524] Tue, 16 December 2008 14:31 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Yes run with -consoleLog and you'll see them all.

Tom

Sean Mitchell schrieb:
> Francois Fernandes wrote:
>
>> did you call the setInput(model) and refresh on the SWT Event thread
>> using Display.asyncExec? Maybe this could solve the problem...
>
> Thanks, I did, still no luck, although it did get me past the thread
> access exception I didn't realise I was having. I hate how all these
> exceptions are quietly hidden away... is there any way in the PDE to
> make exceptions a little more noticeable?
>
> Cheers,
>
> Sean


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Changing model for a TableViewer in a View [message #333535 is a reply to message #333526] Wed, 17 December 2008 03:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Store the input object in Vector or ArrayList. Then set the vector/arraylist as input. Check for the instanceof of the input element in getElements method as in the following code. Make sure that the methods in label provider also checks for instanceof input element.

public Object[] getElements(Object inputElement) {
   ArrayList<Object> objList = new ArrayList<Object>();
   if (inputElement instanceof Vector) {
      objList.addAll((Vector) inputElement);
   }
   return objList.toArray();
}


~Prasanna
Re: Changing model for a TableViewer in a View [message #333537 is a reply to message #333526] Wed, 17 December 2008 03:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Hi,

Store the input object in Vector or ArrayList. Then set the vector/arraylist as input. Check for the instanceof of the input element in getElements method as in the following code.

public Object[] getElements(Object inputElement) {
   ArrayList<Object> objList = new ArrayList<Object>();
   if (inputElement instanceof Vector) {
      objList.addAll((Vector) inputElement);
   }
   return objList.toArray();
}


Make sure that the methods in label provider also checks for instanceof of the input element.

~Prasanna
Re: Changing model for a TableViewer in a View [message #333539 is a reply to message #333526] Wed, 17 December 2008 03:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Hi,

Store the input object in Vector or ArrayList. Then set the vector/arraylist as input. Check for the instanceof of the input element in getElements method as in the following code.

public Object[] getElements(Object inputElement) {
   ArrayList<Object> objList = new ArrayList<Object>();
   if (inputElement instanceof Vector) {
      objList.addAll((Vector) inputElement);
   }
   return objList.toArray();
}


Make sure that the methods in label provider also checks for instanceof of the input element.

~Prasanna
Re: Changing model for a TableViewer in a View [message #333540 is a reply to message #333524] Wed, 17 December 2008 03:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Hi,

Store the input object in Vector or ArrayList. Then set the vector/arraylist as input. Check for the instanceof of the input element in getElements method as in the following code.

public Object[] getElements(Object inputElement) {
   ArrayList<Object> objList = new ArrayList<Object>();
   if (inputElement instanceof Vector) {
      objList.addAll((Vector) inputElement);
   }
   return objList.toArray();
}


Make sure that the methods in label provider class also checks for instanceof of the input element before retrieveing the data.

~Prasanna
Re: Changing model for a TableViewer in a View [message #333546 is a reply to message #333540] Wed, 17 December 2008 05:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Hi,

I am sorry for the repeated replies. I noticed that the server threw exception on replies, hence I tried posting the messages repeatedly.

Thanks for understanding.

~Prasanna
Re: Changing model for a TableViewer in a View [message #333582 is a reply to message #333546] Wed, 17 December 2008 21:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sean.mitchwood.com

Prasanna wrote:

> I am sorry for the repeated replies. I noticed that the server threw exception on replies, hence I tried posting the messages repeatedly.

Yeah man, no problem.

Thanks to all of you on this thread for your help... between your
various bits of advice I have it working now.

Arawak
Re: Changing model for a TableViewer in a View [message #333640 is a reply to message #333490] Fri, 19 December 2008 12:15 Go to previous message
Francois Fernandes is currently offline Francois FernandesFriend
Messages: 8
Registered: July 2009
Junior Member
Could you please provide some sample code on how you invoke the
methods in question?

On Mon, 15 Dec 2008 10:52:32 -0500, Sean Mitchell <sean@mitchwood.com>
wrote:

>Hi All..
>
>I'm working on an RCP app that has a view which lists items in a
>TableViewer.
>
>The view is backed by a model which is provided as a service by OSGi
>declarative services, and so typically it may or may not available.
>
>My problem is that when the model turns up in my ServiceTracker, and I
>call setInput(model) and then refresh() on the TableViewer, my View does
>not refresh itself.
>
>In the ContentProvider I can see that inputChanged() is being called,
>but not getElements().
>
>I'm not sure if I've approached this the right way, but it's certainly
>not working as I expected.
>
>Anyone have any insight on this problem?
>
>Cheers,
>
>Sean
Previous Topic:How can I change the location where the project files are stored?
Next Topic:debugging plugins at runtime?
Goto Forum:
  


Current Time: Fri Nov 08 22:52:31 GMT 2024

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

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

Back to the top