Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Nattable creation in IWorkbenchSiteProgressService
Nattable creation in IWorkbenchSiteProgressService [message #1062448] Fri, 07 June 2013 18:28 Go to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Hi,

I am having an eclipse plugin which when opened does a background job (using IWorkbenchSiteProgressService). I schedule a job and then update Nattable post the job is done in the UI thread(using syncExec from Display) and it works perfectly except that the grid is not shown until i go to another view or change perspective and come back to the view. Its a refresh issue i guess, but I do not know how to get the plugin view to refresh so that the grid is visible.

Example,
IWorkbenchSiteProgressService siteService = (IWorkbenchSiteProgressService)getSite().getAdapter(IWorkbenchSiteProgressService.class); 
			siteService.schedule( new Job()
			{
protected IStatus run(IProgressMonitor monitor) 
		{
			//Get data
                       dataList = GetFileData();
getDisplay().syncExec( new Runnable()
						{
							public void run()
							{
								//Create Nattable here with the data
							}
						} ); 
			monitor.done();
			return Status.OK_STATUS;
		}
}
)


The workObject
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062459 is a reply to message #1062448] Fri, 07 June 2013 20:42 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Well, I'm not quite sure what you are trying to do. Why are you creating the NatTable instance in a background thread instead of just creating the data in the background thread and set the data to the NatTable instance?
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062466 is a reply to message #1062459] Fri, 07 June 2013 20:51 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
I was creating the data in the background thread as it takes a while and I am passing the list of dataobjects to the grid from there and hence created in the background thread.
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062468 is a reply to message #1062466] Fri, 07 June 2013 20:55 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Are you using GlazedLists so that the NatTable is automatically refreshed when changing the content? Otherwise you need to tell the NatTable to refresh yourself.
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062470 is a reply to message #1062468] Fri, 07 June 2013 21:22 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Yes. I am using GlazedLists. The problem is that there is nothing in the Composite that I passed to create Nattable. Only why i go to another view and switch back to this view I see the grid. Its not like the data is updated dynamically. I am creating the huge list in background and when its done I create the nattable with the list of objects.
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062471 is a reply to message #1062470] Fri, 07 June 2013 21:44 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Is there any known issues when the Nattable is created in background thread? Its still created in the UI thread by calling getDisplay().syncExec() from the background run job.
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062472 is a reply to message #1062471] Fri, 07 June 2013 21:53 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Quote:
and when its done I create the nattable with the list of objects


I ask again - Why don't you create the NatTable first and populate only the data when loading is done?
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062733 is a reply to message #1062472] Mon, 10 June 2013 14:43 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Okay, I tried creating an empty Nattable grid with empty list of objects and in the background thread, the list is populated. Once data is loaded, I called refresh on the nattable and I dont see any rows in the grid now. Even If I switch between views it does not show the rows. Is there any other method on the nattable that has to be called once the list is populated, to refresh the grid?
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062736 is a reply to message #1062733] Mon, 10 June 2013 14:52 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Have you ensured that you work on the correct list reference. You need to change the content of the list you put into NatTable (clean(), addAll()) instead of changing the list reference.

This is a typical issue people ran into when dynamically changing the content in a NatTable. Usually they try to change the list instance rather than content.
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062741 is a reply to message #1062736] Mon, 10 June 2013 14:59 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Yes, I made sure its the same reference. I create an empty list of objects before passing them to the Nattable. And then I just add the objects to the list(no new ArrayList<>) or changing the reference.
For example,
List<DataRow> rows = new ArrayList<>();
Nattable nattable = CreateNattable(rows);
InitializeRows(rows); //just adds to the list.
nattable.refresh(); 


The CreateNattable creates the tree grid as mentioned in the example and also as mentioned here in one of my previous posts http://www.eclipse.org/forums/index.php/t/488236/
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062744 is a reply to message #1062741] Mon, 10 June 2013 15:09 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
When it comes to multi-threading, things get complicated. Said that, I'm not sure how to help you.

Maybe the threads are coliding, the refresh is done before the items are added to the list, or there is something else wrong. It should work, but without debugging you never can tell.

A few hints that might help you in further investigation:
- The GlazedListsEventLayer is performing refreshes when you add items to the EventList instance that is used to create the GlazedListsEventLayer or list below. So you could try to work on the eventList that wraps your ArrayList and add the GlazedListsEventLayer. This way you don't have to deal with the refresh yourself.
- As I'm not sure if you already use the GlazedListsEventLayer or not, maybe there is some issue with the threads there, as the GlazedListsEventLayer adds a small delay to collect several events and treat them as one.
- You can have a look at the "Everything_but_the_kitchen_sink" example which is also loading a lot of items prior showing the table in a separate thread. Maybe you get some hints on how to do it there.
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062746 is a reply to message #1062744] Mon, 10 June 2013 15:20 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
I am using the EventList from GlazedLists but not the GlazedListsEventLayer. Is there an example of how to use this layer? I guess not using GlazedListsEventLayer is the reason the grid is not refreshed?

Also I removed background thread and I created Nattable with empty list of objects and then populated the lists and still the grid is not refreshed. So there is no thread now.
Re: Nattable creation in IWorkbenchSiteProgressService [message #1062763 is a reply to message #1062746] Mon, 10 June 2013 16:12 Go to previous message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Okay, I figured out that instead of adding objects to the list, adding to the EvenList reference works.
Previous Topic:removing alternate row color style
Next Topic:Font changes when editing a cell with an Inline Text Control
Goto Forum:
  


Current Time: Thu Mar 28 18:30:13 GMT 2024

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

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

Back to the top