Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Problem with TableContentProvider
Problem with TableContentProvider [message #459482] Fri, 01 December 2006 17:06 Go to next message
Eclipse UserFriend
Originally posted by: florianwendland.freenet.de

Hello all,
I have a TableViewer and therefore a ContentProvider implementing
IStructuredContendProvider.
The initial input is a XML-String like this

<DBProfiles>
<DBProfil default='true'>
<usr>ping</usr>
<id>secret</id>
</DBProfil>
</DBProfiles>

In the ContentProvider I'd like to walk through all of these Elements like
this:

public Object[] getElements(Object parent) {
Object[] rObject = new Object[0];
System.out.println("Durchl
Re: Problem with TableContentProvider [message #459486 is a reply to message #459482] Sat, 02 December 2006 04:30 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Why should it be called a second, third, ... time? A TableViewer
presents a flat structure. How do you expect the outcome to be? You need
to walk through all your elements once:

public Object[] getElements(Object parent) {
ArrayList ar = new ArrayList();

if(parent instanceof Element){
createArray(ar,element);
}

return rObject;
}

public void createArray(ArrayList ar, Element element) {
Object[] children = element.getChildren().toArray();
for( int i = 0; i < children.length; i++ ) {
ar.add( children[i] );
createArray(ar,element);
}
}

But represent XML-Structures I think it's wiser to use a TreeViewer with
ITreeContentProvider is the better idea. There your old could would work.

Tom


Florian Wendland schrieb:
> Hello all,
> I have a TableViewer and therefore a ContentProvider implementing
> IStructuredContendProvider.
> The initial input is a XML-String like this
>
> <DBProfiles>
> <DBProfil default='true'>
> <usr>ping</usr>
> <id>secret</id>
> </DBProfil>
> </DBProfiles>
>
> In the ContentProvider I'd like to walk through all of these Elements like
> this:
>
> public Object[] getElements(Object parent) {
> Object[] rObject = new Object[0];
> System.out.println("Durchläufe");
> if(parent instanceof Element){
> Element context = (Element)parent;
>
> if(context.getName().equals("DBProfiles")){
> rObject = context.getChildren().toArray();
> System.out.println("1");
> }
> if(context.getName().equals("DBProfil")){
> rObject = context.getChildren().toArray();
> System.out.println("2");
> }
> }
> return rObject;
> }
>
> My problem is, that the ContentProvider will only be invoked one time, in
> fact for the root element. It never prints 2 to the console.
> What' my error? I can't find anyone.
>
> Thx
> Florian
>
> ------------------------------------------------------------ ----------------
> ----
> Ich verwende die kostenlose Version von SPAMfighter,
> die bei mir bis jetzt 3592 Spammails entfernt hat.
> Für private Anwender ist SPAMfighter völlig kostenlos!
> Jetzt gratis testen: hier klicken.
>
>
Re: Problem with TableContentProvider [message #459489 is a reply to message #459482] Sat, 02 December 2006 09:16 Go to previous message
Eclipse UserFriend
Originally posted by: florianwendland.freenet.de

Thanks,
I think, I had a blackout :)
This works of course.

------------------------------------------------------------ ----------------
----
Ich verwende die kostenlose Version von SPAMfighter,
die bei mir bis jetzt 3608 Spammails entfernt hat.
F
Previous Topic:Extensible FileDialog
Next Topic:buddy classloading troubles
Goto Forum:
  


Current Time: Fri Mar 21 16:02:21 EDT 2025

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

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

Back to the top