eclipse / nebula

Nebula Project
https://eclipse.org/nebula
Eclipse Public License 2.0
84 stars 98 forks source link

Nebula PropertyTable unsort() results in a NPE #460

Closed morgsie closed 2 years ago

morgsie commented 2 years ago

We have used Opal(1.0.9) in our RCP project for years, particularly using the PropertyTable.

As part of an upgrade we have updated Opal to the new Nebula project. I believe we have downloaded that latest, the plugins are timestamped "_1.0.0.202011020719", which I believe is version 2.6.0

When we first started using Opal we found a bug where when calling the unsort() method a NPE would be returned. Laurent fixed this bug for us in February 2018. Upgrading to the latest version of Nebula propertytable has reintroduced this bug.

Steps to recreate, running the following code results in the NPE:

public void createPartControl( Composite parent ) {

table = new PropertyTable( parent, SWT.NONE );
table.unsort();

Error: java.lang.NullPointerException: Cannot invoke "org.eclipse.swt.widgets.Tree.setRedraw(boolean)" because "this.tree" is null at org.eclipse.nebula.widgets.opal.propertytable.PTWidgetTree.refillData(PTWidgetTree.java:169) at org.eclipse.nebula.widgets.opal.propertytable.PropertyTable.unsort(PropertyTable.java:261)

lcaron commented 2 years ago

It seems that there is a problem with the latest release... Can you please try with Nebula 2.5.0 : https://download.eclipse.org/nebula/releases/2.5.0/ ?

morgsie commented 2 years ago

Thank you for your email, really appreciate you getting back to me. I have tried it with the 2.5.0 release today as you suggested but seem to be getting the same error: java.lang.NullPointerException: Cannot invoke "org.eclipse.swt.widgets.Tree.setRedraw(boolean)" because "this.tree" is null at org.eclipse.nebula.widgets.opal.propertytable.PTWidgetTree.refillData(PTWidgetTree.java:169) at org.eclipse.nebula.widgets.opal.propertytable.PropertyTable.unsort(PropertyTable.java:261)

lcaron commented 2 years ago

Ok can you please try with the latest release : https://download.eclipse.org/nebula/snapshot/ ?

morgsie commented 2 years ago

Thanks for getting back to us, Laurent.

I am no longer seeing the NPE. However, the unsort() function appears to be sorting the properties in some random order as they are not appearing in the order in which they are created, which is the behaviour in Opal 1.0.9 and the desired behaviour.

It almost appears as if they are being sorted Z ->A but not quite. We need to categories (and properties) to appear in the order in which they are added to the table - ie not sorted. Thanks so much for your continued assistance!

lcaron commented 2 years ago

Hi

First of all, I forgot to thank you for using Opal since a long time. Can you please try with the latest release ? it should be ok.

morgsie commented 2 years ago

Hi Laurent, Thank you, this latest build does resolve the issue and we are seeing the expected behaviour. Thank you!! I assume this fix will be rolled into your next release, which is scheduled for the 1st July?

lcaron commented 2 years ago

Hi Sorry for my late answer (back from holidays). You're totally wright, this issue will be fixed in the 2.7.0 release. Do you need an intermediate version (v2.6.1) ?

morgsie commented 2 years ago

Hi Laurent, I hope you had a good holiday! We should be fine to wait for the 2.7.0 release at the beginning of July, just good to know that it is coming so that we can plan our testing and release.

Thanks, Mhorag

From: Laurent CARON @.> Sent: 30 May 2022 11:14 To: eclipse/nebula @.> Cc: Mhorag Lane @.>; Author @.> Subject: Re: [eclipse/nebula] Nebula PropertyTable unsort() results in a NPE (Issue #460)

Hi Sorry for my late answer (back from holidays). You're totally wright, this issue will be fixed in the 2.7.0 release. Do you need an intermediate version (v2.6.1) ?

— Reply to this email directly, view it on GitHubhttps://github.com/eclipse/nebula/issues/460#issuecomment-1140970028, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIG7RO7QY2K4MGMKHVBSG5DVMSIGVANCNFSM5UMKM4EA. You are receiving this because you authored the thread.Message ID: @.**@.>>

lcaron commented 2 years ago

Fine for me, thank you for your trust

morgsie commented 2 years ago

Thank you for your support 😊

From: Laurent CARON @.> Sent: 30 May 2022 15:17 To: eclipse/nebula @.> Cc: Mhorag Lane @.>; Author @.> Subject: Re: [eclipse/nebula] Nebula PropertyTable unsort() results in a NPE (Issue #460)

Fine for me, thank you for your trust

— Reply to this email directly, view it on GitHubhttps://github.com/eclipse/nebula/issues/460#issuecomment-1141211816, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIG7RO2JTQD6X6IZG7DOWDTVMTEWTANCNFSM5UMKM4EA. You are receiving this because you authored the thread.Message ID: @.**@.>>

morgsie commented 2 years ago

Hi Laurent, I hope you are well. I have a quick question for you and I hope you are able to help me.

I have a tabfolder with 3 tab items. On one of the tabitems I want to have a treeviewer as well as a PropertyTable. I have tried to do this using a SWT Group as the composite on the tabitem, however, the PropertyTable doesn’t seem to display. I can see the treeviewer and any text fields I add to test but no PropertyTable.

Is this something I can do? Or is there a different composite that I should use? Or can I only use a tabfolder as the composite for a PropertyTable?

I can send you an example of my code if that helps?

Your help is much appreciated. Kind Regards, Mhorag

From: Laurent CARON @.> Sent: 30 May 2022 11:14 To: eclipse/nebula @.> Cc: Mhorag Lane @.>; Author @.> Subject: Re: [eclipse/nebula] Nebula PropertyTable unsort() results in a NPE (Issue #460)

Hi Sorry for my late answer (back from holidays). You're totally wright, this issue will be fixed in the 2.7.0 release. Do you need an intermediate version (v2.6.1) ?

— Reply to this email directly, view it on GitHubhttps://github.com/eclipse/nebula/issues/460#issuecomment-1140970028, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIG7RO7QY2K4MGMKHVBSG5DVMSIGVANCNFSM5UMKM4EA. You are receiving this because you authored the thread.Message ID: @.**@.>>

lcaron commented 2 years ago

Hi Mhorag

I'll be happy to help you, please send me a code sample.

Take care,

Laurent

morgsie commented 2 years ago

Hi Laurent, Thank you so much for your assistance! Please find attached some sample code to show what I am attempting.

Kind regards, Mhorag

From: Laurent CARON @.> Sent: 01 September 2022 18:39 To: eclipse/nebula @.> Cc: Mhorag Lane @.>; Author @.> Subject: Re: [eclipse/nebula] Nebula PropertyTable unsort() results in a NPE (Issue #460)

Hi Mhorag

I'll be happy to help you, please send me a code sample.

Take care,

Laurent

— Reply to this email directly, view it on GitHubhttps://github.com/eclipse/nebula/issues/460#issuecomment-1234584884, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIG7RO63INJFBIFO3Y5BEJLV4DSZRANCNFSM5UMKM4EA. You are receiving this because you authored the thread.Message ID: @.**@.>>

lcaron commented 2 years ago

Hi Mhorag

There is no sample code attached :'(

Laurent

morgsie commented 2 years ago

Hi Laurent, It seems the attached file has not been removed by the email server. I will resend it once I am back home. Apologies for the delay.

Mhorag

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Laurent CARON @.> Sent: Saturday, 3 September 2022, 18:55 To: eclipse/nebula @.> Cc: Mhorag Lane @.>; Author @.> Subject: Re: [eclipse/nebula] Nebula PropertyTable unsort() results in a NPE (Issue #460)

Hi Mhorag

There is no sample code attached :'(

Laurent

— Reply to this email directly, view it on GitHubhttps://github.com/eclipse/nebula/issues/460#issuecomment-1236172361, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIG7RO4YTQAJUU5XD4NJNGDV4OGHNANCNFSM5UMKM4EA. You are receiving this because you authored the thread.Message ID: @.***>

morgsie commented 2 years ago

Hi Laurent, Please see my sample code below. Thank you again for your assistance 😊

import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewerColumn; import org.eclipse.nebula.widgets.opal.propertytable.PTProperty; import org.eclipse.nebula.widgets.opal.propertytable.PropertyTable; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text;

public class PropTableAndTreetabs { Display d; Shell s;

Display d = new Display();
Shell s = new Shell( d );

s.setSize( 600, 600 );
s.setText( "Tab to contain TreeViewer and PropertyTable" );
s.setLayout( new FillLayout() );

TabFolder tf  = new TabFolder( s, SWT.BORDER );

TabItem   ti1 = new TabItem( tf, SWT.NULL );
ti1.setText( "Group - Tree + PropTable" );
GridLayout gridLayout = new GridLayout( 10, false );

//group to contain both treeviewer and PropertyTable
Group  grp        = new Group( tf, SWT.NONE );
grp.setLayout( gridLayout );
//add TreeViewer to group
TreeViewer thisTree = createTreeViewer(grp);
Text       tt       = new Text( grp, 0 );
tt.setText( "before prop table" );
tt.setVisible( true );
//add PropertyTable to group - doesn't display?
PropertyTable thisTable = new PropertyTable( grp, SWT.NONE );
thisTable.addProperty( new PTProperty( "text", "Description", "Description for the description field", "blahblah..." ) ).setCategory( "General" );
thisTable.addProperty( new PTProperty( "text2", "Description2", "Description2 for the description field", "woohoo..." ) ).setCategory( "General" );
thisTable.setVisible( true );
thisTable.refreshValues();

Text tt2 = new Text( grp, 0 );
tt2.setText( "after, where is it??" );
tt2.setVisible( true );
ti1.setControl( grp );

//add PropertyTable directly to the TabItem
TabItem ti2 = new TabItem( tf, SWT.BORDER );
ti2.setText( "PropTable Only" );
PropertyTable thisTable2 = new PropertyTable( tf, SWT.NONE );
thisTable2.addProperty( new PTProperty( "text", "Description", "Description for the description field", "blahblah..." ) ).setCategory( "General" );
thisTable2.addProperty( new PTProperty( "text2", "Description2", "Description2 for the description field", "woohoo..." ) ).setCategory( "General" );
thisTable2.setVisible( true );
ti2.setControl( thisTable2 );

s.open();

while( !s.isDisposed() ) {
  if( !d.readAndDispatch() ) {
    d.sleep();
  }
}
d.dispose();

}

private TreeViewer createTreeViewer(Group grp) { TreeViewer thisTree= new TreeViewer( grp, SWT.BORDER | SWT.FULL_SELECTION ); thisTree.getTree().setLinesVisible( true ); thisTree.getTree().setHeaderVisible( true ); addCol(thisTree, "Col1"); addCol(thisTree, "Col2"); return thisTree; }

private void addCol( TreeViewer thisTree, String colHead ) { TreeViewerColumn column = new TreeViewerColumn( thisTree, SWT.NONE ); column.getColumn().setWidth( 100 ); column.getColumn().setMoveable( true ); column.getColumn().setText( colHead ); }

}

Mhorag

From: Laurent CARON @.> Sent: 03 September 2022 18:55 To: eclipse/nebula @.> Cc: Mhorag Lane @.>; Author @.> Subject: Re: [eclipse/nebula] Nebula PropertyTable unsort() results in a NPE (Issue #460)

Hi Mhorag

There is no sample code attached :'(

Laurent

— Reply to this email directly, view it on GitHubhttps://github.com/eclipse/nebula/issues/460#issuecomment-1236172361, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIG7RO4YTQAJUU5XD4NJNGDV4OGHNANCNFSM5UMKM4EA. You are receiving this because you authored the thread.Message ID: @.***>

lcaron commented 2 years ago

Hi Mhoragh

It is what you want ?

image

If it is the case, here is the source code :

PropTableAndTreetabs.txt

Laurent

morgsie commented 2 years ago

Hi Laurent, That is perfect, I feel quite stupid for missing that! Thank you so much for your help, I really appreciate it.

Kind Regards, Mhorag

From: Laurent CARON @.> Sent: 06 September 2022 17:29 To: eclipse/nebula @.> Cc: Mhorag Lane @.>; Author @.> Subject: Re: [eclipse/nebula] Nebula PropertyTable unsort() results in a NPE (Issue #460)

Hi Mhoragh

It is what you want ?

[image]https://user-images.githubusercontent.com/1170014/188687629-66f41cbd-d90e-468c-bcd0-3c13af07cfc8.png

If it is the case, here is the source code :

PropTableAndTreetabs.txthttps://github.com/eclipse/nebula/files/9498911/PropTableAndTreetabs.txt

Laurent

— Reply to this email directly, view it on GitHubhttps://github.com/eclipse/nebula/issues/460#issuecomment-1238385092, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIG7RO5T7ZETFZX5H6W67VTV45WN7ANCNFSM5UMKM4EA. You are receiving this because you authored the thread.Message ID: @.**@.>>

lcaron commented 2 years ago

I'm happy for being helpful !

Take care

Laurent

morgsie commented 1 year ago

Hi Laurent, Thank you for your email, really appreciate you getting back to me. I have tried it with the 2.5.0 release today as you suggested but seem to be getting the same error: [Graphical user interface, text, application Description automatically generated]

Thanks, Mhorag

From: Laurent CARON @.> Sent: 02 May 2022 21:23 To: eclipse/nebula @.> Cc: Mhorag Lane @.>; Author @.> Subject: Re: [eclipse/nebula] Nebula PropertyTable unsort() results in a NPE (Issue #460)

It seems that there is a problem with the latest release... Can you please try with Nebula 2.5.0 : https://download.eclipse.org/nebula/releases/2.5.0/ ?

— Reply to this email directly, view it on GitHubhttps://github.com/eclipse/nebula/issues/460#issuecomment-1115328736, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIG7ROZOZZIINZSWENPWLXDVIA2T5ANCNFSM5UMKM4EA. You are receiving this because you authored the thread.Message ID: @.**@.>>