Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » When to apply the DefaultNatTableStyleConfiguration?
When to apply the DefaultNatTableStyleConfiguration? [message #990462] Wed, 12 December 2012 15:31 Go to next message
Alex Kipling is currently offline Alex KiplingFriend
Messages: 260
Registered: July 2012
Senior Member
I did
        DefaultNatTableStyleConfiguration defaultNatTableStyleConfiguration = new DefaultNatTableStyleConfiguration();
        defaultNatTableStyleConfiguration.hAlign = HorizontalAlignmentEnum.LEFT;

        natTable.addConfiguration(defaultNatTableStyleConfiguration);
        natTable.configure();


but it did not work.
How would I apply the DefaultNatTableStyleConfiguration ?
Re: When to apply the DefaultNatTableStyleConfiguration? [message #990477 is a reply to message #990462] Wed, 12 December 2012 16:15 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
DefaultNatTableStyleConfiguration defaultNatTableStyleConfiguration = new DefaultNatTableStyleConfiguration() {
    {
        this.hAlign = HorizontalAlignmentEnum.LEFT;
    }
};

natTable.addConfiguration(defaultNatTableStyleConfiguration);
natTable.configure();


because the constructor of DefaultNatTableStyleConfiguration puts the values in the ConfigRegistry. Therefore you need to change the value before the constructor is executed, which can be achieved with a init block in Java.
Re: When to apply the DefaultNatTableStyleConfiguration? [message #990580 is a reply to message #990477] Thu, 13 December 2012 09:41 Go to previous messageGo to next message
Alex Kipling is currently offline Alex KiplingFriend
Messages: 260
Registered: July 2012
Senior Member
Thnx Dirk, but this still does not work.
This is my code:
DefaultNatTableStyleConfiguration defaultNatTableStyleConfiguration = new DefaultNatTableStyleConfiguration() {
            {
                hAlign = HorizontalAlignmentEnum.LEFT;
            }

            @Override
            public void configureRegistry(IConfigRegistry configRegistry) {
                super.configureRegistry(configRegistry);
            }
        };

        gridLayer.addConfiguration(defaultNatTableStyleConfiguration);
        natTable.addConfiguration(defaultNatTableStyleConfiguration);
        natTable.configure();


The method configureRegistry(IConfigRegistry) is triggered, but I have no Idea how to check, whether the settings are there after doing natTable.configure();

What could be the reason for not applying the config?
Should the IConfigRegistry be applied to the NatTable or to the layers?

Inside the defaultNatTableStyleConfiguration - the attribute hAlign is applied to the CellStyle as following,
which appears to change the global cell style.
cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, hAlign);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle);


How can I retrieve the cellStyle object from the NatTable again, so that i can see, whether the hAlign was applied right?
IConfigRegistry reg = natTable.getConfigRegistry();
// how to get the cellStyle from the reg?
Re: When to apply the DefaultNatTableStyleConfiguration? [message #990585 is a reply to message #990580] Thu, 13 December 2012 09:58 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hi Alex,

this is some code I use and which works fine:

NatTable natTable = new NatTable(parent, layer, false);
		
natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
	{
		vAlign = VerticalAlignmentEnum.TOP;
		hAlign = HorizontalAlignmentEnum.LEFT;
	}
});
		
natTable.configure();


Are you sure that you don't overwrite the styling by using some conditional styling based on labels?

You can for example add the following configuration to your NatTable instance, which will enable a context menu that allows you to check which labels are attached to your cell.

natTable.addConfiguration(new DebugMenuConfiguration(natTable));


Also you don't need to add the DefaultNatTableStyleConfiguration to both, the GridLayer and the NatTable. NatTable should be enough.

The only other thing that might cause an issue could be the ConfigRegistry instance. Are you creating new one at the beginning? In this case you would need to set it back to the NatTable of course. Otherwise the NatTable will create its own one, and then your configuration and your instantiation of NatTable won't use the same one.

Hope that helps,
Dirk

Oh, and regarding your question, if you want to retrieve a value out of the ConfigRegistry, use getConfigAttribute(). UTSL (always wanted to use this Wink )

IConfigRegistry reg = natTable.getConfigRegistry();
reg.getConfigAttribute(CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL);

[Updated on: Thu, 13 December 2012 10:02]

Report message to a moderator

Re: When to apply the DefaultNatTableStyleConfiguration? [message #990623 is a reply to message #990585] Thu, 13 December 2012 13:41 Go to previous message
Alex Kipling is currently offline Alex KiplingFriend
Messages: 260
Registered: July 2012
Senior Member
Thnx, indeed I was overriding the ConfigRegistry!
Previous Topic:Disabling or enabling the cells in the table
Next Topic:How to freeze the table programmatially?
Goto Forum:
  


Current Time: Thu Apr 25 20:45:27 GMT 2024

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

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

Back to the top