Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » [ZEST] NPEs due to invalid GraphViewer selections
[ZEST] NPEs due to invalid GraphViewer selections [message #720459] Tue, 30 August 2011 16:00 Go to next message
Eclipse UserFriend
Originally posted by:

We are using the GraphViewer from GEF 3.6.1 in an Eclipse View (zest
core plugin has version 1.2.0) and observe that we get always
NullPointerExceptions since we have added a context menu to this viewer.
It turned out that the cause of these is that the GraphViewer produces
ISelection values which are not empty (the sequence of elements has a
size > 0), but the elements have null values. But null values are not
acceptable contents for any IStructuredSelection as described in the
corresponding constructors of StructuredSelection. It turned out that
these selection values are produced by quering the data property of the
GraphNode contents of the viewer. But looking at the GraphNode
description there is nothing mentioned that the data property must have
a well-defined value. In contrast, several constructors exist, that
implicitly set the data value to null.

IMO there are two choices to fix this:

1) The GraphViewer should document the relation between selection and
data, in this case it seems that user code can never legally construct
GraphNode objects with null data.

2) The GraphViewer takes care when constructing the selection values
within AbstractStructuredGraphViewer#getSelectionFromWidget() to not add
null data values to the complete selection.

There is a worse problem with GraphConnection: In this case there exists
only a single constructor which does implicitly set the data property of
the GraphItem to null. In this case I would strongly recommend to
provide a further constructors that allows setting the data as well.

As a workaround for this problem we currently have changed our code and
always set a unique data value per GraphNode and per GraphConnection.

Thanks & Greetings from Bremen

Daniel Krügler
Re: [ZEST] NPEs due to invalid GraphViewer selections [message #720732 is a reply to message #720459] Wed, 31 August 2011 07:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by:

On 2011-08-30 18:00, Daniel Krügler wrote:
> We are using the GraphViewer from GEF 3.6.1 in an Eclipse View (zest
> core plugin has version 1.2.0) and observe that we get always
> NullPointerExceptions since we have added a context menu to this viewer.
> It turned out that the cause of these is that the GraphViewer produces
> ISelection values which are not empty (the sequence of elements has a
> size > 0), but the elements have null values. But null values are not
> acceptable contents for any IStructuredSelection as described in the
> corresponding constructors of StructuredSelection.

Let me emphasize that the NPEs don't appear in our code and we cannot
fix the problem by checking the contents of the ISelection objects
produced by the viewer ourselves. The NPEs do occur deep within the
Eclipse object-contribution handler code that is invoked during the
handling of the menu contributions of the aforementioned context menu.
Therefore this is a contract violation by the GraphViewer which causes
the problem.

- Daniel Krügler
Re: [ZEST] NPEs due to invalid GraphViewer selections [message #721281 is a reply to message #720732] Thu, 01 September 2011 10:28 Go to previous messageGo to next message
Fabian Steeg is currently offline Fabian SteegFriend
Messages: 72
Registered: July 2009
Member
Thanks for the detailed report! Could you file it as a bug, ideally with a snippet or test showing the behavior, at https://bugs.eclipse.org/bugs/enter_bug.cgi?product=GEF&component=Zest
Re: [ZEST] NPEs due to invalid GraphViewer selections [message #721291 is a reply to message #721281] Thu, 01 September 2011 11:03 Go to previous message
Eclipse UserFriend
Originally posted by:

On 2011-09-01 12:28, Fabian Steeg wrote:
> Thanks for the detailed report! Could you file it as a bug, ideally with
> a snippet or test showing the behavior, at
> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=GEF&component=Zest

For those interested in this bug, see

https://bugs.eclipse.org/bugs/show_bug.cgi?id=356449

Thanks & Greetings from Bremen,

Daniel Krügler
Previous Topic:Adding a Ctrl-i keystroke
Next Topic:moving child from one container to another
Goto Forum:
  


Current Time: Fri Dec 19 10:15:46 GMT 2014

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

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