|[ZEST] NPEs due to invalid GraphViewer selections [message #720459]
||Tue, 30 August 2011 16:00
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
Powered by FUDForum
. Page generated in 0.01293 seconds