Skip to main content



      Home
Home » Eclipse Projects » NatTable » Different SpanningDataBodyDataProvider for nattable(Different SpanningDataBodyDataProvider for nattable)
Different SpanningDataBodyDataProvider for nattable [message #1720249] Fri, 15 January 2016 09:48 Go to next message
Eclipse UserFriend
Hi,

I have a customSpanningDataBodyProvider() which changes for different kinds of settings I have.

For example, one of the setting I have displays 12 columns and other should show 25 columns and 13 columns.

My question is, Once the dataprovider is set can we change it later?

If the dataprovider vlaues are changed, do we have to create the datalayer, Viewportlayer and add configurations again?

Could you please tell me how to set the different bodydataprovider for datalayer?

Re: Different SpanningDataBodyDataProvider for nattable [message #1720255 is a reply to message #1720249] Fri, 15 January 2016 10:09 Go to previous messageGo to next message
Eclipse UserFriend
Looking into the code, it seems there is a setter, but unfortunately it is protected.

For now you could try to subclass DataLayer and make setDataProvider() public. Technically it should work if you afterwards execute a StructuralRefreshCommand to inform all layers about the change. Also notice that the column header dataprovider is typically linked to the body and therefore also needs to be updated (e.g. you have more columns).

If that works out for you, you could file a request to make setDataProvider() public by default.

Another option would be to design the IDataProvider in a way that their content is exchangeable instead of making it necessary to exchange the IDataProvider.
Re: Different SpanningDataBodyDataProvider for nattable [message #1720264 is a reply to message #1720255] Fri, 15 January 2016 10:47 Go to previous messageGo to next message
Eclipse UserFriend

Quote:
Another option would be to design the IDataProvider in a way that their content is exchangeable instead of making it necessary to exchange the IDataProvider.


I am sorry. I am new to Nattable. What do you mean by this statement?
Re: Different SpanningDataBodyDataProvider for nattable [message #1720266 is a reply to message #1720264] Fri, 15 January 2016 10:56 Go to previous messageGo to next message
Eclipse UserFriend
That has nothing to do with NatTable in special. That is Java. Wink

You don't need to use the default IDataProvider implemenations. You can create your own by implementing IDataProvider. And there you can add setters that allows you to specify different column configurations.
Re: Different SpanningDataBodyDataProvider for nattable [message #1720368 is a reply to message #1720266] Mon, 18 January 2016 04:05 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dirk,

I already have a customDataProvider which implements IDataProvider where I have setters and getters. Everything works fine. My problem is to optimize the performance of the Nattable that I am using, so trying to make a clean code.




Re: Different SpanningDataBodyDataProvider for nattable [message #1720377 is a reply to message #1720368] Mon, 18 January 2016 04:41 Go to previous messageGo to next message
Eclipse UserFriend
At that point there shouldn't be performance issues.
Re: Different SpanningDataBodyDataProvider for nattable [message #1720424 is a reply to message #1720377] Mon, 18 January 2016 10:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dirk,

As you said I subclass DataLayer and made setDataProvider() public and called the strauturalRefreshCommand. It works. Thanks for the suggestion.

I have one more question regarding the ColumnHeaderLayer. As I have mentioned before in the first post, I have different kinds of setting, each with different columnheaders and columngroupheaders.
ColumnHeaderLayer colLayer = null;
				ColumnGroupHeaderLayer colgroupLayer = null;
				ColumnGroupGroupHeaderLayer colgroupgroupLayer = null;
				if(type == "XYZ")){
					
					// Create HeadLayer
					colLayer = new ColumnHeaderLayer(
							headData.getHeaderDataLayer(),
							viewportLayer,
							selLayer);
								
					colgroupLayer = new ColumnGroupHeaderLayer(colLayer, selLayer, headData.getColumnGroupModel());
					for(ColumnGroups grp : colGroupsGroups){
						colgroupLayer.addColumnsIndexesToGroup(grp.groupName, grp.childIndex);
					}
					
					colgroupgroupLayer = new ColumnGroupGroupHeaderLayer(
							colgroupLayer,
							selLayer,
							headData.getColumnGroupModel());

					// create groups
					for (ColumnGroups cg : colGroups)
						colgroupgroupLayer.addColumnsIndexesToGroup(cg.groupName, cg.childIndex);
					
					
					// set HeadLayer
					table.setColumnHeaderLayer(colLayer);
				} else{
					// Create HeadLayer
					colLayer = new ColumnHeaderLayer(
							headData.getHeaderDataLayer(),
							viewportLayer,
							selLayer);

					// create groupLayer
					colgroupLayer = new ColumnGroupHeaderLayer(
							colLayer, selLayer, headData.getColumnGroupModel());

					// create groups
					for (ColumnGroups cg : colGroups)
						colgroupLayer.addColumnsIndexesToGroup(cg.groupName, cg.childIndex);

					// set HeadLayer
					table.setColumnHeaderLayer(colLayer);
				}
				if(colgroupgroupLayer != null)
					compLayer.setChildLayer(GridRegion.COLUMN_HEADER, colgroupgroupLayer, 0, 0);
				else
					compLayer.setChildLayer(GridRegion.COLUMN_HEADER, colgroupLayer, 0, 0);
				compLayer.setChildLayer(GridRegion.BODY, viewportLayer, 0, 1);


Whenever I change my settings should I create ColumnHeaderLayer or ColumnGroupHeaderLayer every time ? Is it the correct way of doing it? Or If you have any other suggestions please let me know.
Re: Different SpanningDataBodyDataProvider for nattable [message #1720524 is a reply to message #1720424] Tue, 19 January 2016 03:05 Go to previous messageGo to next message
Eclipse UserFriend
As I already explained in another thread of yours, it is never a good idea to re-create the layer stack. Operate on the necessary bottom line, IDataProvider and ColumnGroupModel
Re: Different SpanningDataBodyDataProvider for nattable [message #1720588 is a reply to message #1720524] Tue, 19 January 2016 09:42 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dirk,

As you said I am avoiding recreating the layer stack.

// Create HeadLayer
					colLayer = new ColumnHeaderLayer(
							getHeaderDataLayer(), 
							viewportLayer,
							selLayer);



I have a getHeaderLayer method which creates the new DefaultColumnHeaderDataProvider(columnIDs[],columnIDToLabelMap) and set the dataProvider for the DataLayer and return back the DataLayer object.

If I need to avoid recreating the ColumnHeaderLayer for the second time, then I have to some how set the datalayer for the ColumnHeaderLayer(). But there is no set method for setting the datalayer to the ColumnHeaderLayer.

Whats should I do ? or Am I missing something ?
Re: Different SpanningDataBodyDataProvider for nattable [message #1720592 is a reply to message #1720588] Tue, 19 January 2016 10:03 Go to previous messageGo to next message
Eclipse UserFriend
Set the IDataProvider to the DataLayer?
Re: Different SpanningDataBodyDataProvider for nattable [message #1720595 is a reply to message #1720592] Tue, 19 January 2016 10:24 Go to previous messageGo to next message
Eclipse UserFriend
Inside my getHeaderDataLayer() I have the following code:

	public IDataProvider getHeaderDataProvider() {
		return new DefaultColumnHeaderDataProvider(columnID,columnIDToLabelMap);
		
	}
	public DataLayer getHeaderDataLayer(){
		return new DataLayer(getHeaderDataProvider(),30,40);
	}



This getHeaderDataLayer() is passed inside the ColumnHeaderLayer() as I have mentioned before.

(ColumnID,columnIDtoLabel) values changes based on different settings.

[Updated on: Tue, 19 January 2016 10:25] by Moderator

Re: Different SpanningDataBodyDataProvider for nattable [message #1720612 is a reply to message #1720595] Tue, 19 January 2016 14:25 Go to previous messageGo to next message
Eclipse UserFriend
I said you should avoid re-creating the layer stack. That also means avoid re-creating layers. Set the IDataProvider to the DataLayer and do not create a new DataLayer. You said it is working for you on the body layer stack. So why do you want to introduce another mechanism for the header?

It is really frustrating to explain the same thing in one thread multiple times! And I won't answer that question again.

If you are not familiar with NatTable basics, read the Getting Started Tutorial I published a while ago: http://www.vogella.com/tutorials/NatTable/article.html
Re: Different SpanningDataBodyDataProvider for nattable [message #1720668 is a reply to message #1720612] Wed, 20 January 2016 03:49 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dirk,

My question is about columnheaderlayer and not about the datalayer. The code that I posted is my old one and I just wanted to show you. And as you said before I have already changed it by extending the datalyer class and setting the dataprovider. I avoided creating new data layer and only set the new dataproviders. My only question is with the columnheaderlayer and columngroupheaderlayer. How to set it the second time? Because there is no setter methods for columnheaderlayer for different dataproviders.

I am sorry that's really frustrating for you. As you have said before I went through the nattable basics.

Thanks
Re: Different SpanningDataBodyDataProvider for nattable [message #1720670 is a reply to message #1720668] Wed, 20 January 2016 04:06 Go to previous messageGo to next message
Eclipse UserFriend
And I don't understand your questions about the ColumnHeaderLayer. That is also a top layer that has a DataLayer in the stack underneath. So it is the same!
Re: Different SpanningDataBodyDataProvider for nattable [message #1720697 is a reply to message #1720670] Wed, 20 January 2016 05:42 Go to previous messageGo to next message
Eclipse UserFriend
ColumnHeaderLayer has three paramaters in the constructor.

IUniqueIndexLayer baseLayer - I am passing the datalayer with different dataprovider
ILayer horizontalLayerDependency - ViewPortLayer
SelectionLayer selectionLayer - SelectionLayer


To get the baseLayer with different dataprovider, I subclassed the datalayer class and set the DataProvider as you have mentioned earlier in the post. so that works fine

My question is to avoid creating ColumnHeaderLayer again(during second time nattable reloads with different dataprovider)so I have to some how set the changed IUniqueIndexLayer baseLayer to ColumnHeaderLayer.



I checked the eclipse class defenition website, there is no setters for the IUniqueIndexLayer baseLayer in ColumnHeaderLayer class. Then how do I set the changed baselayer in ColumnHeaderLayer?

Same question for ColumnGroupHeaderLyer if ColumnHeaderLayer is changed how do I set it in ColumnGroupHeaderLyer ?

I am really sorry to bother you with these questions.

I hope you understand my question now.

[Updated on: Wed, 20 January 2016 05:52] by Moderator

Re: Different SpanningDataBodyDataProvider for nattable [message #1720701 is a reply to message #1720697] Wed, 20 January 2016 05:54 Go to previous messageGo to next message
Eclipse UserFriend
I understood the question already the first time, but you don't understand my answer.

DON'T RECREATE THE LAYERS!!!

The ColumnHeaderLayer is set on top of a DataLayer and you need to change the IDataProvider on that one too. Similar to the body. And to change the column grouping, operate on the ColumnGroupModel.

If you still don't get it I don't know how to help any further.
Re: Different SpanningDataBodyDataProvider for nattable [message #1720744 is a reply to message #1720701] Wed, 20 January 2016 10:47 Go to previous message
Eclipse UserFriend
Hi Dirk,

Now I understood what you mean. I was confused before regarding the columnheaderLayer.

Now I set the changed dataProvider as I did for the body. and It works fine.

Thanks a lot for answering all my questions.

Previous Topic:Export Excel raises NPE
Next Topic:Value does not get set and table freezes
Goto Forum:
  


Current Time: Fri Jun 13 08:50:34 EDT 2025

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

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

Back to the top