Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Creating href
Creating href [message #656556] Sat, 26 February 2011 18:08 Go to next message
AJ  is currently offline AJ Friend
Messages: 77
Registered: July 2009
Member
I have a template resource at the workspace level so UI preferences are defined as per user. However, this resource contains proxy references to resources in the project(s) that the user has created.

Currently, all href are being set the uri of the main container template resource when it is saved.

So, is there a way I can change the contained href to point to each individual project when the template resource is saved?

/workspace/user_resource.xmi
href=/workspace/projectA/myResources/resource1.xmi
Re: Creating href [message #656563 is a reply to message #656556] Sat, 26 February 2011 19:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
AJ,

Aren't the user's resources using
platform:/resource/projectA/myResources/resource1.xmi?


AJ wrote:
> I have a template resource at the workspace level so UI preferences
> are defined as per user. However, this resource contains proxy
> references to resources in the project(s) that the user has created.
>
> Currently, all href are being set the uri of the main container
> template resource when it is saved.
>
> So, is there a way I can change the contained href to point to each
> individual project when the template resource is saved?
>
> /workspace/user_resource.xmi
> href=/workspace/projectA/myResources/resource1.xmi
Re: Creating href [message #656580 is a reply to message #656563] Sun, 27 February 2011 00:01 Go to previous messageGo to next message
AJ  is currently offline AJ Friend
Messages: 77
Registered: July 2009
Member
Ed,

Yes, they are using the "platform" scheme, but the segment is set to the container template resource uri.

So I need (as you indicated):

platform:/resource/project_ID/resources_folder/resource1.xmi

But instead, I am getting:

platform:/plugin/plugin_location/datafiles/resource1.xmi

Do I need to do something like computePlatformPluginToPlatformResourceMap() to compute from platform:/plugin/ to platform:/resource/?

Thanks!

[Updated on: Mon, 28 February 2011 16:37]

Report message to a moderator

Re: Creating href [message #656846 is a reply to message #656580] Mon, 28 February 2011 18:55 Go to previous messageGo to next message
AJ  is currently offline AJ Friend
Messages: 77
Registered: July 2009
Member
The method below, it seems to do what I need. However, resourceSet.getURIConverter().exists(uri, null) return false if I add the URI map before the template resource in the plugin is loaded.

.....
...
resourceSet.getURIConverter().getURIMap().putAll(computePlat formPluginToPlatformResourceMap());
if (resourceSet.getURIConverter().exists(uri, null)) {
try {
timelineResource = resourceSet.getResource(uri, true);
.....
...

//-----------------------
public static Map<URI, URI> computePlatformPluginToPlatformResourceMap() {
Map<URI, URI> result = new HashMap<URI, URI>();
IWorkspaceRoot root = EcorePlugin.getWorkspaceRoot();
if (root != null) {
IProject[] projects = root.getProjects();
if (projects != null) {
for (IProject project : projects) {
if (project.isOpen()) {
URI platformPluginURI = URI.createPlatformPluginURI("plugin_ID/datafiles" + "/", false);
URI platformResourceURI = URI.createPlatformResourceURI(project.getName() + "/", true);
result.put(platformPluginURI, platformResourceURI);
}
}
}
}
return result;
}
//----


In summary, the template.xmi containig a relative href="datafiles/myresource1.xmi#S_AVAIL"/ and when it is loaded from the plugin, the href is change to the location of the template.xmi resource (ie. platform:/plugin/plugin_location/datafiles/myresource1.xmi#S _AVAIL ").

However, that template is then saved into the user workspace as user.xmi and there is when I need the href to be converted from platform:/plugin/ to platform:/resource/project_id/

I tried to set the URIMap in the resourceset before I save it, but it doesn't affect anything. Any suggestion will be greatly appreciated!
Re: Creating href [message #656854 is a reply to message #656846] Mon, 28 February 2011 19:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
AJ,

Comments below.

AJ wrote:
> The method below, it seems to do what I need. However,
> resourceSet.getURIConverter().exists(uri, null) return false
Kind of losing context here given your posting is appearing as a new
top-level thread...

For which URI?
> if I add the URI map before the template resource in the plugin is
> loaded.
>
> ....
> ..
> resourceSet.getURIConverter().getURIMap().putAll(computePlat
> formPluginToPlatformResourceMap());
> if (resourceSet.getURIConverter().exists(uri, null)) {
> try {
> timelineResource = resourceSet.getResource(uri, true);
> ....
> ..
>
> //-----------------------
> public static Map<URI, URI>
> computePlatformPluginToPlatformResourceMap() {
> Map<URI, URI> result = new HashMap<URI, URI>();
> IWorkspaceRoot root = EcorePlugin.getWorkspaceRoot();
> if (root != null) {
> IProject[] projects = root.getProjects();
> if (projects != null) {
> for (IProject project : projects) {
> if (project.isOpen()) {
> URI platformPluginURI =
> URI.createPlatformPluginURI("plugin_ID/datafiles" + "/", false);
> URI platformResourceURI =
> URI.createPlatformResourceURI(project.getName() + "/", true);
> result.put(platformPluginURI,
> platformResourceURI);
> }
> }
> }
> }
> return result;
> }
This is intended for redirecting URIs pointing at the installed IDE's
plugins to their equivalent in the workspace...
> //----
>
>
> In summary, the template.xmi containig a relative
> href="datafiles/myresource1.xmi#S_AVAIL"/ and when it is loaded from
> the plugin, the href is change to the location of the template.xmi
> resource (ie.
> platform:/plugin/plugin_location/datafiles/myresource1.xmi#S _AVAIL ").
If that URI is relative it is expected to exist in the plugins.
> However, that template is then saved into the user workspace as
> user.xmi and there is when I need the href to be converted from
> platform:/plugin/ to platform:/resource/project_id/
How is it that installed plugins should have data files that point into
the workspace? A workspace could be empty...
>
> I tried to set the URIMap in the resourceset before I save it, but it
> doesn't affect anything. Any suggestion will be greatly appreciated!
The map won't affect the URIs used when saving. The logical URIs on the
resources themselves will always be used.

Maybe taking a step back will help. How is it that an installed
plug-in's data files should be pointing into the workspace? Of course
you can do that with a platform:/resource URI, but you have relative
URIs. How does it end up that way?
Re: Creating href [message #656878 is a reply to message #656854] Mon, 28 February 2011 21:07 Go to previous messageGo to next message
AJ  is currently offline AJ Friend
Messages: 77
Registered: July 2009
Member
Hi Ed,

Yes, let's step back. I hope I can now formulate my question/problem better.

I have a resource loaded from the user workspace and it contains no-containment references to resources that might or might not exist in a user's project.

These hrefs look like this:

<profile href="project:/Resources/resouceA.xmi#ALL_AVAIL"/>

When it is loaded, I use my own URIConverter to resolve in runtime the "project/..." scheme to "platform:/resource/current_project/..."

However, I am not able to convert it back to "project/..." when the resource is saved. Is there a way to do that?

Thank again, Ed!

[Updated on: Mon, 28 February 2011 21:48]

Report message to a moderator

Re: Creating href [message #657085 is a reply to message #656878] Tue, 01 March 2011 15:00 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
AJ,

Comments below.

AJ wrote:
> Hi Ed,
>
> Yes, let's step back. I hope I can now formulate my question/problem
> better.
>
> I have resource loaded from the user workspace and it contains
> no-containment references to resources that might or might not exist
> in a user's project.
Sounds pretty fuzzy.
>
> These hrefs look like this:
>
> <profile href="project:/Resources/resouceA.xmi#ALL_AVAIL"/>
So this is a scheme you've synthesized instead of using
platform:/resource/<project>....?
>
> Is there a mechanism where I can resolve in runtime my "project/..."
> scheme to "platform:/resource/current_project/..." and convert it back
> to "project/..." when the resource is saved?
You could look into using

/**
* A {@link URIHandler} value that will be used to control how URIs
are {@link URI#resolve(URI) resolved} during load
* and {@link URI#deresolve(URI) deresolved} during save.
* @see URI
* @see URIHandler
* @see XMLHelper#resolve(URI, URI)
* @see XMLHelper#deresolve(URI)
* @see URIHandlerImpl
*/
String OPTION_URI_HANDLER = "URI_HANDLER";

>
> Can it be done via URIConverter or URIHandler?
The URIConverter supports folder remapping... It's not clear to me why
you need your own scheme?
>
> Thank again, Ed!
Previous Topic:Analyzing accessible EMF metamodels for project
Next Topic:PropertyView customizing
Goto Forum:
  


Current Time: Thu Oct 17 18:16:32 GMT 2019

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

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

Back to the top