Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » CNF: How can ContentProvider determine project of an object?
CNF: How can ContentProvider determine project of an object? [message #641289] Wed, 24 November 2010 13:18 Go to next message
Eclipse User
Originally posted by: yoduderoo.netscape.net

Hi,
I use Common Navigator Framework in an RCP app. The user creates
projects and under each project are domain objects which are retrieved
from a DB.

For the content provider methods such as hasChildren(Object element), I
need to know the project to which the passed domain object belongs
(i.e., element argument in hasChildren()).

How does one determine the nav tree path of an element passed to a
content provider?

Thanks, -yo
Re: CNF: How can ContentProvider determine project of an object? [message #641498 is a reply to message #641289] Thu, 25 November 2010 12:05 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IV
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
You don't need to worry about navigating the tree of the objects if the object is an IResource (which it will be if you are using the CNF against a workspace. Check if it's an IResource and use IResource.getProject().

Re: CNF: How can ContentProvider determine project of an object? [message #641520 is a reply to message #641498] Thu, 25 November 2010 14:15 Go to previous messageGo to next message
Eclipse User
Originally posted by: yoduderoo.netscape.net

The objects are not IResource but rather EMF objects retrieved from a
database.
Thanks, y

Francis Upton wrote:
> You don't need to worry about navigating the tree of the objects if the
> object is an IResource (which it will be if you are using the CNF
> against a workspace. Check if it's an IResource and use
> IResource.getProject().
Re: CNF: How can ContentProvider determine project of an object? [message #641521 is a reply to message #641520] Thu, 25 November 2010 14:27 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25919
Registered: July 2009
Senior Member
I don't think anyone can answer this question. There isn't a general
way to know the project of an EObject. Certainly one can use
EObject.eResource() to determine the containing resource and
Resource.getURI() to determine that resource's URI. If it's of the form
platform:/resource/ (URI.isPlatformResource() is true) you can map that
to a workspace IResource (as described in the FAQ). In the end though,
I think only you have the specific knowledge to answer your own question.


Yodude wrote:
> The objects are not IResource but rather EMF objects retrieved from a
> database.
> Thanks, y
>
> Francis Upton wrote:
>> You don't need to worry about navigating the tree of the objects if
>> the object is an IResource (which it will be if you are using the CNF
>> against a workspace. Check if it's an IResource and use
>> IResource.getProject().
Previous Topic:Unable to compile class for JSP
Next Topic:FormEditor and Refresh editor pages
Goto Forum:
  


Current Time: Sat Jul 26 11:22:12 EDT 2014

Powered by FUDForum. Page generated in 0.02731 seconds