Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Set Custom Marker on ClassFile
Set Custom Marker on ClassFile [message #506446] Thu, 07 January 2010 14:54 Go to next message
Ben H is currently offline Ben HFriend
Messages: 13
Registered: July 2009
Junior Member
Hi,

i am currently trying to set a Marker on a ClassFile programmatically.
I have no problems to set Markers on a normal .java or .text file by using the method Resource.createMarker(...)

But I am not able to do so on an IClassFile, because I cannot get the Resource for it. I am starting with an IClassFileEditorInput. Is there another way to set markers on ClassFiles?

Thanks in advance,
Ben
Re: Set Custom Marker on ClassFile [message #506597 is a reply to message #506446] Fri, 08 January 2010 09:38 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Ben Herfurth wrote:
> Hi,
>
> i am currently trying to set a Marker on a ClassFile programmatically.
> I have no problems to set Markers on a normal .java or .text file by
> using the method Resource.createMarker(...)
>
> But I am not able to do so on an IClassFile, because I cannot get the
> Resource for it. I am starting with an IClassFileEditorInput. Is there
> another way to set markers on ClassFiles?
You need to attach it to another resource, e.g. the workspace root. See
also org.eclipse.jdt.core.JavaCore.addJavaElementMarkerAttributes (Map,
IJavaElement)

Dani
>
> Thanks in advance,
> Ben
Re: Set Custom Marker on ClassFile [message #506605 is a reply to message #506597] Fri, 08 January 2010 10:06 Go to previous messageGo to next message
Ben H is currently offline Ben HFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Daniel,

schrieb Daniel Megert:
> You need to attach it to another resource, e.g. the workspace root. See
how can I do this?
> also org.eclipse.jdt.core.JavaCore.addJavaElementMarkerAttributes (Map,
> IJavaElement)
>
> Dani

So first thing i have to do is, to attach the ClassFile to the
workspaceRoot. Then i add the MarkerAttributes via the JavaCore-Method.
Then i can create the marker on the WorkspaceRoot-Resource? Is that correct?

Thanks in advance,
Ben
Re: Set Custom Marker on ClassFile [message #506615 is a reply to message #506605] Fri, 08 January 2010 10:46 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Ben Herfurth wrote:
> Hi Daniel,
>
> schrieb Daniel Megert:
>> You need to attach it to another resource, e.g. the workspace root. See
> how can I do this?
>> also org.eclipse.jdt.core.JavaCore.addJavaElementMarkerAttributes (Map,
>> IJavaElement)
>>
>> Dani
>
> So first thing i have to do is, to attach the ClassFile to the
> workspaceRoot.
No, you don't have to "attach" anything.
> Then i add the MarkerAttributes via the JavaCore-Method.
> Then i can create the marker on the WorkspaceRoot-Resource? Is that
> correct?
Yes.

Dani
>
> Thanks in advance,
> Ben
Re: Set Custom Marker on ClassFile [message #506646 is a reply to message #506615] Fri, 08 January 2010 13:37 Go to previous messageGo to next message
Ben H is currently offline Ben HFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Daniel,

thanks for you help so far. I tried your way, but didnt really got it to
work. Now I tried to create only to create the marker on the
WorkspaceRoot and then adding a SimpleMarkerAnnotation to the
annotationModel of the DocumentProvider of the editor.
That worked so far, but even if I set the Marker persistent, the
annotation in the editor isnt persistent. The bookmark remains and is
shown in the BookmarksView, but the ClassFileEditor doesnt have the
marker on a restart of eclipse.
Do you have an idea?

Thanks in advance,
Ben

schrieb Daniel Megert:
> Ben Herfurth wrote:
>> Hi Daniel,
>>
>> schrieb Daniel Megert:
>>> You need to attach it to another resource, e.g. the workspace root. See
>> how can I do this?
>>> also org.eclipse.jdt.core.JavaCore.addJavaElementMarkerAttributes (Map,
>>> IJavaElement)
>>>
>>> Dani
>>
>> So first thing i have to do is, to attach the ClassFile to the
>> workspaceRoot.
> No, you don't have to "attach" anything.
>> Then i add the MarkerAttributes via the JavaCore-Method.
>> Then i can create the marker on the WorkspaceRoot-Resource? Is that
>> correct?
> Yes.
>
> Dani
>>
>> Thanks in advance,
>> Ben
Re: Set Custom Marker on ClassFile [message #506650 is a reply to message #506646] Fri, 08 January 2010 13:58 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Ben Herfurth wrote:
> Hi Daniel,
>
> thanks for you help so far. I tried your way, but didnt really got it
> to work. Now I tried to create only to create the marker on the
> WorkspaceRoot and then adding a SimpleMarkerAnnotation to the
> annotationModel of the DocumentProvider of the editor.
> That worked so far, but even if I set the Marker persistent, the
> annotation in the editor isnt persistent. The bookmark remains and is
> shown in the BookmarksView, but the ClassFileEditor doesnt have the
> marker on a restart of eclipse.
> Do you have an idea?
Normally the editor's marker annotation model only knows about markers
on the resource. If you do special things like having markers on the
workspace root you need to handle this yourself. The
org.eclipse.jdt.internal.ui.javaeditor.ClassFileMarkerAnnota tionModel
does something like that.

Dani
>
> Thanks in advance,
> Ben
>
> schrieb Daniel Megert:
>> Ben Herfurth wrote:
>>> Hi Daniel,
>>>
>>> schrieb Daniel Megert:
>>>> You need to attach it to another resource, e.g. the workspace root.
>>>> See
>>> how can I do this?
>>>> also org.eclipse.jdt.core.JavaCore.addJavaElementMarkerAttributes (Map,
>>>> IJavaElement)
>>>>
>>>> Dani
>>>
>>> So first thing i have to do is, to attach the ClassFile to the
>>> workspaceRoot.
>> No, you don't have to "attach" anything.
>>> Then i add the MarkerAttributes via the JavaCore-Method.
>>> Then i can create the marker on the WorkspaceRoot-Resource? Is that
>>> correct?
>> Yes.
>>
>> Dani
>>>
>>> Thanks in advance,
>>> Ben
>
Previous Topic:Editor using UTF-8
Next Topic:what can eclipse do for my organization?
Goto Forum:
  


Current Time: Fri Mar 29 05:19:54 GMT 2024

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

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

Back to the top