Search in sources :

Example 1 with StandardErrorDialog

use of org.jkiss.dbeaver.ui.dialogs.StandardErrorDialog in project dbeaver by serge-rider.

the class DBeaverUI method showError.

@Override
public UserResponse showError(@NotNull final String title, @Nullable final String message, @NotNull final IStatus status) {
    IStatus rootStatus = status;
    for (IStatus s = status; s != null; ) {
        if (s.getException() instanceof DBException) {
            UserResponse dbErrorResp = showDatabaseError(message, (DBException) s.getException());
            if (dbErrorResp != null) {
                // If this DB error was handled by some DB-specific way then just don't care about it
                return dbErrorResp;
            }
            break;
        }
        if (s.getChildren() != null && s.getChildren().length > 0) {
            s = rootStatus = s.getChildren()[0];
        } else {
            break;
        }
    }
    log.error(rootStatus.getMessage(), rootStatus.getException());
    // log.debug(message);
    Runnable runnable = () -> {
        // Display the dialog
        StandardErrorDialog dialog = new StandardErrorDialog(UIUtils.getActiveWorkbenchShell(), title, message, status, IStatus.ERROR);
        dialog.open();
    };
    UIUtils.syncExec(runnable);
    return UserResponse.OK;
}
Also used : DBException(org.jkiss.dbeaver.DBException) IStatus(org.eclipse.core.runtime.IStatus) StandardErrorDialog(org.jkiss.dbeaver.ui.dialogs.StandardErrorDialog)

Example 2 with StandardErrorDialog

use of org.jkiss.dbeaver.ui.dialogs.StandardErrorDialog in project dbeaver by dbeaver.

the class DBeaverUI method showError.

@Override
public UserResponse showError(@NotNull final String title, @Nullable final String message, @NotNull final IStatus status) {
    IStatus rootStatus = status;
    for (IStatus s = status; s != null; ) {
        if (s.getException() instanceof DBException) {
            UserResponse dbErrorResp = showDatabaseError(message, (DBException) s.getException());
            if (dbErrorResp != null) {
                // If this DB error was handled by some DB-specific way then just don't care about it
                return dbErrorResp;
            }
            break;
        }
        if (s.getChildren() != null && s.getChildren().length > 0) {
            s = rootStatus = s.getChildren()[0];
        } else {
            break;
        }
    }
    log.error(rootStatus.getMessage(), rootStatus.getException());
    // log.debug(message);
    Runnable runnable = () -> {
        // Display the dialog
        StandardErrorDialog dialog = new StandardErrorDialog(UIUtils.getActiveWorkbenchShell(), title, message, status, IStatus.ERROR);
        dialog.open();
    };
    UIUtils.syncExec(runnable);
    return UserResponse.OK;
}
Also used : DBException(org.jkiss.dbeaver.DBException) IStatus(org.eclipse.core.runtime.IStatus) StandardErrorDialog(org.jkiss.dbeaver.ui.dialogs.StandardErrorDialog)

Example 3 with StandardErrorDialog

use of org.jkiss.dbeaver.ui.dialogs.StandardErrorDialog in project dbeaver by serge-rider.

the class UIUtils method showErrorDialog.

public static void showErrorDialog(@Nullable final Shell shell, @NotNull final String title, @Nullable final String message, @NotNull final IStatus status) {
    for (IStatus s = status; s != null; ) {
        if (s.getException() instanceof DBException) {
            if (showDatabaseError(shell, title, message, (DBException) s.getException())) {
                // If this DB error was handled by some DB-specific way then just don't care about it
                return;
            }
            break;
        }
        if (s.getChildren() != null && s.getChildren().length > 0) {
            s = s.getChildren()[0];
        } else {
            break;
        }
    }
    // log.debug(message);
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            // Display the dialog
            StandardErrorDialog dialog = new StandardErrorDialog(shell == null ? DBeaverUI.getActiveWorkbenchShell() : shell, title, message, RuntimeUtils.stripStack(status), IStatus.ERROR);
            dialog.open();
        }
    };
    DBeaverUI.syncExec(runnable);
}
Also used : DBException(org.jkiss.dbeaver.DBException) IStatus(org.eclipse.core.runtime.IStatus) StandardErrorDialog(org.jkiss.dbeaver.ui.dialogs.StandardErrorDialog)

Aggregations

IStatus (org.eclipse.core.runtime.IStatus)3 DBException (org.jkiss.dbeaver.DBException)3 StandardErrorDialog (org.jkiss.dbeaver.ui.dialogs.StandardErrorDialog)3