Skip to main content



      Home
Home » Eclipse Projects » NatTable » Getting columnPosition from NatEventData
Getting columnPosition from NatEventData [message #1722038] Tue, 02 February 2016 07:05 Go to next message
Eclipse UserFriend
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 08:51 Go to previous messageGo to next message
Eclipse UserFriend
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 06:26 Go to previous messageGo to next message
Eclipse UserFriend
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 07:05 Go to previous messageGo to next message
Eclipse UserFriend
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 07:21 Go to previous message
Eclipse UserFriend
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: Sat Jun 21 01:05:12 EDT 2025

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

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

Back to the top