Search in sources :

Example 1 with DefaultServerOutputReader

use of org.jkiss.dbeaver.model.impl.DefaultServerOutputReader in project dbeaver by serge-rider.

the class SQLEditor method runPostExecuteActions.

private void runPostExecuteActions(@Nullable SQLQueryResult result) {
    final DBCExecutionContext executionContext = getExecutionContext();
    if (executionContext != null) {
        final DBPDataSource dataSource = executionContext.getDataSource();
        // Dump server output
        DBCServerOutputReader outputReader = DBUtils.getAdapter(DBCServerOutputReader.class, dataSource);
        if (outputReader == null && result != null) {
            outputReader = new DefaultServerOutputReader(result);
        }
        if (outputReader != null && outputReader.isServerOutputEnabled()) {
            dumpServerOutput(executionContext, outputReader);
        }
        // Refresh active object
        if (result == null || !result.hasError() && getActivePreferenceStore().getBoolean(SQLPreferenceConstants.REFRESH_DEFAULTS_AFTER_EXECUTE)) {
            final DBSObjectSelector objectSelector = DBUtils.getAdapter(DBSObjectSelector.class, dataSource);
            if (objectSelector != null) {
                new AbstractJob("Refresh default object") {

                    @Override
                    protected IStatus run(DBRProgressMonitor monitor) {
                        try (DBCSession session = executionContext.openSession(monitor, DBCExecutionPurpose.UTIL, "Refresh default object")) {
                            objectSelector.refreshDefaultObject(session);
                        } catch (Exception e) {
                            log.error(e);
                        }
                        return Status.OK_STATUS;
                    }
                }.schedule();
            }
        }
    }
}
Also used : AbstractJob(org.jkiss.dbeaver.model.runtime.AbstractJob) DefaultServerOutputReader(org.jkiss.dbeaver.model.impl.DefaultServerOutputReader) DBSObjectSelector(org.jkiss.dbeaver.model.struct.DBSObjectSelector) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) DBException(org.jkiss.dbeaver.DBException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 DBException (org.jkiss.dbeaver.DBException)1 DefaultServerOutputReader (org.jkiss.dbeaver.model.impl.DefaultServerOutputReader)1 AbstractJob (org.jkiss.dbeaver.model.runtime.AbstractJob)1 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)1 DBSObjectSelector (org.jkiss.dbeaver.model.struct.DBSObjectSelector)1