Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » IMarker and IResource
IMarker and IResource [message #427131] Tue, 03 February 2009 10:37 Go to next message
Matthias is currently offline MatthiasFriend
Messages: 19
Registered: July 2009
Junior Member
Hi,

I have following problem.

I try to create IMarkers, this works well, but I can not click on "Go to"
to follow the marker to the element in the editor.

I tried:

EObject eObject = (EObject)select.getFirstElement();
Resource resource = eObject.eResource();

IResource iresource = ResourcesPlugin.getWorkspace().getRoot();
URI pathn = EcoreUtil.getURI(eObject);


imarker = iresource.createMarker(IMarker.PROBLEM);
imarker.setAttribute(IMarker.MESSAGE, "Test error");
imarker.setAttribute(IMarker.LOCATION, "Element X");


I think it is a problem of the resources.
How to get from resource to iresource?

Thanks a lot

Matthias
Re: IMarker and IResource [message #427136 is a reply to message #427131] Tue, 03 February 2009 13:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000304070607080405080204
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Matthias,

I've added this to the FAQ:
< http://wiki.eclipse.org/EMF/FAQ#How_do_I_map_between_an_EMF_ Resource_and_an_Eclipse_IFile.3F>


http://wiki.eclipse.org/EMF/FAQ#How_do_I_map_between_an_EMF_ Resource_and_an_Eclipse_IFile.3F



Matthias wrote:
> Hi,
>
> I have following problem.
>
> I try to create IMarkers, this works well, but I can not click on "Go
> to" to follow the marker to the element in the editor.
>
> I tried:
>
> EObject eObject = (EObject)select.getFirstElement();
> Resource resource = eObject.eResource();
>
> IResource iresource = ResourcesPlugin.getWorkspace().getRoot();
> URI pathn = EcoreUtil.getURI(eObject);
>
>
> imarker = iresource.createMarker(IMarker.PROBLEM);
> imarker.setAttribute(IMarker.MESSAGE, "Test error");
> imarker.setAttribute(IMarker.LOCATION, "Element X");
>
>
> I think it is a problem of the resources.
> How to get from resource to iresource?
>
> Thanks a lot
>
> Matthias
>
>

--------------000304070607080405080204
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Matthias,<br>
<br>
I've added this to the FAQ:<a
href=" http://wiki.eclipse.org/EMF/FAQ#How_do_I_map_between_an_EMF_ Resource_and_an_Eclipse_IFile.3F"><br>
</a>
<blockquote><a
href=" http://wiki.eclipse.org/EMF/FAQ#How_do_I_map_between_an_EMF_ Resource_and_an_Eclipse_IFile.3F"> http://wiki.eclipse.org/EMF/FAQ#How_do_I_map_between_an_EMF_ Resource_and_an_Eclipse_IFile.3F</a><br>
</blockquote>
<br>
<br>
Matthias wrote:
<blockquote
cite="mid:0bcc94818cf059a71f057cfb3cd0ab60$1@www.eclipse.org"
type="cite">Hi,
<br>
<br>
I have following problem.
<br>
<br>
I try to create IMarkers, this works well, but I can not click on "Go
to" to follow the marker to the element in the editor.
<br>
<br>
I tried:
<br>
<br>
EObject eObject


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: IMarker and IResource [message #427140 is a reply to message #427131] Tue, 03 February 2009 17:39 Go to previous messageGo to next message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
Matthias,

BTW, this might affect you as well:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=196618




Matthias wrote:
> Hi,
>
> I have following problem.
>
> I try to create IMarkers, this works well, but I can not click on "Go
> to" to follow the marker to the element in the editor.
>
> I tried:
>
> EObject eObject = (EObject)select.getFirstElement();
> Resource resource = eObject.eResource();
>
> IResource iresource = ResourcesPlugin.getWorkspace().getRoot(); URI
> pathn = EcoreUtil.getURI(eObject);
>
>
> imarker = iresource.createMarker(IMarker.PROBLEM);
> imarker.setAttribute(IMarker.MESSAGE, "Test error");
> imarker.setAttribute(IMarker.LOCATION, "Element X");
>
>
> I think it is a problem of the resources.
> How to get from resource to iresource?
>
> Thanks a lot
>
> Matthias
>
>
Re: IMarker and IResource [message #427145 is a reply to message #427140] Wed, 04 February 2009 07:45 Go to previous messageGo to next message
Matthias is currently offline MatthiasFriend
Messages: 19
Registered: July 2009
Junior Member
Not really,

the main problem for me is this:

EObject ob = (EObject) (select.getFirstElement());
URI uri = EcoreUtil.getURI(ob);
URI newuri = URI.createPlatformResourceURI(uri.path(), true);

IPath path = ???;

IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);


I don't know how to get the link between the URI and the IResource.
(see questionmarks above)

Maybe someone knows it?

Thanks a lot

Matthias


AJ wrote:

> Matthias,

> BTW, this might affect you as well:

> https://bugs.eclipse.org/bugs/show_bug.cgi?id=196618




> Matthias wrote:
>> Hi,
>>
>> I have following problem.
>>
>> I try to create IMarkers, this works well, but I can not click on "Go
>> to" to follow the marker to the element in the editor.
>>
>> I tried:
>>
>> EObject eObject = (EObject)select.getFirstElement();
>> Resource resource = eObject.eResource();
>>
>> IResource iresource = ResourcesPlugin.getWorkspace().getRoot(); URI
>> pathn = EcoreUtil.getURI(eObject);
>>
>>
>> imarker = iresource.createMarker(IMarker.PROBLEM);
>> imarker.setAttribute(IMarker.MESSAGE, "Test error");
>> imarker.setAttribute(IMarker.LOCATION, "Element X");
>>
>>
>> I think it is a problem of the resources.
>> How to get from resource to iresource?
>>
>> Thanks a lot
>>
>> Matthias
>>
>>
Re: IMarker and IResource [message #427147 is a reply to message #427145] Wed, 04 February 2009 12:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070509040605080603010408
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Matthias,

I'm not sure how the FAQ I pointed you to doesn't already answer this
question. I suppose the wiki site being down isn't helping.

..Use platform resource URIs to access the workspace
-- platform:/resource/project[/relative-path]
--Be sure to encode the path
..URI.createPlatformResourceURI(iFile.getPath().toString(), true)
--Use workspaceRoot.getFile(new
Path(uri.toPlatformResourceString(true))) to convert back to an IFile



Matthias wrote:
> Not really,
>
> the main problem for me is this:
>
> EObject ob = (EObject) (select.getFirstElement());
> URI uri = EcoreUtil.getURI(ob);
> URI newuri = URI.createPlatformResourceURI(uri.path(), true);
Do you try this in the debugger to see what kind of values you're
dealing with?
>
> IPath path = ???;
>
> IResource res =
> ResourcesPlugin.getWorkspace().getRoot().findMember(path);
>
>
> I don't know how to get the link between the URI and the IResource.
> (see questionmarks above)
>
> Maybe someone knows it?
>
> Thanks a lot
>
> Matthias
>
>
> AJ wrote:
>
>> Matthias,
>
>> BTW, this might affect you as well:
>
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=196618
>
>
>
>
>> Matthias wrote:
>>> Hi,
>>>
>>> I have following problem.
>>>
>>> I try to create IMarkers, this works well, but I can not click on
>>> "Go to" to follow the marker to the element in the editor.
>>>
>>> I tried:
>>>
>>> EObject eObject = (EObject)select.getFirstElement();
>>> Resource resource = eObject.eResource();
>>>
>>> IResource iresource = ResourcesPlugin.getWorkspace().getRoot();
>>> URI pathn = EcoreUtil.getURI(eObject);
>>> imarker =
>>> iresource.createMarker(IMarker.PROBLEM);
>>> imarker.setAttribute(IMarker.MESSAGE, "Test error");
>>> imarker.setAttribute(IMarker.LOCATION, "Element X");
>>>
>>>
>>> I think it is a problem of the resources.
>>> How to get from resource to iresource?
>>>
>>> Thanks a lot
>>>
>>> Matthias
>>>
>
>

--------------070509040605080603010408
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Matthias,<br>
<br>
I'm not sure how the FAQ I pointed you to doesn't already answer this
question. I suppose the wiki site being down isn't helping.<br>
<br>
<div
style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0.38in; text-indent: -0.38in;"><span
style="font-size: 28pt;"><span style="">&#8226;</span></span><span
style="font-size: 28pt; font-family: Corbel;">Use platform resource
URIs to access the workspace</span></div>
<div class="O1"
style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0.81in; text-indent: -0.31in;"><span
style="font-size: 24pt;"><span style="">&#8211;</span></span><span
style="font-size: 24pt; font-family: Corbel;"> </span><span
style="font-size: 24pt; font-family: Corbel; color: rgb(192, 80, 77);">platform:</span><span
style="font-size: 24pt; font-family: Corbel; color: rgb(31, 73, 125);">/resource/</span><span
style="font-size: 24pt; font-family: Corbel; color: rgb(49, 133, 156);">project</span><span
style="font-size: 24pt; font-family: Corbel;">[</span><span
style="font-size: 24pt; font-family: Corbel; color: rgb(148, 138, 84);">/relative-path</span><span
style="font-size: 24pt; font-family: Corbel;">]</span></div>
<div class="O1"
style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0.81in; text-indent: -0.31in;"><span
style="font-size: 24pt;"><span style="">&#8211;</span></span><span
style="font-size: 24pt; font-family: Corbel;">Be sure to encode the
path</span></div>
<div class="O2"
style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 1.25in; text-indent: -0.25in;"><span
style="font-size: 18pt;"><span style="">&#8226;</span></span><span
style="font-size: 18pt; font-family: Corbel;">URI.createPlatformResourceURI</span><span
style="font-size: 18pt; font-family: Corbel;">(</span><span
style="font-size: 18pt; font-family: Corbel;">iFile.getPath</span><span
style="font-size: 18pt; font-family: Corbel;">().</span><span
style="font-size: 18pt; font-family: Corbel;">toString</span><span
style="font-size: 18pt; font-family: Corbel;">(), true)</span></div>
<div class="O1"
style="margin-top: 0pt; margin-bottom: 0pt; margin-left: 0.81in; text-indent: -0.31in;"><span
style="font-size: 24pt;"><span style="">&#8211;</span></span><span
style="font-size: 24pt; font-family: Corbel;">Use </span><span
style="font-size: 18pt; font-family: Corbel;">workspaceRoot.getFile</span><span
style="font-size: 18pt; font-family: Corbel;">(new Path(</span><span
style="font-size: 18pt; font-family: Corbel;">uri.toPlatformResourceString</span><span
style="font-size: 18pt; font-family: Corbel;">(true)))</span><span
style="font-size: 24pt; font-family: Corbel;"> to convert back to an </span><span
style="font-size: 24pt; font-family: Corbel;">IFile</span><span
style="font-size: 24pt; font-family: Corbel;">
</span></div>
<br>
<br>
<br>
Matthias wrote:
<blockquote
cite="mid:148f5f00bbb7044a24ccfcac20e192a0$1@www.eclipse.org"
type="cite">Not really,
<br>
<br>
the main problem for me is this:
<br>
<br>
EObject ob = (EObject) (select.getFirstElement());
<br>
URI uri = EcoreUtil.getURI(ob);
<br>
URI newuri = URI.createPlatformResourceURI(uri.path(), true);
<br>
</blockquote>
Do you try this in the debugger to see what kind of values you're
dealing with?<br>
<blockquote
cite="mid:148f5f00bbb7044a24ccfcac20e192a0$1@www.eclipse.org"
type="cite">


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: IMarker and IResource [message #427153 is a reply to message #427147] Wed, 04 February 2009 13:21 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Ed, Matthias,

If you happen to be using the EMF Transaction component in your project,
anyway, then you might consider using the
WorkspaceSynchronizer::getFile(...) utility method to get the file
underlying a resource. It supports, in addition to platform:/resource
URIs, also archive URIs (e.g., jar:), file: URIs, and (via the
URIConverter) any other abstract scheme such as GMF's pathmap: scheme
that can be translated to something resolving to a file in the workspace.

HTH,

Christian


Ed Merks wrote:
> Matthias,
>
> I'm not sure how the FAQ I pointed you to doesn't already answer this
> question. I suppose the wiki site being down isn't helping.
>
> •Use platform resource URIs to access the workspace
> – platform:/resource/project[/relative-path]
> –Be sure to encode the path
> •URI.createPlatformResourceURI(iFile.getPath().toString(), true)
> –Use workspaceRoot.getFile(new Path(uri.toPlatformResourceString(true)))
> to convert back to an IFile
>
>
>
> Matthias wrote:
>> Not really,
>>
>> the main problem for me is this:
>>
>> EObject ob = (EObject) (select.getFirstElement());
>> URI uri = EcoreUtil.getURI(ob);
>> URI newuri = URI.createPlatformResourceURI(uri.path(), true);
> Do you try this in the debugger to see what kind of values you're
> dealing with?
>>
>> IPath path = ???;
>>
>> IResource res =
>> ResourcesPlugin.getWorkspace().getRoot().findMember(path);
>>
>>
>> I don't know how to get the link between the URI and the IResource.
>> (see questionmarks above)
>>
>> Maybe someone knows it?
>>
>> Thanks a lot
>>
>> Matthias
>>
>>
>> AJ wrote:
>>
>>> Matthias,
>>
>>> BTW, this might affect you as well:
>>
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=196618
>>
>>
>>
>>
>>> Matthias wrote:
>>>> Hi,
>>>>
>>>> I have following problem.
>>>>
>>>> I try to create IMarkers, this works well, but I can not click on
>>>> "Go to" to follow the marker to the element in the editor.
>>>>
>>>> I tried:
>>>>
>>>> EObject eObject = (EObject)select.getFirstElement();
>>>> Resource resource = eObject.eResource();
>>>>
>>>> IResource iresource = ResourcesPlugin.getWorkspace().getRoot();
>>>> URI pathn = EcoreUtil.getURI(eObject);
>>>> imarker =
>>>> iresource.createMarker(IMarker.PROBLEM);
>>>> imarker.setAttribute(IMarker.MESSAGE, "Test error");
>>>> imarker.setAttribute(IMarker.LOCATION, "Element X");
>>>>
>>>>
>>>> I think it is a problem of the resources.
>>>> How to get from resource to iresource?
>>>>
>>>> Thanks a lot
>>>>
>>>> Matthias
>>>>
>>
>>
Previous Topic:generating a graphical representation of a gmf model
Next Topic:Validation Framework
Goto Forum:
  


Current Time: Fri Apr 26 09:36:09 GMT 2024

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

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

Back to the top