Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » TreeViewer Label Provider
TreeViewer Label Provider [message #465282] Wed, 28 March 2007 08:42 Go to next message
Swetha is currently offline SwethaFriend
Messages: 68
Registered: July 2009
Member
Hi All,

I have Experiment domain object in which dateTime is one of the
fields..(Corresponding table is Experiment in oracle database)..

I need to develop a tree Viewer in which the first level node is the
Experiment domain object but the label to be represented is only Year of
dateTime, so in label provider class I can return only year...

When I click on the year say 2007, as a child nodes again experiment
domain object but the content is only month in the second level of tree
and agin for the third level same experiment domain but the label is only
day....

How can I manage this in label provider and content provider..

Pls give me the links for the snippets of this type...


Thanks,
Swetha
Re: TreeViewer Label Provider [message #465284 is a reply to message #465282] Wed, 28 March 2007 08:56 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

What is your problem:
1. You don't know how to model/design your system
2. You don't know how to use LabelProviders?

For 2. I have an answer:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/

Tom

Swetha schrieb:
> Hi All,
>
> I have Experiment domain object in which dateTime is one of the
> fields..(Corresponding table is Experiment in oracle database)..
>
> I need to develop a tree Viewer in which the first level node is the
> Experiment domain object but the label to be represented is only Year of
> dateTime, so in label provider class I can return only year...
>
> When I click on the year say 2007, as a child nodes again experiment
> domain object but the content is only month in the second level of tree
> and agin for the third level same experiment domain but the label is
> only day....
>
> How can I manage this in label provider and content provider..
>
> Pls give me the links for the snippets of this type...
>
>
> Thanks,
> Swetha
>


--
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
----------------------------------------------------
tom schindl Eclipse JFace Committer
Re: TreeViewer Label Provider [message #465288 is a reply to message #465284] Wed, 28 March 2007 09:13 Go to previous messageGo to next message
Swetha is currently offline SwethaFriend
Messages: 68
Registered: July 2009
Member
Hi,

My problem is with the Label Provider only..

I am placing same domain object at three levels of tree...but the label
at three levels is different..
How can I manage this in LabelProvider.. in getText() method how can I
manage it as I don't have the info abt the the level of tree..

I hope u understand my problem..

Thanks,
Swetha
Re: TreeViewer Label Provider [message #465292 is a reply to message #465288] Wed, 28 March 2007 09:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: starkom.ngs.ru

getText(Object obj) - you can write wrappers for dateTime and put they i=
n =

your ContentProvider

FirstLevelDateTimeWrapper {
dateTime info =3D [setting in constructor]
....
public String toString() {
return info.getYear();
}
}

and so on...

Then your method will be getText(Object obj) {
return obj.toString();
}

On Wed, 28 Mar 2007 16:13:26 +0700, Swetha <swetha@yahoo.co.in> wrote:

> Hi,
>
> My problem is with the Label Provider only..
>
> I am placing same domain object at three levels of tree...but the =

> label at three levels is different.. How can I manage this in =

> LabelProvider.. in getText() method how can I manage it as I don't hav=
e =

> the info abt the the level of tree..
>
> I hope u understand my problem..
>
> Thanks,
> Swetha
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: TreeViewer Label Provider [message #465294 is a reply to message #465288] Wed, 28 March 2007 09:39 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Why don't the level in your model object idicating the level this object
is part of?


In LabelProvider:

private SimpleDateFormat[] levels = new SimplyDateFormat[] {
new SimplyDateFormat("yyyy"),
new SimplyDateFormat("MM"),
new SimplyDateFormat("dd")};

public String getText(Object element) {
MyModel element = (MyModel)element;

return levels[element.getLevel()].format(element.getDate());
}



Swetha schrieb:
> Hi,
>
> My problem is with the Label Provider only..
>
> I am placing same domain object at three levels of tree...but the label
> at three levels is different.. How can I manage this in LabelProvider..
> in getText() method how can I manage it as I don't have the info abt the
> the level of tree..
>
> I hope u understand my problem..
>
> Thanks,
> Swetha
>


--
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
----------------------------------------------------
tom schindl Eclipse JFace Committer
Re: TreeViewer Label Provider [message #465298 is a reply to message #465294] Wed, 28 March 2007 10:10 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Even simpler:

In 3.2: Implement the ITreePathLabelProvider-Interface
In 3.3: Subclass the CellLabelProvider and find out which item in the
Tree you are working on by calling viewerCell.getViewerRow().getTreePath()

Tom

Tom Schindl schrieb:
> Why don't the level in your model object idicating the level this object
> is part of?
>
>
> In LabelProvider:
>
> private SimpleDateFormat[] levels = new SimplyDateFormat[] {
> new SimplyDateFormat("yyyy"),
> new SimplyDateFormat("MM"),
> new SimplyDateFormat("dd")};
>
> public String getText(Object element) {
> MyModel element = (MyModel)element;
>
> return levels[element.getLevel()].format(element.getDate());
> }
>
>
>
> Swetha schrieb:
>> Hi,
>>
>> My problem is with the Label Provider only..
>>
>> I am placing same domain object at three levels of tree...but the label
>> at three levels is different.. How can I manage this in LabelProvider..
>> in getText() method how can I manage it as I don't have the info abt the
>> the level of tree..
>>
>> I hope u understand my problem..
>>
>> Thanks,
>> Swetha
>>
>
>


--
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
----------------------------------------------------
tom schindl Eclipse JFace Committer
Re: TreeViewer Label Provider [message #465302 is a reply to message #465292] Wed, 28 March 2007 10:51 Go to previous messageGo to next message
Swetha is currently offline SwethaFriend
Messages: 68
Registered: July 2009
Member
Hi,

Can u please provide me some sample using wrappers
this is pretty urgent

Thanks,
Swetha
Re: TreeViewer Label Provider [message #465304 is a reply to message #465298] Wed, 28 March 2007 10:53 Go to previous messageGo to next message
Swetha is currently offline SwethaFriend
Messages: 68
Registered: July 2009
Member
Hi Tom,

Is there any snippets on using this ITreePathLabelProvider

Thanks,
Swetha
Re: TreeViewer Label Provider [message #465336 is a reply to message #465304] Wed, 28 March 2007 17:40 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
no.

Swetha schrieb:
> Hi Tom,
>
> Is there any snippets on using this ITreePathLabelProvider
>
> Thanks,
> Swetha
>
Previous Topic:adding action to an existing actionSet
Next Topic:RCP freezes up
Goto Forum:
  


Current Time: Fri Sep 13 02:55:58 GMT 2024

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

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

Back to the top