Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » getCellByPosition() returning a null datavalue
getCellByPosition() returning a null datavalue [message #1426267] Thu, 18 September 2014 13:45 Go to next message
Quentin Le Menez is currently offline Quentin Le MenezFriend
Messages: 17
Registered: September 2014
Location: Paris Saclay, France
Junior Member
Hi !

I am currently trying to get the cells from the getCellByPosition(int, int) method. If it does indeed return a TranslatedLayerCell, most of its fields are null (such as bounds, configLabels, datavalue...) and what really has me puzzled is that i can get them using the other accessors such as getDataValueByPosition() and getConfigLabelsByPosition().
I feel like I am missing something concerning the different layers but I reallly cant find out what...


these are the two snippets I have tested so far :
BodyLayerStack bs = (BodyLayerStack) cell.getLayer().getUnderlyingLayerByPosition(cell.getColumnIndex(), cell.getRowIndex());
List<Object> rowSpan = ArrayUtil.asList(bs.getSelectionLayer().getSelectedRowPositions().toArray());
List<Integer> columnSpan = ArrayUtil.asIntegerList(bs.getSelectionLayer().getSelectedColumnPositions());
List<Integer> rowSpanRange = ArrayUtil.asList(((Range) rowSpan.get(0)).getMembers().toArray(new Integer[0]));
List<ILayerCell> mergedCells = new ArrayList<ILayerCell>();
	for (Integer indexY : rowSpanRange) {
		for (Integer indexX : columnSpan) {
			mergedCells.add(bs.getCellByPosition(indexX, indexY)); // yielding a list of cells with mostly null values
		}
	}


and,

((NatTable) parent).getLayer().getCellByPosition(2, 2); // yielding cells but with mostly null values
((NatTable) parent).getLayer().getDataValueByPosition(2, 2); // yielding the correct value
((NatTable) parent).getLayer().getConfigLabelsByPosition(2, 2); // yielding the correct value


Thank you for any enlightenment that you could bestow upon me Wink
Re: getCellByPosition() returning a null datavalue [message #1426285 is a reply to message #1426267] Thu, 18 September 2014 14:11 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2495
Registered: July 2012
Senior Member
Maybe because the cells wrap the original cells and the methods that return the correct values are aware of that. Not sure, would need to look into the code myself.

What are you trying to achieve?
Re: getCellByPosition() returning a null datavalue [message #1426290 is a reply to message #1426285] Thu, 18 September 2014 14:20 Go to previous messageGo to next message
Quentin Le Menez is currently offline Quentin Le MenezFriend
Messages: 17
Registered: September 2014
Location: Paris Saclay, France
Junior Member
I am trying to edit merged cells using a method extracted from EditController: editCells and giving the layer.doCommand(new UpdateDataCommand(layer, selectedCell.getColumnPosition(), selectedCell.getRowPosition(), editorValue)) all the selected merged cells.

oh and also an edition through: cellEditor.activateCell(parent, initialCanonicalValue, EditModeEnum.INLINE, editHandler, cell, configRegistry);

for the first one, I may already have all I need, but for the second I think I need the cells for it to work; which I can't seem to get...

ps: the "cell" and "selectedCell" used are both obtained through mouse selection in the table

[Updated on: Thu, 18 September 2014 14:53]

Report message to a moderator

Re: getCellByPosition() returning a null datavalue [message #1426347 is a reply to message #1426290] Thu, 18 September 2014 16:02 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2495
Registered: July 2012
Senior Member
what do you mean with "merged cells"? spanned cells? than just execute the EditCellCommand. If you mean multi editing you need to execute the EditSelectionCommand. There should be no need to operate on the cells itself.
Re: getCellByPosition() returning a null datavalue [message #1426879 is a reply to message #1426267] Fri, 19 September 2014 11:05 Go to previous message
Quentin Le Menez is currently offline Quentin Le MenezFriend
Messages: 17
Registered: September 2014
Location: Paris Saclay, France
Junior Member
I think I see what I was doing wrong... Thanks for the help !
Previous Topic:Use multi cell painters on a single cell
Next Topic:Make NaTable row non editable based on particular cell value.
Goto Forum:
  


Current Time: Sat Sep 23 23:51:13 GMT 2017

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

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