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);
}
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;
}
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);
}
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;
}
Aggregations