Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » object is not an instance of declaring class Problem in example _6042_TreeStructureGridExample
object is not an instance of declaring class Problem in example _6042_TreeStructureGridExample [message #1693600] Sun, 26 April 2015 11:27 Go to next message
cenk Mising name is currently offline cenk Mising nameFriend
Messages: 159
Registered: July 2009
Senior Member
Hi,

I changed something for testing in _6042_TreeStructureGridExample example application. It is below(Changes indicated with comment "New added for testing something")

 private class PersonWithAddressTreeColumnPropertyAccessor implements IColumnPropertyAccessor {

        private IColumnPropertyAccessor cpa;

        public PersonWithAddressTreeColumnPropertyAccessor(IColumnPropertyAccessor cpa) {
            this.cpa = cpa;
        }

        @Override
        public Object getDataValue(Object rowObject, int columnIndex) {
            if (rowObject instanceof PersonWithAddress) {
                return this.cpa.getDataValue((PersonWithAddress) rowObject, columnIndex);
            }
            //New added for testing something
            else if(rowObject instanceof LastNameGroup){
            	 return this.cpa.getDataValue((LastNameGroup) rowObject, columnIndex);
            }
          //New added for testing something
            else if(rowObject instanceof FirstNameGroup){
           	 return this.cpa.getDataValue((FirstNameGroup) rowObject, columnIndex);
          
            } else if (columnIndex == 0) {
                return rowObject;
            }
            return null;
        }


And there is only one column

 String[] propertyNames = { "lastName"};
//        		"firstName" , "gender",                "married", "birthday" };



when I run application the error occured. The error is below

java.lang.RuntimeException: java.lang.IllegalArgumentException: object is not an instance of declaring class
	at mywork.ReflectiveColumnPropertyAccessor.getDataValue(ReflectiveColumnPropertyAccessor.java:56)
	at mywork._6042_TreeStructureGridExample$PersonWithAddressTreeColumnPropertyAccessor.getDataValue(_6042_TreeStructureGridExample.java:375)
	at org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsDataProvider.getDataValue(GlazedListsDataProvider.java:100)
	at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getDataValue(DataLayer.java:143)
	at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getDataValueByPosition(DataLayer.java:424)
	at org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform.getDataValueByPosition(AbstractLayerTransform.java:372)
	at org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform.getDataValueByPosition(AbstractIndexLayerTransform.java:381)
	at org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform.getDataValueByPosition(AbstractLayerTransform.java:372)
	at org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform.getDataValueByPosition(AbstractLayerTransform.java:372)
	at org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform.getDataValueByPosition(AbstractLayerTransform.java:372)
	at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.getDataValueByPosition(CompositeLayer.java:600)
	at org.eclipse.nebula.widgets.nattable.layer.cell.AbstractLayerCell.getDataValue(AbstractLayerCell.java:64)
	at org.eclipse.nebula.widgets.nattable.layer.cell.CellDisplayConversionUtils.convertDataType(CellDisplayConversionUtils.java:21)
	at org.eclipse.nebula.widgets.nattable.painter.cell.AbstractTextPainter.convertDataType(AbstractTextPainter.java:175)
	at org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter.paintCell(TextPainter.java:159)
	at org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper.paintCell(CellPainterWrapper.java:73)
	at org.eclipse.nebula.widgets.nattable.painter.cell.decorator.LineBorderDecorator.paintCell(LineBorderDecorator.java:84)
	at org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator.paintCell(CellPainterDecorator.java:290)
	at org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper.paintCell(CellPainterWrapper.java:73)
	at org.eclipse.nebula.widgets.nattable.tree.painter.IndentedTreeImagePainter.paintCell(IndentedTreeImagePainter.java:303)
	at org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper.paintCell(CellPainterWrapper.java:73)
	at org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator.paintCell(PaddingDecorator.java:205)
	at org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper.paintCell(CellPainterWrapper.java:73)
	at org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter.paintCell(BackgroundPainter.java:53)
	at org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter.paintCell(CellLayerPainter.java:230)
	at org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter.paintLayer(CellLayerPainter.java:88)
	at org.eclipse.nebula.widgets.nattable.painter.layer.GridLineCellLayerPainter.paintLayer(GridLineCellLayerPainter.java:116)
	at org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter.paintLayer(SelectionLayerPainter.java:109)
	at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer$CompositeLayerPainter.paintLayer(CompositeLayer.java:993)
	at org.eclipse.nebula.widgets.nattable.painter.layer.NatLayerPainter.paintLayer(NatLayerPainter.java:47)
	at org.eclipse.nebula.widgets.nattable.NatTable.paintNatTable(NatTable.java:453)
	at org.eclipse.nebula.widgets.nattable.NatTable.paintControl(NatTable.java:448)
	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:5023)
	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.nebula.widgets.nattable.examples.runner.StandaloneNatExampleRunner.run(StandaloneNatExampleRunner.java:43)
	at org.eclipse.nebula.widgets.nattable.examples.runner.StandaloneNatExampleRunner.run(StandaloneNatExampleRunner.java:23)
	at mywork._6042_TreeStructureGridExample.main(_6042_TreeStructureGridExample.java:95)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
	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 mywork.ReflectiveColumnPropertyAccessor.getDataValue(ReflectiveColumnPropertyAccessor.java:53)
	... 47 more
Error while painting table: java.lang.IllegalArgumentException: object is not an instance of declaring class



What is the problem?

Re: object is not an instance of declaring class Problem in example _6042_TreeStructureGridExample [message #1693601 is a reply to message #1693600] Sun, 26 April 2015 11:39 Go to previous messageGo to next message
Arye Shemesh is currently offline Arye ShemeshFriend
Messages: 37
Registered: November 2012
Member
The ReflectiveColumnPropertyAccessor uses reflection to access the data. It initializes access methods once, for the first input.
If the other inputs are from another classes, the access methods will fail, as they refer to another class.

You need to keep an instance of ReflectiveColumnPropertyAccessor for each class.
Re: object is not an instance of declaring class Problem in example _6042_TreeStructureGridExample [message #1693604 is a reply to message #1693601] Sun, 26 April 2015 13:26 Go to previous messageGo to next message
cenk Mising name is currently offline cenk Mising nameFriend
Messages: 159
Registered: July 2009
Senior Member
Thank you for your response
Is there any example code for your mentioned and solutions

Re: object is not an instance of declaring class Problem in example _6042_TreeStructureGridExample [message #1693606 is a reply to message #1693604] Sun, 26 April 2015 14:14 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
You could simply implement a custom IColumnPropertyAccessor instead of using reflection if you need to deal with different classes in one collection.
Re: object is not an instance of declaring class Problem in example _6042_TreeStructureGridExample [message #1693607 is a reply to message #1693606] Sun, 26 April 2015 14:43 Go to previous messageGo to next message
cenk Mising name is currently offline cenk Mising nameFriend
Messages: 159
Registered: July 2009
Senior Member
Ok. I created new ICloumnPropertyAccessor. How can I define to NatTable. In example defined this like below

this.bodyDataProvider =
                    new GlazedListsDataProvider(
                            this.treeList, new PersonWithAddressTreeColumnPropertyAccessor(columnPropertyAccessor));



How can I define second one

I have been using NatTable for two days. So that I cannot understand exactly .

Thankyou
Re: object is not an instance of declaring class Problem in example _6042_TreeStructureGridExample [message #1693610 is a reply to message #1693607] Sun, 26 April 2015 17:54 Go to previous message
cenk Mising name is currently offline cenk Mising nameFriend
Messages: 159
Registered: July 2009
Senior Member
Dear Fauth,

Ok. I understood. I will implement new ICloumnPropertyAccessor.

Thank you
Previous Topic:changed data in nabula nattable(Cell Value changed) or how to effect from database side
Next Topic:Dynamic conditional highlighting
Goto Forum:
  


Current Time: Fri Apr 19 06:32:21 GMT 2024

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

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

Back to the top