01: package org.drools.eclipse.editors;
02:
03: import org.drools.eclipse.DroolsEclipsePlugin;
04: import org.drools.eclipse.debug.core.IDroolsDebugConstants;
05: import org.eclipse.core.resources.IMarker;
06: import org.eclipse.core.resources.IResource;
07: import org.eclipse.core.runtime.CoreException;
08: import org.eclipse.jface.text.BadLocationException;
09: import org.eclipse.jface.text.Position;
10: import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
11:
12: /**
13: * Drools annotation model.
14: *
15: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
16: */
17: public class DRLAnnotationModel extends ResourceMarkerAnnotationModel {
18:
19: public DRLAnnotationModel(IResource resource) {
20: super (resource);
21: }
22:
23: protected Position createPositionFromMarker(IMarker marker) {
24: try {
25: if (!marker.getType().equals(
26: IDroolsDebugConstants.DROOLS_MARKER_TYPE)) {
27: return super .createPositionFromMarker(marker);
28: }
29: int line = marker.getAttribute(
30: IDroolsDebugConstants.DRL_LINE_NUMBER, -1);
31: try {
32: return new Position(fDocument.getLineOffset(line - 1));
33: } catch (BadLocationException exc) {
34: return super .createPositionFromMarker(marker);
35: }
36: } catch (CoreException exc) {
37: DroolsEclipsePlugin.log(exc);
38: return null;
39: }
40: }
41: }
|