[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] Re: pb building TreeView
|
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@xxxxxxxxxxx> wrote in message news:b8bbcv$u1r$1@xxxxxxxxxxxxxxxx
> 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
>