Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » TextEditor annotations in OverviewRuler from IMarkers
TextEditor annotations in OverviewRuler from IMarkers [message #541654] Tue, 22 June 2010 02:05 Go to next message
No real name is currently offline No real name
Messages: 1
Registered: June 2010
Junior Member
I have a TextEditor. There are markers created by a IncrementalProjectBuilder,
public static final String MARKER_TYPE = "com.salmat.speech.vecomposer.gsleditor.gslProblem";

	private void addMarker(IFile file, String message, int lineNumber,
			int severity) {
		try {
			IMarker marker = file.createMarker(MARKER_TYPE);
			marker.setAttribute(IMarker.MESSAGE, message.replaceAll("\\s", " "));
			marker.setAttribute(IMarker.SEVERITY, severity);
			if (lineNumber == -1) {
				lineNumber = 1;
			}
			marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
		} catch (CoreException e) {
		}
	}


These appear in the VerticalRuler. I think that is because of the following in the plugin.xml
<extension
         id="gslProblem"
         name="GSL Problem"
         point="org.eclipse.core.resources.markers">
      <super
            type="org.eclipse.core.resources.problemmarker">
      </super>
      <persistent
            value="true">
      </persistent>
   </extension>


The markers also appear in the "Problems" and "Markers" pane.
I would like them to also appear in the overview ruler. So far I've been very unsuccessful.

In my TextEditor I have got it showing an overview ruler with:
@Override
	protected boolean isOverviewRulerVisible() {
		return true;
	}


And I've hard coded some annotations on it:
@Override
	protected void editorSaved() {
		super.editorSaved();
		String ERROR_TYPE = "error.type";
		fOverviewRuler.addAnnotationType(ERROR_TYPE);
		fOverviewRuler.addHeaderAnnotationType(ERROR_TYPE);
		fOverviewRuler.setAnnotationTypeLayer(ERROR_TYPE, 3);
		fOverviewRuler.setAnnotationTypeColor(ERROR_TYPE, new Color(Display.getDefault(),new RGB(255,0,0)));
		
		fOverviewRuler.getModel().addAnnotation(new Annotation(ERROR_TYPE,false,"foobar"), new Position(6));
		fOverviewRuler.getModel().addAnnotation(new Annotation(ERROR_TYPE,false,"foobar1"), new Position(60)); 
		
		
	}


How do you get the markers to appear "automatically"?

I'm sure I've missed something very simple Smile

thx,
Jamie
Re: TextEditor annotations in OverviewRuler from IMarkers [message #544272 is a reply to message #541654] Fri, 02 July 2010 08:21 Go to previous message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
jamie.lister.spam@gmail.com wrote:
> I have a TextEditor. There are markers created by a
> IncrementalProjectBuilder,
> public static final String MARKER_TYPE =
> "com.salmat.speech.vecomposer.gsleditor.gslProblem";
>
> private void addMarker(IFile file, String message, int lineNumber,
> int severity) {
> try {
> IMarker marker = file.createMarker(MARKER_TYPE);
> marker.setAttribute(IMarker.MESSAGE,
> message.replaceAll("\\s", " "));
> marker.setAttribute(IMarker.SEVERITY, severity);
> if (lineNumber == -1) {
> lineNumber = 1;
> }
> marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
> } catch (CoreException e) {
> }
> }
>
>
> These appear in the VerticalRuler. I think that is because of the
> following in the plugin.xml
>
> <extension
> id="gslProblem"
> name="GSL Problem"
> point="org.eclipse.core.resources.markers">
> <super
> type="org.eclipse.core.resources.problemmarker">
> </super>
> <persistent
> value="true">
> </persistent>
> </extension>
>
>
> The markers also appear in the "Problems" and "Markers" pane.
> I would like them to also appear in the overview ruler. So far I've
> been very unsuccessful.
>
> In my TextEditor I have got it showing an overview ruler with:
>
> @Override
> protected boolean isOverviewRulerVisible() {
> return true;
> }
>
>
> And I've hard coded some annotations on it:
>
> @Override
> protected void editorSaved() {
> super.editorSaved();
> String ERROR_TYPE = "error.type";
> fOverviewRuler.addAnnotationType(ERROR_TYPE);
> fOverviewRuler.addHeaderAnnotationType(ERROR_TYPE);
> fOverviewRuler.setAnnotationTypeLayer(ERROR_TYPE, 3);
> fOverviewRuler.setAnnotationTypeColor(ERROR_TYPE, new
> Color(Display.getDefault(),new RGB(255,0,0)));
>
> fOverviewRuler.getModel().addAnnotation(new
> Annotation(ERROR_TYPE,false,"foobar"), new Position(6));
> fOverviewRuler.getModel().addAnnotation(new
> Annotation(ERROR_TYPE,false,"foobar1"), new Position(60));
>
> }
>
>
> How do you get the markers to appear "automatically"?
>
> I'm sure I've missed something very simple :)
Take a look at the following extension points:
- org.eclipse.ui.editors.annotationTypes
- org.eclipse.ui.editors.markerAnnotationSpecification

Dani
>
> thx,
> Jamie
Previous Topic:Eclipse SDK vs. Eclipse Platform SDK vs. Eclipse Project SDK
Next Topic:CommonDropAdapterAssistant validateDrop cannot get drag source
Goto Forum:
  


Current Time: Fri Oct 24 18:52:42 GMT 2014

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

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