Search in sources :

Example 1 with IDatabaseBreakpoint

use of org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint in project dbeaver by serge-rider.

the class ToggleProcedureBreakpointTarget method toggleLineBreakpoints.

@Override
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    IEditorPart editorPart = (IEditorPart) part;
    IResource resource = extractResource(editorPart, selection);
    if (resource == null) {
        return;
    }
    DBSObject databaseObject = DebugUI.extractDatabaseObject(editorPart);
    if (databaseObject == null) {
        return;
    }
    DBNDatabaseNode node = DBWorkbench.getPlatform().getNavigatorModel().getNodeByObject(new VoidProgressMonitor(), databaseObject, false);
    if (node == null) {
        return;
    }
    String nodeItemPath = node.getNodeItemPath();
    ITextSelection textSelection = (ITextSelection) selection;
    int lineNumber = textSelection.getStartLine();
    IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(DBGConstants.MODEL_IDENTIFIER_DATABASE);
    for (IBreakpoint breakpoint : breakpoints) {
        if (breakpoint instanceof IDatabaseBreakpoint) {
            IDatabaseBreakpoint databaseBreakpoint = (IDatabaseBreakpoint) breakpoint;
            if (nodeItemPath.equals(databaseBreakpoint.getNodePath())) {
                if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
                    DebugUITools.deleteBreakpoints(new IBreakpoint[] { breakpoint }, part.getSite().getShell(), null);
                    return;
                }
            }
        }
    }
    int charstart = -1, charend = -1;
    DBGBreakpointDescriptor breakpointDescriptor = GeneralUtils.adapt(databaseObject, DBGBreakpointDescriptor.class);
    if (breakpointDescriptor == null) {
        throw new CoreException(GeneralUtils.makeErrorStatus("Object '" + DBUtils.getObjectFullName(databaseObject, DBPEvaluationContext.UI) + "' doesn't support breakpoints"));
    }
    // create line breakpoint (doc line numbers start at 0)
    new DatabaseLineBreakpoint(databaseObject, node, resource, breakpointDescriptor, lineNumber + 1, charstart, charend, true);
}
Also used : DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint) IEditorPart(org.eclipse.ui.IEditorPart) DBGBreakpointDescriptor(org.jkiss.dbeaver.debug.DBGBreakpointDescriptor) ITextSelection(org.eclipse.jface.text.ITextSelection) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) CoreException(org.eclipse.core.runtime.CoreException) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IResource(org.eclipse.core.resources.IResource)

Example 2 with IDatabaseBreakpoint

use of org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint in project dbeaver by serge-rider.

the class DatabaseDebugModelPresentation method getEditorInput.

@Override
public IEditorInput getEditorInput(Object element) {
    if (element instanceof DBNDatabaseNode) {
        DBNDatabaseNode databaseNode = (DBNDatabaseNode) element;
        return createEditorInput(databaseNode);
    }
    if (element instanceof IDatabaseBreakpoint) {
        IDatabaseBreakpoint breakpoint = (IDatabaseBreakpoint) element;
        try {
            String nodePath = breakpoint.getNodePath();
            DBNModel navigatorModel = DBWorkbench.getPlatform().getNavigatorModel();
            DBNNode node = navigatorModel.getNodeByPath(new VoidProgressMonitor(), nodePath);
            if (node instanceof DBNDatabaseNode) {
                DBNDatabaseNode databaseNode = (DBNDatabaseNode) node;
                return createEditorInput(databaseNode);
            }
        } catch (Exception e) {
            String message = NLS.bind("Unable to resolve editor input for breakpoint {0}", breakpoint);
            log.error(message, e);
        }
    }
    return null;
}
Also used : DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) CoreException(org.eclipse.core.runtime.CoreException) DebugException(org.eclipse.debug.core.DebugException) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

Example 3 with IDatabaseBreakpoint

use of org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint in project dbeaver by dbeaver.

the class ToggleProcedureBreakpointTarget method toggleLineBreakpoints.

