Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Re: pb building TreeView
Re: pb building TreeView [message #15382] Fri, 25 April 2003 10:20 Go to next message
Eclipse UserFriend
Originally posted by: knut_radloff.oti.com

Does getChildNodes return null when there are no more children? You can set an exception breakpoint in the debugger and find
out.where the exception is occurring.

Knut

PS: Please continue the thread on eclipse.platform, eclipse.tools should no longer be used and will be made read-only soon.

"anthony saucet" <anthony.saucet@freesbee.fr> wrote in message news:b8bbcv$u1r$1@rogue.oti.com...
> I'm trying to build a TreeView in my perspective to have a look on a DOM
> tree built in memory.
> I've implemented the TreeView with new TreeViewer, called
> setContentProvider() and setLabelProvider(). setInput() gets the
> rootElement of my DOM tree. Then in class contentProvider, the tree is
> being built by getChildren(), and everything seems ok.
> here's the code to get the children:
>
> public Object[] getChildren(Object element) {
> Object elnts[]=new Object[20];
> int i = 0;
> int j=((Element)element).getChildNodes().getLength();
>
> for(Node child = ((Element)element).getFirstChild(); i<j;
> ((Element)element).getNextSibling()){
> elnts[i]=((Element)element).getChildNodes().item(i);
> i++;
> }
> return elnts;
> }
>
> I don't really know what happens BUT when it arrives at the end, when no
> more child or items, it tries to continue and to create the tree and the
> following message appears:
> "Unable to create part: Tree" from
> eclipse.core.internal.runtime.InternalPlatform
> and the exception: "nullPointerException".
>
> Does anybody have an idea of what I need to do, or what I missed ?
> many thx
>
Re: pb building TreeView [message #15516 is a reply to message #15382] Fri, 25 April 2003 11:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: anthony.saucet.freesbee.fr

getChildNodes() is not null BUT getChildNodes().getLength() = 0 !!!
I've printed out what happens in class contentProvider:

getChildNodes: !null
j: 0 /* getChildNodes().getLength() */
contentPovider getChildren end /* end of method getChildren() */
hasChild /* call method hasChild */
contentPovider getChildren /* calls method getChildren() */

and when tries j = getChildNodes().getLength(), stops here and after lot
of things I didn't catch, exception.
anthony


Knut Radloff wrote:

> Does getChildNodes return null when there are no more children? You can set
an exception breakpoint in the debugger and find
> out.where the exception is occurring.

> Knut

> PS: Please continue the thread on eclipse.platform, eclipse.tools should no
longer be used and will be made read-only soon.

> "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
news:b8bbcv$u1r$1@rogue.oti.com...
> > I'm trying to build a TreeView in my perspective to have a look on a DOM
> > tree built in memory.
> > I've implemented the TreeView with new TreeViewer, called
> > setContentProvider() and setLabelProvider(). setInput() gets the
> > rootElement of my DOM tree. Then in class contentProvider, the tree is
> > being built by getChildren(), and everything seems ok.
> > here's the code to get the children:
> >
> > public Object[] getChildren(Object element) {
> > Object elnts[]=new Object[20];
> > int i = 0;
> > int j=((Element)element).getChildNodes().getLength();
> >
> > for(Node child = ((Element)element).getFirstChild(); i<j;
> > ((Element)element).getNextSibling()){
> > elnts[i]=((Element)element).getChildNodes().item(i);
> > i++;
> > }
> > return elnts;
> > }
> >
> > I don't really know what happens BUT when it arrives at the end, when no
> > more child or items, it tries to continue and to create the tree and the
> > following message appears:
> > "Unable to create part: Tree" from
> > eclipse.core.internal.runtime.InternalPlatform
> > and the exception: "nullPointerException".
> >
> > Does anybody have an idea of what I need to do, or what I missed ?
> > many thx
> >
Re: pb building TreeView [message #15610 is a reply to message #15516] Fri, 25 April 2003 13:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: knut_radloff.oti.com

I just noticed that you initialize your children array (elnts) to a fixed size. The array you return must only have enough slots for
all the children and no extra null slots. That's probably what's causing the exception.
You need to size it to getChildNodes().getLength(). If you have no children an empty array will be returned.

Knut
"anthony saucet" <anthony.saucet@freesbee.fr> wrote in message news:b8bjer$6na$1@rogue.oti.com...
> getChildNodes() is not null BUT getChildNodes().getLength() = 0 !!!
> I've printed out what happens in class contentProvider:
>
> getChildNodes: !null
> j: 0 /* getChildNodes().getLength() */
> contentPovider getChildren end /* end of method getChildren() */
> hasChild /* call method hasChild */
> contentPovider getChildren /* calls method getChildren() */
>
> and when tries j = getChildNodes().getLength(), stops here and after lot
> of things I didn't catch, exception.
> anthony
>
>
> Knut Radloff wrote:
>
> > Does getChildNodes return null when there are no more children? You can set
> an exception breakpoint in the debugger and find
> > out.where the exception is occurring.
>
> > Knut
>
> > PS: Please continue the thread on eclipse.platform, eclipse.tools should no
> longer be used and will be made read-only soon.
>
> > "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> news:b8bbcv$u1r$1@rogue.oti.com...
> > > I'm trying to build a TreeView in my perspective to have a look on a DOM
> > > tree built in memory.
> > > I've implemented the TreeView with new TreeViewer, called
> > > setContentProvider() and setLabelProvider(). setInput() gets the
> > > rootElement of my DOM tree. Then in class contentProvider, the tree is
> > > being built by getChildren(), and everything seems ok.
> > > here's the code to get the children:
> > >
> > > public Object[] getChildren(Object element) {
> > > Object elnts[]=new Object[20];
> > > int i = 0;
> > > int j=((Element)element).getChildNodes().getLength();
> > >
> > > for(Node child = ((Element)element).getFirstChild(); i<j;
> > > ((Element)element).getNextSibling()){
> > > elnts[i]=((Element)element).getChildNodes().item(i);
> > > i++;
> > > }
> > > return elnts;
> > > }
> > >
> > > I don't really know what happens BUT when it arrives at the end, when no
> > > more child or items, it tries to continue and to create the tree and the
> > > following message appears:
> > > "Unable to create part: Tree" from
> > > eclipse.core.internal.runtime.InternalPlatform
> > > and the exception: "nullPointerException".
> > >
> > > Does anybody have an idea of what I need to do, or what I missed ?
> > > many thx
> > >
>
>
>
>
>
Re: pb building TreeView [message #15642 is a reply to message #15610] Fri, 25 April 2003 13:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: knut_radloff.oti.com

Oops, I just ignored my own advice and crossposted to the deprecated eclipse.tools newsgroup.

"Knut Radloff" <knut_radloff@oti.com> wrote in message news:b8bq00$cob$1@rogue.oti.com...
> I just noticed that you initialize your children array (elnts) to a fixed size. The array you return must only have enough slots
for
> all the children and no extra null slots. That's probably what's causing the exception.
> You need to size it to getChildNodes().getLength(). If you have no children an empty array will be returned.
>
> Knut
> "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message news:b8bjer$6na$1@rogue.oti.com...
> > getChildNodes() is not null BUT getChildNodes().getLength() = 0 !!!
> > I've printed out what happens in class contentProvider:
> >
> > getChildNodes: !null
> > j: 0 /* getChildNodes().getLength() */
> > contentPovider getChildren end /* end of method getChildren() */
> > hasChild /* call method hasChild */
> > contentPovider getChildren /* calls method getChildren() */
> >
> > and when tries j = getChildNodes().getLength(), stops here and after lot
> > of things I didn't catch, exception.
> > anthony
> >
> >
> > Knut Radloff wrote:
> >
> > > Does getChildNodes return null when there are no more children? You can set
> > an exception breakpoint in the debugger and find
> > > out.where the exception is occurring.
> >
> > > Knut
> >
> > > PS: Please continue the thread on eclipse.platform, eclipse.tools should no
> > longer be used and will be made read-only soon.
> >
> > > "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> > news:b8bbcv$u1r$1@rogue.oti.com...
> > > > I'm trying to build a TreeView in my perspective to have a look on a DOM
> > > > tree built in memory.
> > > > I've implemented the TreeView with new TreeViewer, called
> > > > setContentProvider() and setLabelProvider(). setInput() gets the
> > > > rootElement of my DOM tree. Then in class contentProvider, the tree is
> > > > being built by getChildren(), and everything seems ok.
> > > > here's the code to get the children:
> > > >
> > > > public Object[] getChildren(Object element) {
> > > > Object elnts[]=new Object[20];
> > > > int i = 0;
> > > > int j=((Element)element).getChildNodes().getLength();
> > > >
> > > > for(Node child = ((Element)element).getFirstChild(); i<j;
> > > > ((Element)element).getNextSibling()){
> > > > elnts[i]=((Element)element).getChildNodes().item(i);
> > > > i++;
> > > > }
> > > > return elnts;
> > > > }
> > > >
> > > > I don't really know what happens BUT when it arrives at the end, when no
> > > > more child or items, it tries to continue and to create the tree and the
> > > > following message appears:
> > > > "Unable to create part: Tree" from
> > > > eclipse.core.internal.runtime.InternalPlatform
> > > > and the exception: "nullPointerException".
> > > >
> > > > Does anybody have an idea of what I need to do, or what I missed ?
> > > > many thx
> > > >
> >
> >
> >
> >
> >
>
>
Re: pb building TreeView [message #15672 is a reply to message #15516] Fri, 25 April 2003 13:10 Go to previous messageGo to next message
Eclipse UserFriend
Antony, The problem u are encountering might be due to the fact that u are
using an array that has no elements. Use a list and convert it to a array to
return an array of objects.

HTP

"anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
news:b8bjer$6na$1@rogue.oti.com...
> getChildNodes() is not null BUT getChildNodes().getLength() = 0 !!!
> I've printed out what happens in class contentProvider:
>
> getChildNodes: !null
> j: 0 /* getChildNodes().getLength() */
> contentPovider getChildren end /* end of method getChildren() */
> hasChild /* call method hasChild */
> contentPovider getChildren /* calls method getChildren() */
>
> and when tries j = getChildNodes().getLength(), stops here and after lot
> of things I didn't catch, exception.
> anthony
>
>
> Knut Radloff wrote:
>
> > Does getChildNodes return null when there are no more children? You can
set
> an exception breakpoint in the debugger and find
> > out.where the exception is occurring.
>
> > Knut
>
> > PS: Please continue the thread on eclipse.platform, eclipse.tools should
no
> longer be used and will be made read-only soon.
>
> > "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> news:b8bbcv$u1r$1@rogue.oti.com...
> > > I'm trying to build a TreeView in my perspective to have a look on a
DOM
> > > tree built in memory.
> > > I've implemented the TreeView with new TreeViewer, called
> > > setContentProvider() and setLabelProvider(). setInput() gets the
> > > rootElement of my DOM tree. Then in class contentProvider, the tree is
> > > being built by getChildren(), and everything seems ok.
> > > here's the code to get the children:
> > >
> > > public Object[] getChildren(Object element) {
> > > Object elnts[]=new Object[20];
> > > int i = 0;
> > > int j=((Element)element).getChildNodes().getLength();
> > >
> > > for(Node child = ((Element)element).getFirstChild(); i<j;
> > > ((Element)element).getNextSibling()){
> > > elnts[i]=((Element)element).getChildNodes().item(i);
> > > i++;
> > > }
> > > return elnts;
> > > }
> > >
> > > I don't really know what happens BUT when it arrives at the end, when
no
> > > more child or items, it tries to continue and to create the tree and
the
> > > following message appears:
> > > "Unable to create part: Tree" from
> > > eclipse.core.internal.runtime.InternalPlatform
> > > and the exception: "nullPointerException".
> > >
> > > Does anybody have an idea of what I need to do, or what I missed ?
> > > many thx
> > >
>
>
>
>
>
Re: pb building TreeView [message #15700 is a reply to message #15672] Fri, 25 April 2003 13:13 Go to previous messageGo to next message
Eclipse UserFriend
I did not see Radloff's reply..

Balaji

"Balaji" <balajik@us.ibm.com> wrote in message
news:b8bq7h$cu5$1@rogue.oti.com...
> Antony, The problem u are encountering might be due to the fact that u are
> using an array that has no elements. Use a list and convert it to a array
to
> return an array of objects.
>
> HTP
>
> "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> news:b8bjer$6na$1@rogue.oti.com...
> > getChildNodes() is not null BUT getChildNodes().getLength() = 0 !!!
> > I've printed out what happens in class contentProvider:
> >
> > getChildNodes: !null
> > j: 0 /* getChildNodes().getLength() */
> > contentPovider getChildren end /* end of method getChildren() */
> > hasChild /* call method hasChild */
> > contentPovider getChildren /* calls method getChildren() */
> >
> > and when tries j = getChildNodes().getLength(), stops here and after lot
> > of things I didn't catch, exception.
> > anthony
> >
> >
> > Knut Radloff wrote:
> >
> > > Does getChildNodes return null when there are no more children? You
can
> set
> > an exception breakpoint in the debugger and find
> > > out.where the exception is occurring.
> >
> > > Knut
> >
> > > PS: Please continue the thread on eclipse.platform, eclipse.tools
should
> no
> > longer be used and will be made read-only soon.
> >
> > > "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> > news:b8bbcv$u1r$1@rogue.oti.com...
> > > > I'm trying to build a TreeView in my perspective to have a look on a
> DOM
> > > > tree built in memory.
> > > > I've implemented the TreeView with new TreeViewer, called
> > > > setContentProvider() and setLabelProvider(). setInput() gets the
> > > > rootElement of my DOM tree. Then in class contentProvider, the tree
is
> > > > being built by getChildren(), and everything seems ok.
> > > > here's the code to get the children:
> > > >
> > > > public Object[] getChildren(Object element) {
> > > > Object elnts[]=new Object[20];
> > > > int i = 0;
> > > > int j=((Element)element).getChildNodes().getLength();
> > > >
> > > > for(Node child = ((Element)element).getFirstChild(); i<j;
> > > > ((Element)element).getNextSibling()){
> > > > elnts[i]=((Element)element).getChildNodes().item(i);
> > > > i++;
> > > > }
> > > > return elnts;
> > > > }
> > > >
> > > > I don't really know what happens BUT when it arrives at the end,
when
> no
> > > > more child or items, it tries to continue and to create the tree and
> the
> > > > following message appears:
> > > > "Unable to create part: Tree" from
> > > > eclipse.core.internal.runtime.InternalPlatform
> > > > and the exception: "nullPointerException".
> > > >
> > > > Does anybody have an idea of what I need to do, or what I missed ?
> > > > many thx
> > > >
> >
> >
> >
> >
> >
>
>
Re: pb building TreeView [message #18550 is a reply to message #15610] Mon, 28 April 2003 05:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: anthony.saucet.freesbee.fr

You were right, now I size the array with getLength() and tree.setInput()
works perfectly. It seems to build a tree in memory and then expand the
tree in the view, BUT without the root element.
What's the trick to display it?

anthony



Knut Radloff wrote:

> I just noticed that you initialize your children array (elnts) to a fixed
size. The array you return must only have enough slots for
> all the children and no extra null slots. That's probably what's causing the
exception.
> You need to size it to getChildNodes().getLength(). If you have no children
an empty array will be returned.

> Knut
> "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
news:b8bjer$6na$1@rogue.oti.com...
> > getChildNodes() is not null BUT getChildNodes().getLength() = 0 !!!
> > I've printed out what happens in class contentProvider:
> >
> > getChildNodes: !null
> > j: 0 /* getChildNodes().getLength() */
> > contentPovider getChildren end /* end of method getChildren() */
> > hasChild /* call method hasChild */
> > contentPovider getChildren /* calls method getChildren() */
> >
> > and when tries j = getChildNodes().getLength(), stops here and after lot
> > of things I didn't catch, exception.
> > anthony
> >
> >
> > Knut Radloff wrote:
> >
> > > Does getChildNodes return null when there are no more children? You can
set
> > an exception breakpoint in the debugger and find
> > > out.where the exception is occurring.
> >
> > > Knut
> >
> > > PS: Please continue the thread on eclipse.platform, eclipse.tools should
no
> > longer be used and will be made read-only soon.
> >
> > > "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> > news:b8bbcv$u1r$1@rogue.oti.com...
> > > > I'm trying to build a TreeView in my perspective to have a look on a
DOM
> > > > tree built in memory.
> > > > I've implemented the TreeView with new TreeViewer, called
> > > > setContentProvider() and setLabelProvider(). setInput() gets the
> > > > rootElement of my DOM tree. Then in class contentProvider, the tree is
> > > > being built by getChildren(), and everything seems ok.
> > > > here's the code to get the children:
> > > >
> > > > public Object[] getChildren(Object element) {
> > > > Object elnts[]=new Object[20];
> > > > int i = 0;
> > > > int j=((Element)element).getChildNodes().getLength();
> > > >
> > > > for(Node child = ((Element)element).getFirstChild(); i<j;
> > > > ((Element)element).getNextSibling()){
> > > > elnts[i]=((Element)element).getChildNodes().item(i);
> > > > i++;
> > > > }
> > > > return elnts;
> > > > }
> > > >
> > > > I don't really know what happens BUT when it arrives at the end, when
no
> > > > more child or items, it tries to continue and to create the tree and
the
> > > > following message appears:
> > > > "Unable to create part: Tree" from
> > > > eclipse.core.internal.runtime.InternalPlatform
> > > > and the exception: "nullPointerException".
> > > >
> > > > Does anybody have an idea of what I need to do, or what I missed ?
> > > > many thx
> > > >
> >
> >
> >
> >
> >
Re: pb building TreeView [message #21883 is a reply to message #18550] Tue, 29 April 2003 07:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: anthony.saucet.freesbee.fr

I've resolved the pb. Instead of getting the root element (ElementImpl) of
my DOM tree, I retrieve the whole document (DocumentImpl), which will be
the root. Then my root element is a child of the doc.


anthony saucet wrote:

> You were right, now I size the array with getLength() and tree.setInput()
> works perfectly. It seems to build a tree in memory and then expand the
> tree in the view, BUT without the root element.
> What's the trick to display it?

> anthony



> Knut Radloff wrote:

> > I just noticed that you initialize your children array (elnts) to a fixed
> size. The array you return must only have enough slots for
> > all the children and no extra null slots. That's probably what's causing
the
> exception.
> > You need to size it to getChildNodes().getLength(). If you have no children
> an empty array will be returned.

> > Knut
> > "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> news:b8bjer$6na$1@rogue.oti.com...
> > > getChildNodes() is not null BUT getChildNodes().getLength() = 0 !!!
> > > I've printed out what happens in class contentProvider:
> > >
> > > getChildNodes: !null
> > > j: 0 /* getChildNodes().getLength() */
> > > contentPovider getChildren end /* end of method getChildren() */
> > > hasChild /* call method hasChild */
> > > contentPovider getChildren /* calls method getChildren() */
> > >
> > > and when tries j = getChildNodes().getLength(), stops here and after lot
> > > of things I didn't catch, exception.
> > > anthony
> > >
> > >
> > > Knut Radloff wrote:
> > >
> > > > Does getChildNodes return null when there are no more children? You can
> set
> > > an exception breakpoint in the debugger and find
> > > > out.where the exception is occurring.
> > >
> > > > Knut
> > >
> > > > PS: Please continue the thread on eclipse.platform, eclipse.tools
should
> no
> > > longer be used and will be made read-only soon.
> > >
> > > > "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> > > news:b8bbcv$u1r$1@rogue.oti.com...
> > > > > I'm trying to build a TreeView in my perspective to have a look on a
> DOM
> > > > > tree built in memory.
> > > > > I've implemented the TreeView with new TreeViewer, called
> > > > > setContentProvider() and setLabelProvider(). setInput() gets the
> > > > > rootElement of my DOM tree. Then in class contentProvider, the tree
is
> > > > > being built by getChildren(), and everything seems ok.
> > > > > here's the code to get the children:
> > > > >
> > > > > public Object[] getChildren(Object element) {
> > > > > Object elnts[]=new Object[20];
> > > > > int i = 0;
> > > > > int j=((Element)element).getChildNodes().getLength();
> > > > >
> > > > > for(Node child = ((Element)element).getFirstChild(); i<j;
> > > > > ((Element)element).getNextSibling()){
> > > > > elnts[i]=((Element)element).getChildNodes().item(i);
> > > > > i++;
> > > > > }
> > > > > return elnts;
> > > > > }
> > > > >
> > > > > I don't really know what happens BUT when it arrives at the end, when
> no
> > > > > more child or items, it tries to continue and to create the tree and
> the
> > > > > following message appears:
> > > > > "Unable to create part: Tree" from
> > > > > eclipse.core.internal.runtime.InternalPlatform
> > > > > and the exception: "nullPointerException".
> > > > >
> > > > > Does anybody have an idea of what I need to do, or what I missed ?
> > > > > many thx
> > > > >
> > >
> > >
> > >
> > >
> > >
Re: pb building TreeView [message #27520 is a reply to message #21883] Mon, 05 May 2003 07:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: anthony.saucet.freesbee.fr

When I was building the tree in memory, everything was ok, I followed your
advices.
But now I build it in a class and I have a stange pb.
I build my DOM tree in memory with the root element from my DTD. I
retrieve it (No problem.) and try to display it in the the treeView (pb).
I got an inputChanged where new_input is null. And I don't know why!
'cause I only have the rootElement in the document.
Messages I got:

ContentProvider-inputChanged // launching of the view
ContentProvider-inputChanged old=null
tree view // setContentProvider
tree view // setLabelProvider
TREEbuilder-getDoc[MASTER103: null] //gets the rootElement
TREEbuilder-getDoc[MASTER103: null]
ContentProvider-inputChanged
ContentProvider-inputChanged old=null
ContentProvider-inputChanged new=null

Do you have any idea ?
thanks, anthony


anthony saucet wrote:

> I've resolved the pb. Instead of getting the root element (ElementImpl) of
> my DOM tree, I retrieve the whole document (DocumentImpl), which will be
> the root. Then my root element is a child of the doc.


> anthony saucet wrote:

> > You were right, now I size the array with getLength() and tree.setInput()
> > works perfectly. It seems to build a tree in memory and then expand the
> > tree in the view, BUT without the root element.
> > What's the trick to display it?

> > anthony



> > Knut Radloff wrote:

> > > I just noticed that you initialize your children array (elnts) to a fixed
> > size. The array you return must only have enough slots for
> > > all the children and no extra null slots. That's probably what's causing
> the
> > exception.
> > > You need to size it to getChildNodes().getLength(). If you have no
children
> > an empty array will be returned.

> > > Knut
> > > "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> > news:b8bjer$6na$1@rogue.oti.com...
> > > > getChildNodes() is not null BUT getChildNodes().getLength() = 0 !!!
> > > > I've printed out what happens in class contentProvider:
> > > >
> > > > getChildNodes: !null
> > > > j: 0 /* getChildNodes().getLength() */
> > > > contentPovider getChildren end /* end of method getChildren() */
> > > > hasChild /* call method hasChild */
> > > > contentPovider getChildren /* calls method getChildren() */
> > > >
> > > > and when tries j = getChildNodes().getLength(), stops here and after
lot
> > > > of things I didn't catch, exception.
> > > > anthony
> > > >
> > > >
> > > > Knut Radloff wrote:
> > > >
> > > > > Does getChildNodes return null when there are no more children? You
can
> > set
> > > > an exception breakpoint in the debugger and find
> > > > > out.where the exception is occurring.
> > > >
> > > > > Knut
> > > >
> > > > > PS: Please continue the thread on eclipse.platform, eclipse.tools
> should
> > no
> > > > longer be used and will be made read-only soon.
> > > >
> > > > > "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> > > > news:b8bbcv$u1r$1@rogue.oti.com...
> > > > > > I'm trying to build a TreeView in my perspective to have a look on
a
> > DOM
> > > > > > tree built in memory.
> > > > > > I've implemented the TreeView with new TreeViewer, called
> > > > > > setContentProvider() and setLabelProvider(). setInput() gets the
> > > > > > rootElement of my DOM tree. Then in class contentProvider, the tree
> is
> > > > > > being built by getChildren(), and everything seems ok.
> > > > > > here's the code to get the children:
> > > > > >
> > > > > > public Object[] getChildren(Object element) {
> > > > > > Object elnts[]=new Object[20];
> > > > > > int i = 0;
> > > > > > int j=((Element)element).getChildNodes().getLength();
> > > > > >
> > > > > > for(Node child = ((Element)element).getFirstChild(); i<j;
> > > > > > ((Element)element).getNextSibling()){
> > > > > > elnts[i]=((Element)element).getChildNodes().item(i);
> > > > > > i++;
> > > > > > }
> > > > > > return elnts;
> > > > > > }
> > > > > >
> > > > > > I don't really know what happens BUT when it arrives at the end,
when
> > no
> > > > > > more child or items, it tries to continue and to create the tree
and
> > the
> > > > > > following message appears:
> > > > > > "Unable to create part: Tree" from
> > > > > > eclipse.core.internal.runtime.InternalPlatform
> > > > > > and the exception: "nullPointerException".
> > > > > >
> > > > > > Does anybody have an idea of what I need to do, or what I missed ?
> > > > > > many thx
> > > > > >
> > > >
> > > >
> > > >
> > > >
> > > >
Re: pb building TreeView [message #28578 is a reply to message #27520] Wed, 07 May 2003 06:40 Go to previous message
Eclipse UserFriend
Originally posted by: anthony.saucet.freesbee.fr

In fact I think I have something working wrong. I don't know if it's my pc
or eclipse (or the 'Run' mode), but sometimes its behaviour is very
strange.
Now, everything is almost ok, but without modifying anything, the layout
has changed !
thx anyway for your help
anthony



anthony saucet wrote:

> When I was building the tree in memory, everything was ok, I followed your
> advices.
> But now I build it in a class and I have a stange pb.
> I build my DOM tree in memory with the root element from my DTD. I
> retrieve it (No problem.) and try to display it in the the treeView (pb).
> I got an inputChanged where new_input is null. And I don't know why!
> 'cause I only have the rootElement in the document.
> Messages I got:

> ContentProvider-inputChanged // launching of the view
> ContentProvider-inputChanged old=null
> tree view // setContentProvider
> tree view // setLabelProvider
> TREEbuilder-getDoc[MASTER103: null] //gets the rootElement
> TREEbuilder-getDoc[MASTER103: null]
> ContentProvider-inputChanged
> ContentProvider-inputChanged old=null
> ContentProvider-inputChanged new=null

> Do you have any idea ?
> thanks, anthony


> anthony saucet wrote:

> > I've resolved the pb. Instead of getting the root element (ElementImpl) of
> > my DOM tree, I retrieve the whole document (DocumentImpl), which will be
> > the root. Then my root element is a child of the doc.


> > anthony saucet wrote:

> > > You were right, now I size the array with getLength() and tree.setInput()
> > > works perfectly. It seems to build a tree in memory and then expand the
> > > tree in the view, BUT without the root element.
> > > What's the trick to display it?

> > > anthony



> > > Knut Radloff wrote:

> > > > I just noticed that you initialize your children array (elnts) to a
fixed
> > > size. The array you return must only have enough slots for
> > > > all the children and no extra null slots. That's probably what's
causing
> > the
> > > exception.
> > > > You need to size it to getChildNodes().getLength(). If you have no
> children
> > > an empty array will be returned.

> > > > Knut
> > > > "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> > > news:b8bjer$6na$1@rogue.oti.com...
> > > > > getChildNodes() is not null BUT getChildNodes().getLength() = 0 !!!
> > > > > I've printed out what happens in class contentProvider:
> > > > >
> > > > > getChildNodes: !null
> > > > > j: 0 /* getChildNodes().getLength() */
> > > > > contentPovider getChildren end /* end of method getChildren() */
> > > > > hasChild /* call method hasChild */
> > > > > contentPovider getChildren /* calls method getChildren() */
> > > > >
> > > > > and when tries j = getChildNodes().getLength(), stops here and after
> lot
> > > > > of things I didn't catch, exception.
> > > > > anthony
> > > > >
> > > > >
> > > > > Knut Radloff wrote:
> > > > >
> > > > > > Does getChildNodes return null when there are no more children? You
> can
> > > set
> > > > > an exception breakpoint in the debugger and find
> > > > > > out.where the exception is occurring.
> > > > >
> > > > > > Knut
> > > > >
> > > > > > PS: Please continue the thread on eclipse.platform, eclipse.tools
> > should
> > > no
> > > > > longer be used and will be made read-only soon.
> > > > >
> > > > > > "anthony saucet" <anthony.saucet@freesbee.fr> wrote in message
> > > > > news:b8bbcv$u1r$1@rogue.oti.com...
> > > > > > > I'm trying to build a TreeView in my perspective to have a look
on
> a
> > > DOM
> > > > > > > tree built in memory.
> > > > > > > I've implemented the TreeView with new TreeViewer, called
> > > > > > > setContentProvider() and setLabelProvider(). setInput() gets the
> > > > > > > rootElement of my DOM tree. Then in class contentProvider, the
tree
> > is
> > > > > > > being built by getChildren(), and everything seems ok.
> > > > > > > here's the code to get the children:
> > > > > > >
> > > > > > > public Object[] getChildren(Object element) {
> > > > > > > Object elnts[]=new Object[20];
> > > > > > > int i = 0;
> > > > > > > int j=((Element)element).getChildNodes().getLength();
> > > > > > >
> > > > > > > for(Node child = ((Element)element).getFirstChild(); i<j;
> > > > > > > ((Element)element).getNextSibling()){
> > > > > > > elnts[i]=((Element)element).getChildNodes().item(i);
> > > > > > > i++;
> > > > > > > }
> > > > > > > return elnts;
> > > > > > > }
> > > > > > >
> > > > > > > I don't really know what happens BUT when it arrives at the end,
> when
> > > no
> > > > > > > more child or items, it tries to continue and to create the tree
> and
> > > the
> > > > > > > following message appears:
> > > > > > > "Unable to create part: Tree" from
> > > > > > > eclipse.core.internal.runtime.InternalPlatform
> > > > > > > and the exception: "nullPointerException".
> > > > > > >
> > > > > > > Does anybody have an idea of what I need to do, or what I missed
?
> > > > > > > many thx
> > > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
Previous Topic:javadoc location
Next Topic:[ANN] MyEclipse Enterprise Workshop 2.0 EA1
Goto Forum:
  


Current Time: Sun May 11 11:01:48 EDT 2025

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

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

Back to the top