Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Getting columnPosition from NatEventData
Getting columnPosition from NatEventData [message #1722038] Tue, 02 February 2016 12:05 Go to next message
Sreeram R is currently offline Sreeram RFriend
Messages: 9
Registered: July 2009
Junior Member
I'm implementing a NatTable with ColumnGroupHeaders and ColumnHeaders. I added a context menu for the ColumnHeaders using IMenuItemProvider implementation. The sample code is as below:

new IMenuItemProvider() {

@Override
public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
menuItem.setText(menuLabel);
menuItem.setImage(GUIHelper.getImage("hide_column")); //$NON-NLS-1$
menuItem.setEnabled(true);

menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int columnPosition = getNatEventData(event).getColumnPosition();
natTable.doCommand(
new ColumnHideCommand(natTable, columnPosition));
}
});
}
};

But, the above line - getNatEventData(event).getColumnPosition() - returns a wrong columnPosition. Say, if I right click on ColumnHeader-23, it returns columnPosition as 6, which I think should be 23. I tried with the example, _5111_ColumnGroupingExample, which returns the correct columnPosition as per column header position.

Is something I'm missing here?
Re: Getting columnPosition from NatEventData [message #1722050 is a reply to message #1722038] Tue, 02 February 2016 13:51 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
First, why are you implementing the column hide menu item yourself? That should be available via PopupMenuBuilder fluent API.

I think your issues depends on your layer stack composition. But it is hard to tell without more information.
Re: Getting columnPosition from NatEventData [message #1722205 is a reply to message #1722050] Wed, 03 February 2016 11:26 Go to previous messageGo to next message
Sreeram R is currently offline Sreeram RFriend
Messages: 9
Registered: July 2009
Junior Member
Thanks...as mentioned above, its a sample code to explain the case. In my case, I need selected column and will be computing the column positions of similar ColumnHeader in different ColumnGroups. So I will be having my own IMenuItemProvider.

The layer structure in my case is as follows:
1. A BodyStackLayer (extends from AbstractLayerTransform) has layers in the order - DataLayer -> ColumnHideShowLayer -> SelectionLayer -> ViewportLayer -> FreezeLayer -> CompositeFreezeLayer
2. Now, BodyStackLayer -> ColumnHeaderLayer -> SortHeaderLayer -> ColumnGroupHeaderLayer -> FilterRowHeaderComposite
3. The above constitutes the body layer with RowHeaderLayer, CornerLayer for the created GridLayer i.e, my GridLayer instance looks like - new GridLayer(BodyStackLayer,FilterRowHeaderComposite,RowHeaderLayer,CornerLayer)

Let me know if I am missing anything here.

Re: Getting columnPosition from NatEventData [message #1722209 is a reply to message #1722205] Wed, 03 February 2016 12:05 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
For me it sounds like an issue regarding the position interpretation. Do you perform the right click on the column group or the column header? IIRC in our examples we have a different header menu for the column groups to avoid such position glitches. But you can also have a look at the _807_SortableFilterableColumnGroupExample under Tutorial Examples -> Integration to check for the issue. That composition sounds more like the one you are trying to achieve.
Re: Getting columnPosition from NatEventData [message #1722520 is a reply to message #1722209] Fri, 05 February 2016 12:21 Go to previous message
Sreeram R is currently offline Sreeram RFriend
Messages: 9
Registered: July 2009
Junior Member
FYI...I figured out that I'm executing TurnViewportOffCommand before my command is executed which results in giving me incorrect column position. Thanks for suggestions Razz
Previous Topic:Exception in NatTable
Next Topic:Selection style on focus gain/loss
Goto Forum:
  


Current Time: Fri Apr 26 10:12:14 GMT 2024

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

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

Back to the top