Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » getRowPositionByY(y) is not returning correct row position when the table is scrolled down
getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1006658] Fri, 01 February 2013 10:47 Go to next message
karishma Agarwal is currently offline karishma AgarwalFriend
Messages: 28
Registered: June 2011
Junior Member
I have extended the class TreeLayer and implemented the function getConfigLabelsByPosition(int columnPosition, int rowPosition). The implementation of the function getRegionLabelsByXY(int x, int y) I have done as below:

public LabelStack getRegionLabelsByXY(int x, int y) {

int columnPositionByX = getColumnPositionByX(x);
int rowPositionByY = getRowPositionByY(y);
return getConfigLabelsByPosition(columnPositionByX, rowPositionByY);

}

Since it is returning the wrong value in getRowPositionByX() when the table is scrolled down, therefore it is attaching wrong labels to the cell and hence my code breaks. Could you tell me a way out of it.

Thanks,
Karishma.

[Updated on: Fri, 01 February 2013 10:52]

Report message to a moderator

Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1006662 is a reply to message #1006658] Fri, 01 February 2013 11:09 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
getColumnPositionByX and getRowPositionByY are intended to return the column/row by display x/y coordinates. Is the x and y parameter in your call the display coordinate?
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1006675 is a reply to message #1006662] Fri, 01 February 2013 11:57 Go to previous messageGo to next message
karishma Agarwal is currently offline karishma AgarwalFriend
Messages: 28
Registered: June 2011
Junior Member
getRegionLabelsByXY() function is actually getting called by getMouseEventAction() function in IUiBindingRegistry.

