Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Populate Table From Database
Populate Table From Database [message #1447959] Sun, 19 October 2014 05:37 Go to next message
Praveen Banthia is currently offline Praveen BanthiaFriend
Messages: 30
Registered: September 2014
Member
IDataProvider bodyDataProvider = new ListDataProvider<OrgDetails>(retrievedData, columnPropertyAccessor);

the retrievedData is poplated only user opens perspective and enters something in search box.

My issue is the nattable throws exception if I do so saying cannot find data.
Re: Populate Table From Database [message #1447993 is a reply to message #1447959] Sun, 19 October 2014 06:58 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
What is the question? NatTable is not responsible for loading data, it only visualizes the data.
Re: Populate Table From Database [message #1448213 is a reply to message #1447959] Sun, 19 October 2014 15:41 Go to previous messageGo to next message
Praveen Banthia is currently offline Praveen BanthiaFriend
Messages: 30
Registered: September 2014
Member
My bad I should have been clearer.

IDataProvider bodyDataProvider = new ListDataProvider<OrgDetails>(retrievedData, columnPropertyAccessor);

The above statement is responsible for population the tables right .
My issue is when that in my program
retrievedData is populated after intialization of the application and in doing so Nattable thorws error a Null Pointer Exception. Is there a way like avoid this I will post snippet as well as error log for clarity.



searchButton = new Button(parent, SWT.PUSH);
searchButton.setText("Search");
searchButton.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {
System.out.println(searchText.getText());
StoreInDatabase sd = new StoreInDatabase();
retrievedData = (List<OrgDetails>)sd.retrieveFromDatabase(searchText.getText());

}
});


IColumnPropertyAccessor<OrgDetails> columnPropertyAccessor = new OrganizationDetailsPropertyAccessor();
IDataProvider bodyDataProvider = new ListDataProvider<OrgDetails>(retrievedData, columnPropertyAccessor);
final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
final SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);

ILayer columnHeaderLayer = new ColumnHeaderLayer(
new DataLayer(createColumnHeaderDataProvider()),
viewportLayer,
selectionLayer);

CompositeLayer compositeLayer = new CompositeLayer(1, 2);
compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, viewportLayer, 0, 1);
NatTable natTable = new NatTable(parent, compositeLayer);

natTable.setLayoutData(
new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1));


java.lang.NullPointerException
at org.eclipse.nebula.widgets.nattable.data.ListDataProvider.getRowCount(ListDataProvider.java:41)
at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getRowCount(DataLayer.java:267)
at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getHeight(DataLayer.java:318)
at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getPreferredHeight(DataLayer.java:323)
at org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform.getPreferredHeight(AbstractIndexLayerTransform.java:258)
at org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform.getPreferredHeight(AbstractLayerTransform.java:251)
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.getChildClientArea(CompositeLayer.java:651)
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.access$3(CompositeLayer.java:642)
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer$1.getClientArea(CompositeLayer.java:610)
at org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer.getClientAreaWidth(ViewportLayer.java:1341)
at org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer.recalculateAvailableWidthAndColumnCount(ViewportLayer.java:740)
at org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer.getWidth(ViewportLayer.java:572)
at org.eclipse.nebula.widgets.nattable.grid.layer.DimensionallyDependentLayer.getWidth(DimensionallyDependentLayer.java:211)
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer$CompositeLayerPainter.paintLayer(CompositeLayer.java:906)
at org.eclipse.nebula.widgets.nattable.painter.layer.NatLayerPainter.paintLayer(NatLayerPainter.java:43)
at org.eclipse.nebula.widgets.nattable.NatTable.paintNatTable(NatTable.java:408)
at org.eclipse.nebula.widgets.nattable.NatTable.paintControl(NatTable.java:403)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:230)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1491)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4667)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5036)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:164)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Error while painting table: null

[Updated on: Sun, 19 October 2014 15:43]

Report message to a moderator

Re: Populate Table From Database [message #1448214 is a reply to message #1447959] Sun, 19 October 2014 15:43 Go to previous messageGo to next message
Praveen Banthia is currently offline Praveen BanthiaFriend
Messages: 30
Registered: September 2014
Member
My bad I should have been clearer.

IDataProvider bodyDataProvider = new ListDataProvider<OrgDetails>(retrievedData, columnPropertyAccessor);

The above statement is responsible for population the tables right .
My issue is when that in my program
retrievedData is populated after intialization of the application and in doing so Nattable thorws error a Null Pointer Exception. Is there a way like avoid this I will post snippet as well as error log for clarity.


CompositeLayer compositeLayer = new CompositeLayer(1, 2);
compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, viewportLayer, 0, 1);
NatTable natTable = new NatTable(parent, compositeLayer);

natTable.setLayoutData(
new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1));
searchButton = new Button(parent, SWT.PUSH);
searchButton.setText("Search");
searchButton.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {
System.out.println(searchText.getText());
StoreInDatabase sd = new StoreInDatabase();
retrievedData = (List<OrgDetails>)sd.retrieveFromDatabase(searchText.getText());

}
});


IColumnPropertyAccessor<OrgDetails> columnPropertyAccessor = new OrganizationDetailsPropertyAccessor();
IDataProvider bodyDataProvider = new ListDataProvider<OrgDetails>(retrievedData, columnPropertyAccessor);
final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
final SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);

ILayer columnHeaderLayer = new ColumnHeaderLayer(
new DataLayer(createColumnHeaderDataProvider()),
viewportLayer,
selectionLayer);




java.lang.NullPointerException
at org.eclipse.nebula.widgets.nattable.data.ListDataProvider.getRowCount(ListDataProvider.java:41)
at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getRowCount(DataLayer.java:267)
at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getHeight(DataLayer.java:318)
at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getPreferredHeight(DataLayer.java:323)
at org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform.getPreferredHeight(AbstractIndexLayerTransform.java:258)
at org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform.getPreferredHeight(AbstractLayerTransform.java:251)
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.getChildClientArea(CompositeLayer.java:651)
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.access$3(CompositeLayer.java:642)
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer$1.getClientArea(CompositeLayer.java:610)
at org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer.getClientAreaWidth(ViewportLayer.java:1341)
at org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer.recalculateAvailableWidthAndColumnCount(ViewportLayer.java:740)
at org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer.getWidth(ViewportLayer.java:572)
at org.eclipse.nebula.widgets.nattable.grid.layer.DimensionallyDependentLayer.getWidth(DimensionallyDependentLayer.java:211)
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer$CompositeLayerPainter.paintLayer(CompositeLayer.java:906)
at org.eclipse.nebula.widgets.nattable.painter.layer.NatLayerPainter.paintLayer(NatLayerPainter.java:43)
at org.eclipse.nebula.widgets.nattable.NatTable.paintNatTable(NatTable.java:408)
at org.eclipse.nebula.widgets.nattable.NatTable.paintControl(NatTable.java:403)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:230)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1491)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4667)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5036)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:164)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Error while painting table: null
Re: Populate Table From Database [message #1448289 is a reply to message #1448214] Sun, 19 October 2014 18:34 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
Well, the issue is that you are not populating data in the retrievedData list, you are replacing the collection. At the point you are setting the list, the reference points to null. How should NatTable notice that you are setting a reference to a collection afterwards?

Typically you should create an empty list and perform a clear() + addAll() when performing a load operation.
Previous Topic:How to become a NatTable Committer
Next Topic:Regular Expression for Nattable Filter
Goto Forum:
  


Current Time: Mon Mar 08 17:11:06 GMT 2021

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

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

Back to the top