Search in sources :

Example 21 with IBreakpoint

use of org.eclipse.debug.core.model.IBreakpoint in project erlide_eclipse by erlang.

the class ErlangDebugOptionsManager method updateBreakpointsMessages.

/**
 * Updates message attributes on the given erlang breakpoints.
 */
private void updateBreakpointsMessages(final IBreakpoint[] breakpoints) {
    final IWorkspaceRunnable runnable = new IWorkspaceRunnable() {

        @Override
        public void run(final IProgressMonitor monitor) throws CoreException {
            for (final IBreakpoint breakpoint : breakpoints) {
                if (breakpoint instanceof IErlangBreakpoint) {
                    final IErlangBreakpoint erlangBreakpoint = (IErlangBreakpoint) breakpoint;
                    final String message = erlangBreakpoint.getMessage();
                    breakpoint.getMarker().setAttribute(IMarker.MESSAGE, message);
                }
            }
        }
    };
    try {
        ResourcesPlugin.getWorkspace().run(runnable, null, 0, null);
    } catch (final CoreException e) {
        ErlLogger.error(e);
    }
}
Also used : IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 22 with IBreakpoint

use of org.eclipse.debug.core.model.IBreakpoint in project webtools.sourceediting by eclipse.

the class ManageBreakpointAction method update.

public void update() {
    // doEnable means "enable" instead of "disable"
    doEnable = true;
    breakpoints = getBreakpoints(getMarkers());
    for (int i = 0; doEnable && i < breakpoints.length; i++) {
        IBreakpoint breakpoint = breakpoints[i];
        try {
            if (breakpoint.isEnabled()) {
                doEnable = false;
            }
        } catch (CoreException e) {
            // $NON-NLS-1$
            Logger.logException("breakpoint not responding to isEnabled: " + breakpoint, e);
        }
    }
    setEnabled(breakpoints != null && breakpoints.length > 0);
    if (doEnable)
        // $NON-NLS-1$
        setText(SSEUIMessages.ManageBreakpointAction_0);
    else
        // $NON-NLS-1$
        setText(SSEUIMessages.ManageBreakpointAction_1);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 23 with IBreakpoint

use of org.eclipse.debug.core.model.IBreakpoint in project webtools.sourceediting by eclipse.

the class ToggleBreakpointsTarget method toggleLineBreakpoints.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart,
	 *      org.eclipse.jface.viewers.ISelection)
	 */
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    ITextEditor editor = part.getAdapter(ITextEditor.class);
    if (selection instanceof ITextSelection) {
        ITextSelection textSelection = (ITextSelection) selection;
        IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
        int lineNumber = -1;
        try {
            lineNumber = document.getLineOfOffset(textSelection.getOffset());
        } catch (BadLocationException e) {
        }
        if (lineNumber >= 0) {
            ToggleBreakpointAction toggler = new ToggleBreakpointAction(editor, null);
            toggler.update();
            if (toggler.isEnabled()) {
                IResource resource = toggler.getResource();
                AbstractMarkerAnnotationModel model = toggler.getAnnotationModel();
                IBreakpoint[] breakpoints = getBreakpoints(resource, document, model, lineNumber);
                if (breakpoints.length > 0) {
                    IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
                    for (int i = 0; i < breakpoints.length; i++) {
                        breakpoints[i].getMarker().delete();
                        breakpointManager.removeBreakpoint(breakpoints[i], true);
                    }
                } else {
                    toggler.createBreakpoints(lineNumber + 1);
                }
            }
        }
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) AbstractMarkerAnnotationModel(org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel) IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) ITextSelection(org.eclipse.jface.text.ITextSelection) IDocument(org.eclipse.jface.text.IDocument) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) BadLocationException(org.eclipse.jface.text.BadLocationException) IResource(org.eclipse.core.resources.IResource)

Example 24 with IBreakpoint

use of org.eclipse.debug.core.model.IBreakpoint in project webtools.sourceediting by eclipse.

the class XSLBreakpointProvider method addBreakpoint.