private IMouseAction getMouseEventAction(MouseEventTypeEnum mouseEventType, MouseEvent event) {
// TODO: This code can be made more performant by mapping mouse bindings not only to the mouseEventType but
// also to the region that they are interested in. That way, given an area and an event we can narrow down the
// list of mouse bindings that need to be searched. -- Azubuko.Obele

try {

LinkedList<MouseBinding> mouseEventBindings = mouseBindingsMap.get(mouseEventType);

if (mouseEventBindings != null) {

LabelStack regionLabels = natTable.getRegionLabelsByXY(event.x, event.y);

for (MouseBinding mouseBinding : mouseEventBindings) {

if (mouseBinding.getMouseEventMatcher().matches(natTable, event, regionLabels)) {
return mouseBinding.getAction();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1006676 is a reply to message #1006675] Fri, 01 February 2013 12:02 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Ok, then it might be related to your layer composition. Scrolling is handled by the ViewportLayer. Is your TreeLayer on top of the viewport or vice versa?
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1006679 is a reply to message #1006676] Fri, 01 February 2013 12:06 Go to previous messageGo to next message
karishma Agarwal is currently offline karishma AgarwalFriend
Messages: 28
Registered: June 2011
Junior Member
My viewportLayer is on top of TreeLayer . and I have implemented the registerCommandHandlers() of Viewport Layer.

ViewportLayer viewPortLayer = new ViewportLayer(treeLayer){
@Override
protected void registerCommandHandlers() {
registerCommandHandler(new RecalculateScrollBarsCommandHandler(this));
registerCommandHandler(new ScrollSelectionCommandHandler(this));
registerCommandHandler(new ShowCellInViewportCommandHandler(this));
registerCommandHandler(new ShowColumnInViewportCommandHandler(this));
registerCommandHandler(new ShowRowInViewportCommandHandler(this));
}
};
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1006683 is a reply to message #1006679] Fri, 01 February 2013 12:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hm, not quite sure, but are you aware of the difference between position and index in a NatTable? http://eclipse.org/nattable/documentation.php?page=layer

Maybe you need to translate the position to the underlying index by using the LayerUtil to achieve your goal.
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1006768 is a reply to message #1006683] Fri, 01 February 2013 18:19 Go to previous messageGo to next message
karishma Agarwal is currently offline karishma AgarwalFriend
Messages: 28
Registered: June 2011
Junior Member
yes..i am aware of it..Should I use the Layerutil methods in the getRegionLabelsByXY() method?

[Updated on: Fri, 01 February 2013 18:23]

Report message to a moderator

Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1007033 is a reply to message #1006768] Mon, 04 February 2013 07:46 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I have read your previous posts again, and I'm not sure if I understand what you are trying to achieve? Why did you override getRegionLabelsByXY() and getConfigLabelsByPosition() in your specialized TreeLayer? Why did the default implementation not fit your needs? Where do you try to call the method and where is your code breaking regarding those methods.

Sorry, I'm quite confused about your customization and not sure if my comments really help or if you need to do things differently.
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1007047 is a reply to message #1007033] Mon, 04 February 2013 08:58 Go to previous messageGo to next message
karishma Agarwal is currently offline karishma AgarwalFriend
Messages: 28
Registered: June 2011
Junior Member
I have overridden getConfigLabelsByPosition() in my specialized treeLayer because I need more labels to differentiate my cells other than TREE_COLUMN_CELL. In my table,some of the cells have checkboxes and they all show different behaviour in different column Positions.That is why I have overridden getConfigLabelsByPosition() method. Originally when the table is not scrolled, then all the cells are showing correct behaviour regarding their FirstSingleClickBinding because they have got attached with the correct labels. But when the table is scrolled down, and I try to single click on some checkbox, the behaviour changes. The same cell in which the single click Binding event was getting registered earlier before scrolling the table down, now it is not getting registered(After the table is scrolled down). This is because when I single click on the checkbox, the above getMouseEventAction() method is called which in turn calls getRegionLabelsByXY() which is returning wrong rowPosition and columnPosition and hence attaches wrong labels to that particular cell and hence the behaviour change. I hope this will help you in understanding my problem.
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1007049 is a reply to message #1007047] Mon, 04 February 2013 09:11 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Ok, but why don't you use an IConfigLabelAccumulator instead of overriding getConfigLabelsByPosition()
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1007050 is a reply to message #1007049] Mon, 04 February 2013 09:15 Go to previous messageGo to next message
karishma Agarwal is currently offline karishma AgarwalFriend
Messages: 28
Registered: June 2011
Junior Member
What will be the difference if I use IConfigLabelAccumulator?
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1007053 is a reply to message #1007050] Mon, 04 February 2013 09:24 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
As the labels you want to attach are data value based and not based on the layer, the separation of concerns is one big improvement. So if this is the only modification of your special TreeLayer, your TreeLayer isn't needed anymore.

The second thing is that the column and row position that are used to call accumulateConfiLabels() should be related to the layer and not the scroll position. The transition of positions should be done for you. At least this is my current understanding. If it doesn't work I need to have a closer look.
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1007055 is a reply to message #1007053] Mon, 04 February 2013 09:25 Go to previous messageGo to next message
karishma Agarwal is currently offline karishma AgarwalFriend
Messages: 28
Registered: June 2011
Junior Member
OK. I will try this out.

Thanks.
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1007102 is a reply to message #1007055] Mon, 04 February 2013 13:20 Go to previous messageGo to next message
karishma Agarwal is currently offline karishma AgarwalFriend
Messages: 28
Registered: June 2011
Junior Member
I have created labels using IConfigLabelAccumulator. But ultimately when we register any event then getMouseEventAction() is called which calls getRegionLabelsByXY() which does not call accumulateConfigLabels(). So now none of the events are getting registered even when we dont scroll the table.
Re: getRowPositionByY(y) is not returning correct row position when the table is scrolled down [message #1007119 is a reply to message #1007102] Mon, 04 February 2013 14:26 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Seems I missunderstood your requirement. The MouseEventMatcher only checks the region labels and no cell labels. So it gets activated for a click in a region.

I think what you really need is to register a custom MouseEventMatcher. If this one is evaluating the labels or directly evaluates your business logic should be not important. And with this matcher you need to register your custom action. For this have a look at the DefaultEditBindings.

As I don't know what different behaviour for different checkboxes could be, another solution could be to trigger that behaviour within the IDataProvider.
Previous Topic:BlinkLayer - how to redraw cell?
Next Topic:Version 1.0.0 release date?
Goto Forum:
  


Current Time: Fri Apr 19 21:05:03 GMT 2024

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

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

Back to the top