@Override
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    IEditorPart editorPart = (IEditorPart) part;
    IResource resource = extractResource(editorPart, selection);
    if (resource == null) {
        return;
    }
    DBSObject databaseObject = DebugUI.extractDatabaseObject(editorPart);
    if (databaseObject == null) {
        return;
    }
    DBNDatabaseNode node = DBWorkbench.getPlatform().getNavigatorModel().getNodeByObject(new VoidProgressMonitor(), databaseObject, false);
    if (node == null) {
        return;
    }
    String nodeItemPath = node.getNodeItemPath();
    ITextSelection textSelection = (ITextSelection) selection;
    int lineNumber = textSelection.getStartLine();
    IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(DBGConstants.MODEL_IDENTIFIER_DATABASE);
    for (IBreakpoint breakpoint : breakpoints) {
        if (breakpoint instanceof IDatabaseBreakpoint) {
            IDatabaseBreakpoint databaseBreakpoint = (IDatabaseBreakpoint) breakpoint;
            if (nodeItemPath.equals(databaseBreakpoint.getNodePath())) {
                if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
                    DebugUITools.deleteBreakpoints(new IBreakpoint[] { breakpoint }, part.getSite().getShell(), null);
                    return;
                }
            }
        }
    }
    int charstart = -1, charend = -1;
    DBGBreakpointDescriptor breakpointDescriptor = GeneralUtils.adapt(databaseObject, DBGBreakpointDescriptor.class);
    if (breakpointDescriptor == null) {
        throw new CoreException(GeneralUtils.makeErrorStatus("Object '" + DBUtils.getObjectFullName(databaseObject, DBPEvaluationContext.UI) + "' doesn't support breakpoints"));
    }
    // create line breakpoint (doc line numbers start at 0)
    new DatabaseLineBreakpoint(databaseObject, node, resource, breakpointDescriptor, lineNumber + 1, charstart, charend, true);
}
Also used : DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint) IEditorPart(org.eclipse.ui.IEditorPart) DBGBreakpointDescriptor(org.jkiss.dbeaver.debug.DBGBreakpointDescriptor) ITextSelection(org.eclipse.jface.text.ITextSelection) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) CoreException(org.eclipse.core.runtime.CoreException) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IResource(org.eclipse.core.resources.IResource)

Example 4 with IDatabaseBreakpoint

use of org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint in project dbeaver by dbeaver.

the class DatabaseDebugModelPresentation method getEditorInput.

@Override
public IEditorInput getEditorInput(Object element) {
    if (element instanceof DBNDatabaseNode) {
        DBNDatabaseNode databaseNode = (DBNDatabaseNode) element;
        return createEditorInput(databaseNode);
    }
    if (element instanceof IDatabaseBreakpoint) {
        IDatabaseBreakpoint breakpoint = (IDatabaseBreakpoint) element;
        try {
            String nodePath = breakpoint.getNodePath();
            DBNModel navigatorModel = DBWorkbench.getPlatform().getNavigatorModel();
            DBNNode node = navigatorModel.getNodeByPath(new VoidProgressMonitor(), nodePath);
            if (node instanceof DBNDatabaseNode) {
                DBNDatabaseNode databaseNode = (DBNDatabaseNode) node;
                return createEditorInput(databaseNode);
            }
        } catch (Exception e) {
            String message = NLS.bind("Unable to resolve editor input for breakpoint {0}", breakpoint);
            log.error(message, e);
        }
    }
    return null;
}
Also used : DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) CoreException(org.eclipse.core.runtime.CoreException) DebugException(org.eclipse.debug.core.DebugException) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)4 IDatabaseBreakpoint (org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint)4 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)4 VoidProgressMonitor (org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)4 IResource (org.eclipse.core.resources.IResource)2 DebugException (org.eclipse.debug.core.DebugException)2 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)2 ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)2 ITextSelection (org.eclipse.jface.text.ITextSelection)2 IEditorPart (org.eclipse.ui.IEditorPart)2 DBGBreakpointDescriptor (org.jkiss.dbeaver.debug.DBGBreakpointDescriptor)2 DatabaseLineBreakpoint (org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint)2 DBNModel (org.jkiss.dbeaver.model.navigator.DBNModel)2 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2