Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » getConfigLabelsByPosition
icon5.gif  getConfigLabelsByPosition [message #1715399] Mon, 23 November 2015 10:15 Go to next message
Bhagwan Moondra is currently offline Bhagwan MoondraFriend
Messages: 9
Registered: May 2015
Junior Member
Hello,

I have a NatTable implementation where-in I am applying custom label for specific columns and cells. If custom label is for complete column, then I use ColumnOverrideLabelAccumulator. If it is for certain cells of data layer, I override getConfigLabelsByPosition()

Basically, in my table I have header rows and data rows. For data rows, I need to have different styling for specific columns, hence I have defined labels for same and config registry for such labels.

Problem is, getConfigLabelsByPosition() is not getting called for all the columns. After getting LabelStack for certain column number "n", it throws an exception:

java.lang.RuntimeException: java.lang.NullPointerException
at org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor.getDataValue(ReflectiveColumnPropertyAccessor.java:58)
at org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsDataProvider.getDataValue(GlazedListsDataProvider.java:92)
at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getDataValue(DataLayer.java:132)
at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getDataValueByPosition(DataLayer.java:381)


What could be the reason that getConfigLabelsByPosition() is not getting called for specific column index. That too it gets called for header row, but never gets called for data row. I believe this overridden method shoul dbe called every time user changes position, and it should be called for all the column & row positions

Thanks
Re: getConfigLabelsByPosition [message #1715406 is a reply to message #1715399] Mon, 23 November 2015 11:39 Go to previous messageGo to next message
Arye Shemesh is currently offline Arye ShemeshFriend
Messages: 37
Registered: November 2012
Member
You should add your own LabelAccumulator (you can use CellOverrideLabelAccumulator) and not override getConfigLabelsByPosition().
Re: getConfigLabelsByPosition [message #1715548 is a reply to message #1715406] Tue, 24 November 2015 10:51 Go to previous messageGo to next message
Bhagwan Moondra is currently offline Bhagwan MoondraFriend
Messages: 9
Registered: May 2015
Junior Member
Well I tried with CellOverrideLabelAccumulator as well (and not overriding getConfigLabelsByPosition()):

            CellOverrideLabelAccumulator cellLabelAccumulator = new CellOverrideLabelAccumulator(
            		(IRowDataProvider) gridLayer.getBodyDataProvider()) {
                public void accumulateConfigLabels(LabelStack configLabels,
                        int columnPosition, int rowPosition) {
                    
                    	if(columnPosition == 5)
                    		configLabels.addLabel(ROW_DATA_EDITABLE_LABEL);
                    	else
                    		configLabels.addLabel(ROW_DATA_NONEDITABLE_LABEL);
                    }
            };


Basically I have 7 columns defined in my table and I want custom styling for column 5 for certain rows (data rows, the condition which I did not put in code above so as not to complicate my query).
The code above gets executed for all column positions till 5 and gets ROW_DATA_NONEDITABLE_LABEL label, but it is not executed for column 5 and I get the same exception as in my earlier post.

I am wondering why it would skip getting config labels for certain column. Nat table is properly defined with column header
Re: getConfigLabelsByPosition [message #1715565 is a reply to message #1715548] Tue, 24 November 2015 11:46 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Is the column visible?
Re: getConfigLabelsByPosition [message #1715567 is a reply to message #1715565] Tue, 24 November 2015 12:11 Go to previous messageGo to next message
Bhagwan Moondra is currently offline Bhagwan MoondraFriend
Messages: 9
Registered: May 2015
Junior Member
Yes, column is visible
Re: getConfigLabelsByPosition [message #1715570 is a reply to message #1715567] Tue, 24 November 2015 12:20 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
At which level do you apply the accumulator?
Are you aware of the difference between column position and column index?
Are you aware of the 0 based indeces?
Is the column you are mentioning really visible or are you scrolling to that column?

Have you read the getting started tutorial? http://www.vogella.com/tutorials/NatTable/article.html
Re: getConfigLabelsByPosition [message #1715659 is a reply to message #1715570] Wed, 25 November 2015 06:28 Go to previous messageGo to next message
Bhagwan Moondra is currently offline Bhagwan MoondraFriend
Messages: 9
Registered: May 2015
Junior Member
At which level do you apply the accumulator? --> DataLayer
Are you aware of the difference between column position and column index? --> Yes, that's why I am applying accumulator at DataLayer where index is same as position.
Are you aware of the 0 based indeces? --> Yes, my first column index is 0, second column index is 1 and so on
Is the column you are mentioning really visible or are you scrolling to that column? --> Column is visible without the need to scroll.

Have you read the getting started tutorial? --> Yes, first thing before starting implementation
Re: getConfigLabelsByPosition [message #1715662 is a reply to message #1715659] Wed, 25 November 2015 07:13 Go to previous message
Bhagwan Moondra is currently offline Bhagwan MoondraFriend
Messages: 9
Registered: May 2015
Junior Member
Solved the issue. There was no issue with accumulator or getConfigLabelsByPosition(). Problem was that I was using ReflectiveColumnPropertyAccessor which calls getDataValue() and expects a getter method for given Column name. Though I was setting column property names and column property to label map but did not know that a getter would be required with get<ColumnName>
Previous Topic:FixedSummaryRowLayer
Next Topic:Doubleclick from a NatTable doesn't work with MacOS
Goto Forum:
  


Current Time: Thu Apr 18 02:49:28 GMT 2024

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

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

Back to the top