public IStatus addBreakpoint(IDocument document, IEditorInput input, int editorLineNumber, int offset) throws CoreException {
    // check if there is a valid position to set breakpoint
    int pos = getValidPosition(document, editorLineNumber);
    IStatus status = null;
    if (pos >= 0) {
        IResource res = getResourceFromInput(input);
        if (res != null) {
            boolean add = true;
            if (add) {
                IBreakpoint point = new XSLLineBreakpoint(res, editorLineNumber, pos, pos);
                if (point == null) {
                    status = new Status(IStatus.ERROR, XSLDebugUIPlugin.PLUGIN_ID, IStatus.ERROR, Messages.XSLBreakpointProvider_0, null);
                } else {
                // DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(point);
                }
            }
        } else if (input instanceof IStorageEditorInput) {
            res = ResourcesPlugin.getWorkspace().getRoot();
            String id = input.getName();
            if (input instanceof IStorageEditorInput && ((IStorageEditorInput) input).getStorage() != null && ((IStorageEditorInput) input).getStorage().getFullPath() != null) {
                id = ((IStorageEditorInput) input).getStorage().getFullPath().toString();
            }
            Map<String, String> attributes = new HashMap<String, String>();
            attributes.put(StructuredResourceMarkerAnnotationModel.SECONDARY_ID_KEY, id);
            IBreakpoint point = new XSLLineBreakpoint(res, editorLineNumber, pos, pos);
            if (point == null) {
                status = new Status(IStatus.ERROR, XSLDebugUIPlugin.PLUGIN_ID, IStatus.ERROR, Messages.XSLBreakpointProvider_0, null);
            }
        }
    }
    if (status == null) {
        status = new Status(IStatus.OK, XSLDebugUIPlugin.PLUGIN_ID, IStatus.OK, "JSPUIMessages.OK", // $NON-NLS-1$
        null);
    }
    return status;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) IStorageEditorInput(org.eclipse.ui.IStorageEditorInput) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) HashMap(java.util.HashMap) Map(java.util.Map) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) XSLLineBreakpoint(org.eclipse.wst.xsl.launching.model.XSLLineBreakpoint) IResource(org.eclipse.core.resources.IResource) XSLLineBreakpoint(org.eclipse.wst.xsl.launching.model.XSLLineBreakpoint)

Example 25 with IBreakpoint

use of org.eclipse.debug.core.model.IBreakpoint in project webtools.sourceediting by eclipse.

the class XSLLineBreakpointAdapter method toggleLineBreakpoints.

public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    ITextEditor textEditor = getEditor(part);
    if (textEditor != null) {
        IResource resource = (IResource) textEditor.getEditorInput().getAdapter(IResource.class);
        ITextSelection textSelection = (ITextSelection) selection;
        int lineNumber = textSelection.getStartLine();
        IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IXSLConstants.ID_XSL_DEBUG_MODEL);
        for (IBreakpoint breakpoint : breakpoints) {
            if (resource.equals(breakpoint.getMarker().getResource())) {
                if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
                    // remove
                    breakpoint.delete();
                    return;
                }
            }
        }
        // create line breakpoint (doc line numbers start at 0)
        XSLLineBreakpoint lineBreakpoint = new XSLLineBreakpoint(resource, lineNumber + 1, 1, 1);
        DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IResource(org.eclipse.core.resources.IResource) ITextSelection(org.eclipse.jface.text.ITextSelection) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) XSLLineBreakpoint(org.eclipse.wst.xsl.launching.model.XSLLineBreakpoint) XSLLineBreakpoint(org.eclipse.wst.xsl.launching.model.XSLLineBreakpoint)

Aggregations

IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)36 CoreException (org.eclipse.core.runtime.CoreException)12 IBreakpointManager (org.eclipse.debug.core.IBreakpointManager)12 Breakpoint (nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint)9 IResource (org.eclipse.core.resources.IResource)9 ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)9 ArrayList (java.util.ArrayList)6 IJavaBreakpoint (org.eclipse.jdt.debug.core.IJavaBreakpoint)6 IJavaLineBreakpoint (org.eclipse.jdt.debug.core.IJavaLineBreakpoint)6 IStatus (org.eclipse.core.runtime.IStatus)5 ITextSelection (org.eclipse.jface.text.ITextSelection)5 Test (org.junit.Test)5 Breakpoint (freemarker.debug.Breakpoint)4 IMarker (org.eclipse.core.resources.IMarker)4 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)4 ErlangLineBreakpoint (org.erlide.backend.debug.ErlangLineBreakpoint)4 RemoteException (java.rmi.RemoteException)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3