treeview with different classes [message #216934] |
Wed, 20 June 2007 08:31 |
Eclipse User |
|
|
|
Originally posted by: karl.lindsten.com
Trying too biuld a treeview and its okej when its only one class in the
hiraky. But the thing is that the children is of another classtype and
this cant my labelProvider handle. Someone know a solution?
public class ProfilerDataListLabelProvider extends LabelProvider{
public String getText(Object elem){
System.out.println("get text");
classOne c1 = (classOne) elem;
// should also be able to handle this of elem = classTwo
// classTwo c2 = (classTwo) elem;
return profilerData.date;
}
}
|
|
|
Re: treeview with different classes [message #216977 is a reply to message #216934] |
Wed, 20 June 2007 10:30 |
Eclipse User |
|
|
|
Originally posted by: nugaee.SPAMtlen.pl
karl wrote:
> Trying too biuld a treeview and its okej when its only one class in the
> hiraky. But the thing is that the children is of another classtype and
> this cant my labelProvider handle. Someone know a solution?
>
> public class ProfilerDataListLabelProvider extends LabelProvider{
>
> public String getText(Object elem){
> System.out.println("get text");
>
> classOne c1 = (classOne) elem;
> // should also be able to handle this of elem = classTwo
> // classTwo c2 = (classTwo) elem;
>
>
> return profilerData.date;
> }
> }
>
public String getText(Object item) {
if(item instanceof Sth) {
...
} else if(item instanceof SthElse) {
...
} else {
return item.toString();
}
}
you can also use adapters but i don't know if this is suitable for your
purpose
best regards
bartek michalik
|
|
|
Powered by
FUDForum. Page generated in 0.07899 seconds