Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Table with no row header
Table with no row header [message #1066823] Thu, 04 July 2013 14:11 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello,

I'm trying to create a table which doesn't have a row header (so simply a column header and a data section). I initially started with a GridLayer, but this layer always display the row header.

So, I changed to a CompositeLayer and created the column layer and body layer, but now my table is not editable anymore (which was the case when using a gridLayer).

Here is a code snippet:

		EventPropertyBodyLayerStack bodyLayer = new EventPropertyBodyLayerStack(
				eventType.getProperties(), propertyNames);

		// Column header
		DefaultColumnHeaderDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
				propertyNames, propertyToLabelMap);
		ILayer columnHeaderLayer = new ColumnHeaderLayer(
				new DefaultColumnHeaderDataLayer(columnHeaderDataProvider),
				bodyLayer, bodyLayer.getSelectionLayer());

		CompositeLayer compositeLayer = new CompositeLayer(1, 2);
		compositeLayer.setChildLayer(GridRegion.BODY, bodyLayer, 0, 1);
		compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER,
				columnHeaderLayer, 0, 0);

		final ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(
				bodyLayer.getDataLayer());
		bodyLayer.getDataLayer().setConfigLabelAccumulator(
				columnLabelAccumulator);
		registerColumnLabels(columnLabelAccumulator);

		IConfigRegistry configRegistry = new ConfigRegistry();
		natTable = new NatTable(this, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL,
				compositeLayer, false);
		natTable.setConfigRegistry(configRegistry);
		natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
		natTable.addConfiguration(new EventPropertyEditConfiguration());
		natTable.configure();


Any idea what I might be doing wrong ? If some additional code is needed, I can provide it.

Thank you,
Cédric
Re: Table with no row header [message #1066886 is a reply to message #1066823] Fri, 05 July 2013 05:00 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 the edit binding configurations are added in your edit configuration?
Re: Table with no row header [message #1066905 is a reply to message #1066886] Fri, 05 July 2013 06:31 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Yes, I'm pretty sure that this is correct, since if I replace the code with my previous code (which was creating a grid layer instead), then it works fine.
I didn't touch anything in the registerColumnLabels method and the EventPropertyEditConfiguration class.
Re: Table with no row header [message #1066906 is a reply to message #1066905] Fri, 05 July 2013 06:37 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
I had a look at the GridLayer to see what it did and I saw that there was this piece of code which overrides the CompositeLayer behavior:

	@Override
	protected boolean doCommandOnChildLayers(ILayerCommand command) {
		if (doCommandOnChildLayer(command, getBodyLayer())) {
			return true;
		} else if (doCommandOnChildLayer(command, getColumnHeaderLayer())) {
			return true;
		} else if (doCommandOnChildLayer(command, getRowHeaderLayer())) {
			return true;
		} else {
			return doCommandOnChildLayer(command, getCornerLayer());
		}
	}
	
	private boolean doCommandOnChildLayer(ILayerCommand command, ILayer childLayer) {
		ILayerCommand childCommand = command.cloneCommand();
		return childLayer.doCommand(childCommand);
	}


Is this maybe related to the problem ? I tried to implement the same functionality in my case by it still didn't work.
Re: Table with no row header [message #1066968 is a reply to message #1066906] Fri, 05 July 2013 09:34 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Again, are you sure that the DefaultEditBindings are included in your edit configuration? By default it is added in the DefaultGridLayerConfiguration, which you don't have as you don't use the GridLayer. So if you don't add it manually, it wouldn't be there!
Re: Table with no row header [message #1066974 is a reply to message #1066968] Fri, 05 July 2013 10:10 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello Dirk,

Sorry for my beginner questions, I just started to use the control, so I'm sometimes a bit lost...

Quote:
Again, are you sure that the DefaultEditBindings are included in your edit configuration? By default it is added in the DefaultGridLayerConfiguration, which you don't have as you don't use the GridLayer. So if you don't add it manually, it wouldn't be there!


Ok, I misunderstood your previous reply, I thought that you were talking about the way to configure the edit properties like shown in the examples (specifying which columns are editable, adding combobox cell editors, ...).

Indeed, I didn't do that. So, now if I add that configuration (in fact I add DefaultEditBindings and DefaultEditConfiguration) to my CompositeLayer, I can edit my fields in the table. However the selection is now behaving in a very strange way: it always disappear. So if I edit a cell and conform (for instance by hitting enter), then the cell selection disappear (which means I can't navigate my table using keyboard anymore).

Here is what I do:

		CompositeLayer compositeLayer = new CompositeLayer(1, 2);
		compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER,
				columnHeaderLayer, 0, 0);
		compositeLayer.setChildLayer(GridRegion.BODY, bodyLayer, 0, 1);
		compositeLayer.addConfiguration(new DefaultEditBindings());
		compositeLayer.addConfiguration(new DefaultEditConfiguration());


Do I add the configurations on the correct layer ?
Re: Table with no row header [message #1066982 is a reply to message #1066974] Fri, 05 July 2013 10:43 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Yes it should be the correct layer. Not sure what happens on commit. Are you doing some special stuff on commit? Is the NatTable refreshed or does it lose focus on commit?
Re: Table with no row header [message #1066992 is a reply to message #1066982] Fri, 05 July 2013 11:14 Go to previous message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Oh yes, I have a listener on my model which refreshes the table when the model changes (this allows undo/redo for instance). I'll have to find another way of doing that.

Thanks for the help !
Previous Topic:Support for color selection in a cell ?
Next Topic:Full row validation
Goto Forum:
  


Current Time: Thu Apr 25 16:34:08 GMT 2024

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

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

Back to the top