Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » provide a model with a plugin
provide a model with a plugin [message #419295] Sat, 17 May 2008 07:09 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Hey,

I created a plugin that holds an uml model library. When I now do: Load
Resource... and enter "platform:/plugin/abcplugin/mymodel.uml it gets loaded.
When I reference elements from "mymodel" in a user model, all the paths to the
mymodel elements are made _relative_ (,e.g. ../../../../../plugin/mymodel.uml)
This means, that as soon as I move the user model into a different folder, it
gets invalid is that right? Is that something that needs to be handled with
"pathmaps"? How?

Thanks,
Felix
Re: provide a model with a plugin [message #419296 is a reply to message #419295] Sat, 17 May 2008 08:45 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
> Is that something that needs to be handled with "pathmaps"? How?

I guess I figured it out, create an extension for
org.eclipse.emf.ecore.uri_mapping. It's really wonderful that you provide all
the examples, without them everything would be much harder.


Felix
Re: provide a model with a plugin [message #419297 is a reply to message #419296] Sat, 17 May 2008 09:18 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
> I guess I figured it out, create an extension for
> org.eclipse.emf.ecore.uri_mapping.

Ok, just to confirm. Now I do Load resource and enter
"pathmap://MYPATH/mymodel.uml"

What is the best way to programmatically create a mapped resource uri?
Can I just use

URI.createURI("pathmap:/MYPATH/mymodel.uml")?


Thanks,
Felix
Re: provide a model with a plugin [message #419298 is a reply to message #419297] Sat, 17 May 2008 11:55 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
> Can I just use
>
> URI.createURI("pathmap:/MYPATH/mymodel.uml")?

This seems to work, but only inside a plugin. What can I do to make it work
standalone (e.g. when testing parts of my plugin code during development)?

Thanks again for help.

Felix
Re: provide a model with a plugin [message #419299 is a reply to message #419295] Sat, 17 May 2008 14:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Felix,

In EcoreResourceFactoryImpl.createResource we use

result.getDefaultSaveOptions().put(XMLResource.OPTION_URI_HA NDLER,
new URIHandlerImpl.PlatformSchemeAware());

to avoid having a relative path from workspace resources to plugin
resources.

If you opened your model and saved it to a different resource rather
than just moving the file, you wouldn't have a problem...


Felix Dorner wrote:
> Hey,
>
> I created a plugin that holds an uml model library. When I now do:
> Load Resource... and enter "platform:/plugin/abcplugin/mymodel.uml it
> gets loaded.
> When I reference elements from "mymodel" in a user model, all the
> paths to the mymodel elements are made _relative_ (,e.g.
> ../../../../../plugin/mymodel.uml) This means, that as soon as I move
> the user model into a different folder, it gets invalid is that right?
> Is that something that needs to be handled with "pathmaps"? How?
>
> Thanks,
> Felix


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: provide a model with a plugin [message #419300 is a reply to message #419298] Sat, 17 May 2008 14:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Felix,

Yes, you can defined your own symbolic URI, but it seems to me that
platform:/plugin/<plugin-id>/mymodel.uml is kind of already a nice
symbolic URI. When developing standalone, you'd need to set up the URI
mappings from platform:/plugin/<plugin-id>/ -> jar:file:/c:/my.jar!/
because obviously when running standalone you have to do
programmatically all the things extension points normally do for you...


Felix Dorner wrote:
>
>> Can I just use
>>
>> URI.createURI("pathmap:/MYPATH/mymodel.uml")?
>
> This seems to work, but only inside a plugin. What can I do to make it
> work standalone (e.g. when testing parts of my plugin code during
> development)?
>
> Thanks again for help.
>
> Felix
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: provide a model with a plugin [message #419301 is a reply to message #419299] Sat, 17 May 2008 14:56 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Ed Merks wrote:
> Felix,
>
> In EcoreResourceFactoryImpl.createResource we use
>
> result.getDefaultSaveOptions().put(XMLResource.OPTION_URI_HA NDLER,
> new URIHandlerImpl.PlatformSchemeAware());
>
> to avoid having a relative path from workspace resources to plugin
> resources.

I see. Maybe the UML2 project developers could be very nice and set those
options in UMLResourceFactoryImpl too?

Felix
Re: provide a model with a plugin [message #419302 is a reply to message #419301] Sat, 17 May 2008 15:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Felix,

I'd suggest opening a bugzilla for that.


Felix Dorner wrote:
> Ed Merks wrote:
>> Felix,
>>
>> In EcoreResourceFactoryImpl.createResource we use
>>
>> result.getDefaultSaveOptions().put(XMLResource.OPTION_URI_HA NDLER,
>> new URIHandlerImpl.PlatformSchemeAware());
>>
>> to avoid having a relative path from workspace resources to plugin
>> resources.
>
> I see. Maybe the UML2 project developers could be very nice and set
> those options in UMLResourceFactoryImpl too?
>
> Felix


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: provide a model with a plugin [message #419303 is a reply to message #419300] Sat, 17 May 2008 15:17 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Ed Merks wrote:

> platform:/plugin/<plugin-id>/mymodel.uml is kind of already a nice
> symbolic URI.
Definitely, I'd prefer that one too.

When developing standalone, you'd need to set up the URI
> mappings from platform:/plugin/<plugin-id>/ -> jar:file:/c:/my.jar!/
> because obviously when running standalone you have to do
> programmatically all the things extension points normally do for you...

Hm, I am not sure if I really understand how it works:

I create and deploy a plugin that holds just a model. Inside this plugin's
manifest I define an extension for the emf uri-map extension point.
I checked what happens at startup: the EMF plugin checks for such extensions and
stores the mappings in an internal map.

At this point I thought I can refer to my model model using the pathmap uri, no
matter if I do this from inside another plugin or from a project in my workspace.

Thanks Ed,
Felix
Re: provide a model with a plugin [message #419305 is a reply to message #419303] Sat, 17 May 2008 16:47 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Felix,

Comments below.

Felix Dorner wrote:
> Ed Merks wrote:
>
>> platform:/plugin/<plugin-id>/mymodel.uml is kind of already a nice
>> symbolic URI.
> Definitely, I'd prefer that one too.
>
> When developing standalone, you'd need to set up the URI
>> mappings from platform:/plugin/<plugin-id>/ -> jar:file:/c:/my.jar!/
>> because obviously when running standalone you have to do
>> programmatically all the things extension points normally do for you...
>
> Hm, I am not sure if I really understand how it works:
You asked about standalone execution. The above would remap any URI
prefixed by the first URI to be prefixed by the second URI instead, and
the second URI allows you to access contents within a zip/jar file. So
in this way, you could ensure that your symbolic "plugin" URIs are
accessible in their jars.
>
> I create and deploy a plugin that holds just a model. Inside this
> plugin's manifest I define an extension for the emf uri-map extension
> point.
> I checked what happens at startup: the EMF plugin checks for such
> extensions and stores the mappings in an internal map.
It stores them in URIConverter.URI_MAP.
>
> At this point I thought I can refer to my model model using the
> pathmap uri, no matter if I do this from inside another plugin or from
> a project in my workspace.
Yes. The same applies for platform:/plugin though and that works
without any additional registration.
>
> Thanks Ed,
> Felix


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:declared vs implemented in jet
Next Topic:What is the best approach to change existing model class names
Goto Forum:
  


Current Time: Tue Apr 23 10:24:01 GMT 2024

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

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

Back to the top