Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » NatTabel sort failing(NatTabel sort is crashing )
NatTabel sort failing [message #1469186] Tue, 11 November 2014 11:29 Go to next message
Amruta Sardeshmukh is currently offline Amruta SardeshmukhFriend
Messages: 25
Registered: September 2014
Junior Member
I have implemented sort thorough command handler.
The default sort configuration has been appiled.

My NatTabel has mor than 25+rows.

Sorting works for intial 8 rows but after that ,the sort handler crashes :

java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at ca.odell.glazedlists.gui.AbstractTableComparatorChooser.getComparatorsForColumn(AbstractTableComparatorChooser.java:178)
at org.eclipse.nebula.widgets.nattable.extension.glazedlists.NatTableComparatorChooser.sort(NatTableComparatorChooser.java:33)
at org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel.sort(GlazedListsSortModel.java:91)
at org.eclipse.nebula.widgets.nattable.sort.command.SortCommandHandler$1.run(SortCommandHandler.java:43)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.nebula.widgets.nattable.sort.command.SortCommandHandler.doCommand(SortCommandHandler.java:46)
at org.eclipse.nebula.widgets.nattable.sort.command.SortCommandHandler.doCommand(SortCommandHandler.java:1)
at org.eclipse.nebula.widgets.nattable.command.AbstractLayerCommandHandler.doCommand(AbstractLayerCommandHandler.java:19)
at org.eclipse.nebula.widgets.nattable.layer.AbstractLayer.doCommand(AbstractLayer.java:162)
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.doCommand(CompositeLayer.java:132)
at org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer.doCommand(GridLayer.java:178)
at org.eclipse.nebula.widgets.nattable.NatTable.doCommand(NatTable.java:626)
at com.cat.rac.bnu.nattable.TcNatTableMenuItemProvider$5$1.handleEvent(TcNatTableMenuItemProvider.java:195)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
Re: NatTabel sort failing [message #1469200 is a reply to message #1469186] Tue, 11 November 2014 11:41 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Not sure what you are doing, but at position -1 can't be a comparator in any list in Java
Re: NatTabel sort failing [message #1470804 is a reply to message #1469200] Wed, 12 November 2014 16:49 Go to previous messageGo to next message
Amruta Sardeshmukh is currently offline Amruta SardeshmukhFriend
Messages: 25
Registered: September 2014
Junior Member
While analysing the issue observed that in doCommand for SortCommand

[i]final int columnIndex = command.getLayer().getColumnIndexByPosition(command.getColumnPosition());[/i]

columnIndex is coming as -1 for ceartain columns.

I have column grouping as well.Could that be causing some issue.
Re: NatTabel sort failing [message #1470854 is a reply to message #1470804] Wed, 12 November 2014 17:39 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
how are you sorting?
Re: NatTabel sort failing [message #1472121 is a reply to message #1470854] Thu, 13 November 2014 16:11 Go to previous messageGo to next message
Amruta Sardeshmukh is currently offline Amruta SardeshmukhFriend
Messages: 25
Registered: September 2014
Junior Member
I have added default Sort ConfigurationcoverSheetNatTable.addConfiguration(new DefaultSortConfiguration());

Created sortModel
sortModel = new GlazedListsSortModel(getSortedList(), columnPropertyAccessor, configRegistry, columnGroupHeaderLayer);
this.sortHeaderLayer = new SortHeaderLayer(columnGroupHeaderLayer,
sortModel, false)

I am implementing the sort through command ,which is available on column header

public void registerSortCommandHandler(final ISortModel sortModel, final SortHeaderLayer sortHeaderLayer)
{
registerCommandHandler(new SortCommandHandler(sortModel,sortHeaderLayer)
}

Added menu item for sort

public void addMenuItem(final NatTable natTable, final Menu popUpMenu)
{

MenuItem multiEditMenuItem = new MenuItem(popUpMenu, SWT.NONE);
multiEditMenuItem.setText("Sort\t");


multiEditMenuItem.addListener(SWT.Selection, new Listener() {

@Override
public void handleEvent(Event arg0)
{
// natTable.doCommand(new TCNatTablePasteDataCommand("\t", System
// .getProperty("line.separator")));
NatEventData obj = (NatEventData) popUpMenu.getData();
final int colIndex = natTable.getColumnIndexByPosition(obj.getColumnPosition());
natTable.doCommand(new SortColumnCommand(natTable,colIndex,false));

//natTable.refresh();

}
Re: NatTabel sort failing [message #1472196 is a reply to message #1472121] Thu, 13 November 2014 17:33 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
The issue is that you are doing the position - index transformation before executing the command. You need to simply use the position as the transformation is done on command transport
Re: NatTabel sort failing [message #1478033 is a reply to message #1472196] Tue, 18 November 2014 10:16 Go to previous messageGo to next message
Amruta Sardeshmukh is currently offline Amruta SardeshmukhFriend
Messages: 25
Registered: September 2014
Junior Member
Thanks ,for the input,now I modified my code as :

final int colIndex = obj.getColumnPosition();

The crash is getting avoided.I can see sorting working for most of the columns.
Following are issue which I still observe:

1. On applying the sort for particular column through sort command.I
do not see the cell painter(arrow) getting applied on the column header ,instead I see it applied on previous column's header.

2. In my tabel there are column group and on applying the sort on columns which appear after the column group does not show the sort cell painter.
Re: NatTabel sort failing [message #1478091 is a reply to message #1478033] Tue, 18 November 2014 11:28 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Sounds like you registered the painters to the wrong layers or have some issues in your layer compositions.

Please check the various integration examples for verification.
Re: NatTabel sort failing [message #1479649 is a reply to message #1478091] Wed, 19 November 2014 16:08 Go to previous messageGo to next message
Amruta Sardeshmukh is currently offline Amruta SardeshmukhFriend
Messages: 25
Registered: September 2014
Junior Member
Which are the integration examples in the JNLP file
Re: NatTabel sort failing [message #1479740 is a reply to message #1479649] Wed, 19 November 2014 17:46 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Tutorial Examples - > Integration
Re: NatTabel sort failing [message #1480583 is a reply to message #1479740] Thu, 20 November 2014 09:55 Go to previous message
Amruta Sardeshmukh is currently offline Amruta SardeshmukhFriend
Messages: 25
Registered: September 2014
Junior Member
Thank you.
The integration exmaple helped me !


Previous Topic:Running Nattable Example
Next Topic:Using Combo as CellEditor - deselect value
Goto Forum:
  


Current Time: Thu Mar 28 21:12:56 GMT 2024

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

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

Back to the top