Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » False display of columnWidths after restore via natTable.loadState()
False display of columnWidths after restore via natTable.loadState() [message #1053096] Thu, 02 May 2013 12:29 Go to next message
Franz-Josef Wiszniewsky is currently offline Franz-Josef Wiszniewsky
Messages: 11
Registered: January 2013
Junior Member
Hello,

I'm using natTable's handy loadState() method in order to reload a previously saved table configuration. All loaded data is applied correctly i.e. sort order, sort directions, hidden columns, filter row values, (renamed) header labels, column order. The corresponding values are shown and ordered correctly.

My current problem is that the column widths are loaded from the formerly saved properties, but not correctly displayed. The StructuralRefreshEvent fired by the dataLayer after columnWithConfig and rowHeightConfig were updated, seems to go unheard.

public class DataLayer extends AbstractLayer implements IUniqueIndexLayer {

...

public void loadState(String prefix, Properties properties) {
  ...
  columnWidthConfig.loadState(prefix + PERSISTENCE_KEY_COLUMN_WIDTH, properties);
  ...
  fireLayerEvent(new StructuralRefreshEvent(this));
}
...
}


After executing loadState() the user must either manually resize the whole window or at least the width of a random column in order to get the right visualization.

Without success I tried to refresh the table using (separately) each of the following lines
- natTable.refresh();
- natTable.redraw(); natTable.update();
- parent.redraw(); parent.update();   // where parent is the composite holding the table
- parent.layout();
- parent.layout(true);
- parent.layout(true, true);
- natTable.doCommand(new InitializeAutoResizeColumnsCommand(natTable, column, natTable.getConfigRegistry(), new GCFactory(natTable)));  // on every column


The dataLayer I'm referring to is the (base) dataLayer of my body layer stack. ColumnPercentageSizing is activated for this layer.

Please let me know how to get correctly sized columns.
Any help is appreciated.
Re: False display of columnWidths after restore via natTable.loadState() [message #1053100 is a reply to message #1053096] Thu, 02 May 2013 12:52 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
What version of NatTable are you using? 0.9.0 or a 1.0.0 SNAPSHOT?
Re: False display of columnWidths after restore via natTable.loadState() [message #1053104 is a reply to message #1053100] Thu, 02 May 2013 13:13 Go to previous messageGo to next message
Franz-Josef Wiszniewsky is currently offline Franz-Josef Wiszniewsky
Messages: 11
Registered: January 2013
Junior Member
Hi,

thanks for the quick reply. I'm currently using version 0.9.0. It's a nightly build from 23th September 2012.

Greetings
Franz-Josef
Re: False display of columnWidths after restore via natTable.loadState() [message #1053112 is a reply to message #1053104] Thu, 02 May 2013 13:56 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
Ok, because I did some work on the persistence stuff for 1.0.0. And I think the column size was one issue that I solved there. So maybe you should consider updating to a 1.0.0 SNAPSHOT. The final release is only 2 weeks away. So it might be a good choice to update now to test before the final 1.0.0 release. If you notice any other issues with persistence we then would be able to fix and deliver it soon.

With 1.0.0 there will be also a DisplayPersisenceCommandHandler that opens a dialog for managing "view configurations". So that might be also interesting for you.
Re: False display of columnWidths after restore via natTable.loadState() [message #1053114 is a reply to message #1053112] Thu, 02 May 2013 14:03 Go to previous messageGo to next message
Franz-Josef Wiszniewsky is currently offline Franz-Josef Wiszniewsky
Messages: 11
Registered: January 2013
Junior Member
Hi,

thanks a lot. I will have a look at the 1.0.0 SNAPSHOT. The DisplayPersistenceCommandHandler sounds great.

Greetings
Franz-Josef
Re: False display of columnWidths after restore via natTable.loadState() [message #1053595 is a reply to message #1053114] Mon, 06 May 2013 16:20 Go to previous messageGo to next message
Franz-Josef Wiszniewsky is currently offline Franz-Josef Wiszniewsky
Messages: 11
Registered: January 2013
Junior Member
Hello,

today I tried the 1.0.0-SNAPSHOT release (build version 125) from http://download.eclipse.org/nattable/snapshots/.

Unfortunately the behaviour is still the same: the loaded sizes are applied to the table but not displayed. Nonetheless resizing the window or manually setting the width of a column provokes a refresh of the table and therefore a correct display.

Can you reproduce this behaviour as well ? Do you have a clue why the StructuralRefreshEvent does not work ?

Greetings
Franz-Josef
Re: False display of columnWidths after restore via natTable.loadState() [message #1053604 is a reply to message #1053595] Mon, 06 May 2013 18:07 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
Oh ok, just seen that you are using percentage sizing. Well the issue seems to be related to the missing size information of the control the NatTable is located in. I have to admit that I didn't check percentage sizing on loading in the UI.

Need to investigate how to get the information on loading so the calculation works.
Re: False display of columnWidths after restore via natTable.loadState() [message #1053737 is a reply to message #1053604] Tue, 07 May 2013 12:41 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
I just created an example locally that builds up a NatTable that sets the columnPercentageSizing to true. It is build upon the PersistentNatExampleWrapper in our examples package, so it persists the state on closing and loads in on opening it again. I also added buttons to change the percentages at runtime to verify things are loaded correctly. And I can not reproduce the behaviour you described. The states are correctly loaded and set to the NatTable.

Do you use setColumnWidthPercentageByPosition() to set the width or setColumnWidthByPosition()?
Re: False display of columnWidths after restore via natTable.loadState() [message #1053791 is a reply to message #1053737] Tue, 07 May 2013 15:37 Go to previous messageGo to next message
Franz-Josef Wiszniewsky is currently offline Franz-Josef Wiszniewsky
Messages: 11
Registered: January 2013
Junior Member
Hi,

I'm using setColumnWidthPercentageByPosition(). Am I right about setting this along with setColumnPercentageSizing(true) on the data layer i.e. the underlying layer of my bodyLayerStack ? Could you please provide me your small example ?

Thanks and Greetings
Franz-Josef
Re: False display of columnWidths after restore via natTable.loadState() [message #1053793 is a reply to message #1053791] Tue, 07 May 2013 15:42 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
Have you checked out the sources from git? Otherwise the example might be not that helpful. Also you need to ensure to delete the nattable.properties in your examples workspace before starting as it may contain wrong values which will overload the settings on startup.

/*******************************************************************************
 * Copyright (c) 2012 Original authors and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Dirk Fauth
 ******************************************************************************/
package org.eclipse.nebula.widgets.nattable.examples._300_Data;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
import org.eclipse.nebula.widgets.nattable.examples.AbstractNatExample;
import org.eclipse.nebula.widgets.nattable.examples.PersistentNatExampleWrapper;
import org.eclipse.nebula.widgets.nattable.examples.runner.StandaloneNatExampleRunner;
import org.eclipse.nebula.widgets.nattable.grid.data.DummyModifiableBodyDataProvider;
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
import org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack;
import org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

public class PersistentPercentageSizingDataLayerExample extends PersistentNatExampleWrapper {
	
	public static void main(String[] args) throws Exception {
		StandaloneNatExampleRunner.run(600, 650, new PersistentPercentageSizingDataLayerExample());
	}
	
	public PersistentPercentageSizingDataLayerExample() {
		super(new Test());
	}
}

class Test extends AbstractNatExample {
	
	@Override
	public Control createExampleControl(Composite parent) {
		parent.setLayout(new GridLayout());
		
		final DummyModifiableBodyDataProvider dataProvider = new DummyModifiableBodyDataProvider(3, 2);
		
		DummyGridLayerStack gridLayer = new DummyGridLayerStack(dataProvider);
		final DataLayer n5DataLayer = (DataLayer) gridLayer.getBodyDataLayer();
		n5DataLayer.setColumnWidthPercentageByPosition(0, 25);
		n5DataLayer.setColumnWidthPercentageByPosition(1, 25);
		n5DataLayer.setColumnWidthPercentageByPosition(2, 50);
		n5DataLayer.setColumnPercentageSizing(true);
		
		final NatTable n5 = new NatTable(parent, gridLayer, false);
		n5.addConfiguration(new DefaultNatTableStyleConfiguration());
		n5.addConfiguration(new HeaderMenuConfiguration(n5));
		n5.configure();
		
		GridDataFactory.fillDefaults().grab(true, false).applyTo(n5);
		
		//add buttons
		Button b1 = new Button(parent, SWT.PUSH);
		b1.setText("change");
		b1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				n5DataLayer.setColumnWidthPercentageByPosition(0, 50);
				n5DataLayer.setColumnWidthPercentageByPosition(1, 25);
				n5DataLayer.setColumnWidthPercentageByPosition(2, 25);
			}
		});
		Button b2 = new Button(parent, SWT.PUSH);
		b2.setText("default");
		b2.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				n5DataLayer.setColumnWidthPercentageByPosition(0, 25);
				n5DataLayer.setColumnWidthPercentageByPosition(1, 25);
				n5DataLayer.setColumnWidthPercentageByPosition(2, 50);
			}
		});
		
		return n5;
	}
}
Re: False display of columnWidths after restore via natTable.loadState() [message #1053794 is a reply to message #1053793] Tue, 07 May 2013 15:43 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
No Message Body
Re: False display of columnWidths after restore via natTable.loadState() [message #1058046 is a reply to message #1053794] Fri, 10 May 2013 15:32 Go to previous messageGo to next message
Franz-Josef Wiszniewsky is currently offline Franz-Josef Wiszniewsky
Messages: 11
Registered: January 2013
Junior Member
Thanks a lot for your help.
The issue got a lower priority assigned in my project. So it will take some time until I have any news. But I will try your code for sure.

Greetings,
Franz-Josef
Re: False display of columnWidths after restore via natTable.loadState() [message #1075997 is a reply to message #1058046] Tue, 30 July 2013 13:36 Go to previous messageGo to next message
Franz-Josef Wiszniewsky is currently offline Franz-Josef Wiszniewsky
Messages: 11
Registered: January 2013
Junior Member
This problem has been fixed in nattable release version 1.0.0.
Re: False display of columnWidths after restore via natTable.loadState() [message #1078119 is a reply to message #1053100] Fri, 02 August 2013 15:06 Go to previous messageGo to next message
Franz-Josef Wiszniewsky is currently offline Franz-Josef Wiszniewsky
Messages: 11
Registered: January 2013
Junior Member
Hi,

thanks for your quick reply.
I'm currently using version 1.0.0 dated from 2nd june 2013.
Greetings
Re: False display of columnWidths after restore via natTable.loadState() [message #1078138 is a reply to message #1078119] Fri, 02 August 2013 15:30 Go to previous message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
We released a bugfix release 1.0.1 recently. Maybe you want to have a look.
Previous Topic:Upgrade from SourceForge 0.9 To Nebula 1.0.1
Next Topic:Wrong calculation of column startX after loadState()
Goto Forum:
  


Current Time: Mon Sep 22 00:29:38 GMT 2014

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

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