Search in sources :

Example 1 with DatabaseStackFrame

use of org.jkiss.dbeaver.debug.core.model.DatabaseStackFrame in project dbeaver by serge-rider.

the class DebugUtils method getSourceName.

public static String getSourceName(Object object) throws CoreException {
    if (object instanceof DatabaseStackFrame) {
        DatabaseStackFrame frame = (DatabaseStackFrame) object;
        Object sourceIdentifier = frame.getSourceIdentifier();
        DBSObject dbsObject;
        try {
            dbsObject = findDatabaseObject(frame.getController(), sourceIdentifier, new VoidProgressMonitor());
        } catch (DBException e) {
            Status error = DebugUtils.newErrorStatus(e.getMessage(), e);
            throw new CoreException(error);
        }
        if (dbsObject == null) {
            return null;
        }
        final DBNModel navigatorModel = DBWorkbench.getPlatform().getNavigatorModel();
        DBNDatabaseNode node = navigatorModel.getNodeByObject(new VoidProgressMonitor(), dbsObject, false);
        if (node != null) {
            return node.getNodeItemPath();
        }
    }
    if (object instanceof String) {
        // well, let's be positive and assume it's a node path already
        return (String) object;
    }
    return null;
}
Also used : DatabaseStackFrame(org.jkiss.dbeaver.debug.core.model.DatabaseStackFrame) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBException(org.jkiss.dbeaver.DBException) CoreException(org.eclipse.core.runtime.CoreException) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

Example 2 with DatabaseStackFrame

use of org.jkiss.dbeaver.debug.core.model.DatabaseStackFrame in project dbeaver by dbeaver.

the class DebugUtils method getSourceName.

public static String getSourceName(Object object) throws CoreException {
    if (object instanceof DatabaseStackFrame) {
        DatabaseStackFrame frame = (DatabaseStackFrame) object;
        Object sourceIdentifier = frame.getSourceIdentifier();
        DBSObject dbsObject;
        try {
            dbsObject = findDatabaseObject(frame.getController(), sourceIdentifier, new VoidProgressMonitor());
        } catch (DBException e) {
            Status error = DebugUtils.newErrorStatus(e.getMessage(), e);
            throw new CoreException(error);
        }
        if (dbsObject == null) {
            return null;
        }
        final DBNModel navigatorModel = DBWorkbench.getPlatform().getNavigatorModel();
        DBNDatabaseNode node = navigatorModel.getNodeByObject(new VoidProgressMonitor(), dbsObject, false);
        if (node != null) {
            return node.getNodeItemPath();
        }
    }
    if (object instanceof String) {
        // well, let's be positive and assume it's a node path already
        return (String) object;
    }
    return null;
}
Also used : DatabaseStackFrame(org.jkiss.dbeaver.debug.core.model.DatabaseStackFrame) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBException(org.jkiss.dbeaver.DBException) CoreException(org.eclipse.core.runtime.CoreException) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

Example 3 with DatabaseStackFrame

use of org.jkiss.dbeaver.debug.core.model.DatabaseStackFrame in project dbeaver by dbeaver.

the class DebugCore method getSourceName.

public static String getSourceName(Object object) throws CoreException {
    if (object instanceof DatabaseStackFrame) {
        DatabaseStackFrame frame = (DatabaseStackFrame) object;
        Object sourceIdentifier = frame.getSourceIdentifier();
        DatabaseDebugTarget debugTarget = frame.getDatabaseDebugTarget();
        DBSObject dbsObject = null;
        try {
            dbsObject = debugTarget.findDatabaseObject(sourceIdentifier, new VoidProgressMonitor());
        } catch (DBException e) {
            Status error = DebugCore.newErrorStatus(e.getMessage(), e);
            throw new CoreException(error);
        }
        if (dbsObject == null) {
            return null;
        }
        final DBNModel navigatorModel = DBeaverCore.getInstance().getNavigatorModel();
        DBNDatabaseNode node = navigatorModel.getNodeByObject(dbsObject);
        if (node != null) {
            return node.getNodeItemPath();
        }
    }
    if (object instanceof String) {
        // well, let's be positive and assume it's a node path already
        return (String) object;
    }
    return null;
}
Also used : DatabaseStackFrame(org.jkiss.dbeaver.debug.core.model.DatabaseStackFrame) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBException(org.jkiss.dbeaver.DBException) DatabaseDebugTarget(org.jkiss.dbeaver.debug.core.model.DatabaseDebugTarget) CoreException(org.eclipse.core.runtime.CoreException) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 DBException (org.jkiss.dbeaver.DBException)3 DatabaseStackFrame (org.jkiss.dbeaver.debug.core.model.DatabaseStackFrame)3 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)3 DBNModel (org.jkiss.dbeaver.model.navigator.DBNModel)3 VoidProgressMonitor (org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)3 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)3 DatabaseDebugTarget (org.jkiss.dbeaver.debug.core.model.DatabaseDebugTarget)1