Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Common Navigator, TextEditor and IMarkers
Common Navigator, TextEditor and IMarkers [message #525713] Wed, 07 April 2010 14:30 Go to next message
BLANC Philippe is currently offline BLANC PhilippeFriend
Messages: 89
Registered: July 2009
Member
Hello,
I have an issue with the IMarker management.
I've implemented an RCP plug-in with:
- a Common Navigator view displaying my filesystem.
- a TextEditor opened via this navigation view.
- the Problem view

I have also associated a nature and a builder to the opened projects in my navigation view.

This builder aims to check the IFile contents. If there is any error, I added a marker to the IFile resource via tis code:


IMarker marker = resource.createMarker(MARKER_ID);
marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
marker.setAttribute(IMarker.LINE_NUMBER, new Integer(line));



When the builder add the marker, an entry is correctly created in the Problems view. If I double-click on this entry, the corresponding TextEditor is opened and the text is selected.

However, I didn't manage to add an Error icon to my TextEditor and to my Navigation view.

Can anybody help be to do this ?

Thank you.

Regards,

Philippe
Re: Common Navigator, TextEditor and IMarkers [message #526142 is a reply to message #525713] Thu, 08 April 2010 20:46 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2332
Registered: July 2009
Senior Member
On 4/7/2010 10:30 AM, BLANC Philippe wrote:
> I have an issue with the IMarker management.
> I've implemented an RCP plug-in with:
> - a Common Navigator view displaying my filesystem.
> - a TextEditor opened via this navigation view.
> - the Problem view
>
> I have also associated a nature and a builder to the opened projects in
> my navigation view.
>
> This builder aims to check the IFile contents. If there is any error, I
> added a marker to the IFile resource via tis code:
>
>
>
> IMarker marker = resource.createMarker(MARKER_ID);
> marker.setAttribute(IMarker.MESSAGE, message);
> marker.setAttribute(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
> marker.setAttribute(IMarker.LINE_NUMBER, new Integer(line));
>
>
>
> When the builder add the marker, an entry is correctly created in the
> Problems view. If I double-click on this entry, the corresponding
> TextEditor is opened and the text is selected.
>
> However, I didn't manage to add an Error icon to my TextEditor and to my
> Navigation view.
>
> Can anybody help be to do this ?
>
> Thank you.
>
> Regards,
>
> Philippe

You should check which kind of annotation model is being created in
org.eclipse.ui.texteditor.ResourceMarkerAnnotationModelFacto ry#createAnnotationModel(IPath)
.. And I assume that MARKER_ID is a subtype of
org.eclipse.core.resources.problemmarker ?

--
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: Common Navigator, TextEditor and IMarkers [message #526197 is a reply to message #526142] Fri, 09 April 2010 08:14 Go to previous message
BLANC Philippe is currently offline BLANC PhilippeFriend
Messages: 89
Registered: July 2009
Member
Hello Nitin,
Thank you for your answer.

The method org.eclipse.ui.texteditor.ResourceMarkerAnnotationModelFacto ry#createAnnotationModel(IPath) is never called.

About my IMARKER.ID, here is an extract of my plugin.xml :

<extension
         id="dpMarker"
         name="DP Marker"
         point="org.eclipse.core.resources.markers">
      <super
            type="org.eclipse.core.resources.problemmarker">
      </super>
      <super
            type="org.eclipse.core.resources.textmarker">
      </super>
      <persistent
            value="true">
      </persistent>
   </extension>


So, do I have to add myself the annotion in my editor ?

About my Common Navigator view, I tried to implement the ILightweightLabelDecorator and extend the "org.eclipse.ui.decorators" extension point. Here is an extract of my implementation:


@Override
	public void decorate(Object element, IDecoration decoration) {
		IResource resource = (IResource) element;
		if (resource != null && resource.exists()){
			try {
				IMarker[] markers = ((IResource)element).findMarkers(DPIncrementalProjectBuilder.MARKER_ID, true, IResource.DEPTH_INFINITE);
				if (markers.length > 0){
					Image image = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage();
					
					decoration.addOverlay(DecorationOverlayIcon.createFromImage(image), IDecoration.BOTTOM_RIGHT);
				}
			} catch (CoreException e) {
				e.printStackTrace();
			}
		}
	}



When I set my IResource in the dirty state (I call IResource.touch() when the editor is saved), nothing appens. The "Problem" overlay only appears when I select the corresponding resource in my Navigator.

Do you have a solution to all these problems ?

Thank you.

Regards,

Philippe
Previous Topic:Security in eclipse RCP application
Next Topic:Enable and key bindings
Goto Forum:
  


Current Time: Sun Nov 23 03:58:20 GMT 2014

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

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