Search in sources :

Example 1 with DatabaseLineBreakpoint

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

the class DatabaseDebugModelPresentation method getText.

@Override
public String getText(Object element) {
    // FIXME:AF: register adapters
    try {
        if (element instanceof IDatabaseDebugTarget) {
            IDatabaseDebugTarget databaseDebugTarget = (IDatabaseDebugTarget) element;
            return databaseDebugTarget.getName();
        }
        if (element instanceof DatabaseProcess) {
            DatabaseProcess process = (DatabaseProcess) element;
            return process.getLabel();
        }
        if (element instanceof DatabaseThread) {
            DatabaseThread thread = (DatabaseThread) element;
            return thread.getName();
        }
        if (element instanceof DatabaseStackFrame) {
            DatabaseStackFrame stackFrame = (DatabaseStackFrame) element;
            return stackFrame.getName();
        }
        if (element instanceof DatabaseVariable) {
            DatabaseVariable variable = (DatabaseVariable) element;
            return variable.getName();
        }
        if (element instanceof DatabaseLineBreakpoint) {
            DatabaseLineBreakpoint breakpoint = (DatabaseLineBreakpoint) element;
            String database = breakpoint.getDatabaseName();
            String schema = breakpoint.getSchemaName();
            String procedure = breakpoint.getProcedureName();
            int lineNumber = breakpoint.getLineNumber();
            String pattern = "{0}.{1}.{2} - [line:{3}]";
            Object[] bindings = new Object[] { database, schema, procedure, lineNumber };
            return NLS.bind(pattern, bindings);
        }
    } catch (CoreException e) {
        return "<not responding>";
    }
    return labelProvider.getText(element);
}
Also used : IDatabaseDebugTarget(org.jkiss.dbeaver.debug.core.model.IDatabaseDebugTarget) DatabaseStackFrame(org.jkiss.dbeaver.debug.core.model.DatabaseStackFrame) DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint) CoreException(org.eclipse.core.runtime.CoreException) DatabaseThread(org.jkiss.dbeaver.debug.core.model.DatabaseThread) DBPScriptObject(org.jkiss.dbeaver.model.DBPScriptObject) DatabaseVariable(org.jkiss.dbeaver.debug.core.model.DatabaseVariable) DatabaseProcess(org.jkiss.dbeaver.debug.core.model.DatabaseProcess) DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint)

Example 2 with DatabaseLineBreakpoint

use of org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint 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 = DBeaverCore.getInstance().getNavigatorModel().getNodeByObject(databaseObject);
    if (node == null) {
        return;
    }
    String nodeItemPath = node.getNodeItemPath();
    ITextSelection textSelection = (ITextSelection) selection;
    int lineNumber = textSelection.getStartLine();
    IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(DebugCore.MODEL_IDENTIFIER_DATABASE);
    for (int i = 0; i < breakpoints.length; i++) {
        IBreakpoint breakpoint = breakpoints[i];
        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;
    // create line breakpoint (doc line numbers start at 0)
    new DatabaseLineBreakpoint(databaseObject, node, resource, lineNumber + 1, charstart, charend, true);
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint) IEditorPart(org.eclipse.ui.IEditorPart) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) 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) DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint)

Aggregations

DatabaseLineBreakpoint (org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint)2 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)1 ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)1 ITextSelection (org.eclipse.jface.text.ITextSelection)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IDatabaseBreakpoint (org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint)1 DatabaseProcess (org.jkiss.dbeaver.debug.core.model.DatabaseProcess)1 DatabaseStackFrame (org.jkiss.dbeaver.debug.core.model.DatabaseStackFrame)1 DatabaseThread (org.jkiss.dbeaver.debug.core.model.DatabaseThread)1 DatabaseVariable (org.jkiss.dbeaver.debug.core.model.DatabaseVariable)1 IDatabaseDebugTarget (org.jkiss.dbeaver.debug.core.model.IDatabaseDebugTarget)1 DBPScriptObject (org.jkiss.dbeaver.model.DBPScriptObject)1 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)1 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)1