Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-ui-dev] Fwd: Generification of the JFace TreeViewer

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I'm currently adding generics support to the JFace TreeViewer, but I'm
running in to some problems and I thought you could help me with that.

Unlike the other Viewers, with flat data structures like the
TableViewer, the TreeViewer has to handle (of course) tree like data
structures.

For the viewers in general we decided to have two type parameters for
every viewer. E for an single element the viewer should display and I
for the input you set with the setInput method. For example you are
able to type a TableViewer with TrableViewer<Person,MyOwnListOfPersons>
This type parameters are also applicable to the TreeViewer, but the
tree structure and the internal implementation of the viewer does not
allow a stronger typing of method parameters like it is done in the
other viewers.

For example the method isExpandable(Object elementOrTreePath) in the
AbstractTreeViewer class. This method handles elements (typed as E),
the input (typed as I) and additional to that a TreePath(typed as
TreePath) for the ITreePathContentProvider. The handling for the
different types are managed at runtime. Also this works fine with
generics, the problem is the call of the getFilteredChildren(I parent)
method from the superclass(StructuredViewer). The getFilteredChildren
method is not only called with as I typed parameters, but also with E
and TreePath typed parameters. The signature of the
getFilteredChildren method is correct for all viewers, except for
TreeViewer.

After consulting my mentor Lars Vogel, my first try was to override
the getFilteredChildren method in the
AbstractTreeViewer class with the signature getFilteredChildren(Object
parent), which called the getRawChildren method of the
AbstractTreeViewer. But to still execute the filters which could not
be accessed from the AbstractTreeViewer, I had to outsource the filter
functionality to another protected method (internalFilter) which can
be called from the subclass.

You can see my currently running changes at
https://git.eclipse.org/r/#/c/15647/

So what do you think? Is this a acceptable solution for the issue?

Regards,
Hendrik





-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQEcBAEBAgAGBQJSE3H4AAoJECjZOs4dIxis+4kH/3IHsWf9tPpjouEIDR61A7Lk
jbJd0fCMGIKhyI42RhZdGYxN1bwAQ+Ifjp4P+fDViqlWQ6OPaJoVsGQoBlNV9hvJ
xrSIIXAvXdwLuqnZEXq2pMSxklME6VAyO5U2dDNOwVmTV8+O4SGbiiVfA9cWmlfw
Hv31ePQQiBeaZFogYwL12RbBoKJVhXE98HPdWEh0nodVwM2cO3MyZrtiOaM0coDz
oS5IDY36l26uA87CwH2jhoNxmjLAC+OQ+PQBTvjzSWJfCMEz5DDLJVsYZaoUE1+V
Z07TYOHxyObJ/U5QLsVhfj/IzAdSHn7mHD82tjVlGLFKMrKc/R7b2P1+3spIV6s=
=pypY
-----END PGP SIGNATURE-----


Back to the top