Search in sources :

Example 1 with XSLLineBreakpoint

use of org.eclipse.wst.xsl.launching.model.XSLLineBreakpoint 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 2 with XSLLineBreakpoint

use of org.eclipse.wst.xsl.launching.model.XSLLineBreakpoint 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

IResource (org.eclipse.core.resources.IResource)2 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)2 XSLLineBreakpoint (org.eclipse.wst.xsl.launching.model.XSLLineBreakpoint)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)1 ITextSelection (org.eclipse.jface.text.ITextSelection)1 IStorageEditorInput (org.eclipse.ui.IStorageEditorInput)1 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)1