Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » How to get Project of Element or Model
How to get Project of Element or Model [message #473757] Thu, 05 July 2007 05:36 Go to next message
Francis Gavino is currently offline Francis GavinoFriend
Messages: 57
Registered: July 2009
Member
Hi,

Is there a way to dynamically get the eclipse project (IProject) given the
UML Element or Model?

Thanks,
Francis
Re: How to get Project of Element or Model [message #473758 is a reply to message #473757] Thu, 05 July 2007 11:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Francis,

Here's how to converter between a URI and an IResource:

URI uri =
URI.createPlatformResourceURI(iResource.getFullPath().toStri ng(), true);
IFile iFile = iWorkspaceRoot.getFile(new
Path(uri.toPlatformString(true)));

You can test uri.isPlatformResource() to be sure if the URI is
equivalent to an IFile. Given any EObject x, x.eResource().getURI()
will give you the URI and from that you can determine the IFile and
hance the IProject.


Francis wrote:
> Hi,
>
> Is there a way to dynamically get the eclipse project (IProject) given
> the UML Element or Model?
>
> Thanks,
> Francis
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to get Project of Element or Model [message #473946 is a reply to message #473758] Wed, 11 July 2007 09:23 Go to previous message
Francis Gavino is currently offline Francis GavinoFriend
Messages: 57
Registered: July 2009
Member
Thanks Ed for the response. This approach works for me, although I'm using
EMF 2.2 and URI.toPlatformString() is unavailable. I just created my own
method that uses the segments of the URI to achieve the same result.
Thanks again.

Francis

Ed Merks wrote:

> Francis,

> Here's how to converter between a URI and an IResource:

> URI uri =
> URI.createPlatformResourceURI(iResource.getFullPath().toStri ng(), true);
> IFile iFile = iWorkspaceRoot.getFile(new
> Path(uri.toPlatformString(true)));

> You can test uri.isPlatformResource() to be sure if the URI is
> equivalent to an IFile. Given any EObject x, x.eResource().getURI()
> will give you the URI and from that you can determine the IFile and
> hance the IProject.
Re: How to get Project of Element or Model [message #622730 is a reply to message #473757] Thu, 05 July 2007 11:47 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Francis,

Here's how to converter between a URI and an IResource:

URI uri =
URI.createPlatformResourceURI(iResource.getFullPath().toStri ng(), true);
IFile iFile = iWorkspaceRoot.getFile(new
Path(uri.toPlatformString(true)));

You can test uri.isPlatformResource() to be sure if the URI is
equivalent to an IFile. Given any EObject x, x.eResource().getURI()
will give you the URI and from that you can determine the IFile and
hance the IProject.


Francis wrote:
> Hi,
>
> Is there a way to dynamically get the eclipse project (IProject) given
> the UML Element or Model?
>
> Thanks,
> Francis
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to get Project of Element or Model [message #623645 is a reply to message #473758] Wed, 11 July 2007 09:23 Go to previous message
Francis Gavino is currently offline Francis GavinoFriend
Messages: 57
Registered: July 2009
Member
Thanks Ed for the response. This approach works for me, although I'm using
EMF 2.2 and URI.toPlatformString() is unavailable. I just created my own
method that uses the segments of the URI to achieve the same result.
Thanks again.

Francis

Ed Merks wrote:

> Francis,

> Here's how to converter between a URI and an IResource:

> URI uri =
> URI.createPlatformResourceURI(iResource.getFullPath().toStri ng(), true);
> IFile iFile = iWorkspaceRoot.getFile(new
> Path(uri.toPlatformString(true)));

> You can test uri.isPlatformResource() to be sure if the URI is
> equivalent to an IFile. Given any EObject x, x.eResource().getURI()
> will give you the URI and from that you can determine the IFile and
> hance the IProject.
Previous Topic:Problems saving model (losing hrefs)
Next Topic:Problems with UML2::NamedElement::isDistinguishableFrom
Goto Forum:
  


Current Time: Sat Apr 27 03:28:45 GMT 2024

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

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

Back to the top