Search in sources :

Example 6 with AbstractMarkerAnnotationModel

use of org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel in project webtools.sourceediting by eclipse.

the class BreakpointRulerAction method hasMarkers.

protected boolean hasMarkers() {
    IResource resource = getResource();
    IDocument document = getDocument();
    AbstractMarkerAnnotationModel model = getAnnotationModel();
    if (resource != null && model != null && resource.exists()) {
        try {
            IMarker[] allMarkers = resource.findMarkers(IBreakpoint.LINE_BREAKPOINT_MARKER, true, IResource.DEPTH_ZERO);
            if (allMarkers != null) {
                for (int i = 0; i < allMarkers.length; i++) {
                    if (includesRulerLine(model.getMarkerPosition(allMarkers[i]), document)) {
                        return true;
                    }
                }
            }
        } catch (CoreException x) {
        // 
        }
    }
    return false;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) AbstractMarkerAnnotationModel(org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel) IMarker(org.eclipse.core.resources.IMarker) IResource(org.eclipse.core.resources.IResource) IDocument(org.eclipse.jface.text.IDocument) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 7 with AbstractMarkerAnnotationModel

use of org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel in project webtools.sourceediting by eclipse.

the class BreakpointRulerAction method getAnnotationModel.

/**
 * Returns the <code>AbstractMarkerAnnotationModel</code> of the
 * editor's input.
 *
 * @return the marker annotation model
 */
protected AbstractMarkerAnnotationModel getAnnotationModel() {
    IDocumentProvider provider = fTextEditor.getDocumentProvider();
    IAnnotationModel model = provider.getAnnotationModel(fTextEditor.getEditorInput());
    if (model instanceof AbstractMarkerAnnotationModel)
        return (AbstractMarkerAnnotationModel) model;
    return null;
}
Also used : IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) AbstractMarkerAnnotationModel(org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel)

Example 8 with AbstractMarkerAnnotationModel

use of org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel in project webtools.sourceediting by eclipse.

the class BreakpointRulerAction method getMarkers.

/**
 * Returns all breakpoint markers which include the ruler's line of activity.
 *
 * @return an array of markers which include the ruler's line of activity
 */
protected IMarker[] getMarkers() {
    List markers = new ArrayList();
    IResource resource = getResource();
    IDocument document = getDocument();
    AbstractMarkerAnnotationModel annotationModel = getAnnotationModel();
    if (resource != null && annotationModel != null && resource.exists()) {
        try {
            IMarker[] allMarkers = resource.findMarkers(IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_ZERO);
            if (allMarkers != null) {
                for (int i = 0; i < allMarkers.length; i++) {
                    if (includesRulerLine(annotationModel.getMarkerPosition(allMarkers[i]), document)) {
                        markers.add(allMarkers[i]);
                    }
                }
            }
        } catch (CoreException x) {
        // 
        }
    }
    return (IMarker[]) markers.toArray(new IMarker[0]);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) AbstractMarkerAnnotationModel(org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IMarker(org.eclipse.core.resources.IMarker) IResource(org.eclipse.core.resources.IResource) IDocument(org.eclipse.jface.text.IDocument) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Aggregations

AbstractMarkerAnnotationModel (org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel)8 IResource (org.eclipse.core.resources.IResource)4 IDocument (org.eclipse.jface.text.IDocument)4 CoreException (org.eclipse.core.runtime.CoreException)3 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)3 IFileEditorInput (org.eclipse.ui.IFileEditorInput)3 IMarker (org.eclipse.core.resources.IMarker)2 BadLocationException (org.eclipse.jface.text.BadLocationException)2 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IFileInfo (org.eclipse.core.filesystem.IFileInfo)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IBreakpointManager (org.eclipse.debug.core.IBreakpointManager)1 IRegion (org.eclipse.jface.text.IRegion)1 ITextSelection (org.eclipse.jface.text.ITextSelection)1 Point (org.eclipse.swt.graphics.Point)1 IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)1 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)1 MarkerAnnotation (org.eclipse.ui.texteditor.MarkerAnnotation)1