Search in sources :

Example 1 with ProgressLoaderVisualizer

use of org.jkiss.dbeaver.ui.controls.ProgressLoaderVisualizer in project dbeaver by dbeaver.

the class ResultSetJobDataRead method run.

@Override
protected IStatus run(DBRProgressMonitor monitor) {
    error = null;
    final ProgressLoaderVisualizer<Object> visualizer = new ProgressLoaderVisualizer<>(this, progressControl);
    DBRProgressMonitor progressMonitor = visualizer.overwriteMonitor(monitor);
    DBCExecutionPurpose purpose = dataFilter != null && dataFilter.hasFilters() ? DBCExecutionPurpose.USER_FILTERED : DBCExecutionPurpose.USER;
    new PumpVisualizer(visualizer).schedule(PROGRESS_VISUALIZE_PERIOD * 2);
    try (DBCSession session = getExecutionContext().openSession(progressMonitor, purpose, NLS.bind(CoreMessages.controls_rs_pump_job_context_name, dataContainer.toString()))) {
        DBUtils.tryExecuteRecover(monitor, getDataContainer().getDataSource(), monitor1 -> {
            try {
                statistics = dataContainer.readData(ResultSetJobDataRead.this, session, controller.getDataReceiver(), dataFilter, offset, maxRows, DBSDataContainer.FLAG_READ_PSEUDO);
            } catch (Throwable e) {
                throw new InvocationTargetException(e);
            }
        });
    } catch (DBException e) {
        error = e;
    } finally {
        visualizer.completeLoading(null);
    }
    return Status.OK_STATUS;
}
Also used : DBException(org.jkiss.dbeaver.DBException) ProgressLoaderVisualizer(org.jkiss.dbeaver.ui.controls.ProgressLoaderVisualizer) DBCExecutionPurpose(org.jkiss.dbeaver.model.exec.DBCExecutionPurpose) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) DBCSession(org.jkiss.dbeaver.model.exec.DBCSession)

Example 2 with ProgressLoaderVisualizer

use of org.jkiss.dbeaver.ui.controls.ProgressLoaderVisualizer in project dbeaver by serge-rider.

the class ResultSetJobDataRead method run.

@Override
protected IStatus run(DBRProgressMonitor monitor) {
    error = null;
    final ProgressLoaderVisualizer<Object> visualizer = new ProgressLoaderVisualizer<>(this, progressControl);
    DBRProgressMonitor progressMonitor = visualizer.overwriteMonitor(monitor);
    new PumpVisualizer(visualizer).schedule(PROGRESS_VISUALIZE_PERIOD * 2);
    long fetchFlags = DBSDataContainer.FLAG_READ_PSEUDO;
    if (offset > 0) {
        fetchFlags |= DBSDataContainer.FLAG_FETCH_SEGMENT;
    }
    if (offset > 0 && getExecutionContext().getDataSource().getContainer().getPreferenceStore().getBoolean(ModelPreferences.RESULT_SET_REREAD_ON_SCROLLING)) {
        if (maxRows > 0) {
            maxRows += offset;
        }
        offset = 0;
    }
    if (refresh) {
        fetchFlags |= DBSDataContainer.FLAG_REFRESH;
    }
    long finalFlags = fetchFlags;
    DBCExecutionPurpose purpose = dataFilter != null && dataFilter.hasFilters() ? DBCExecutionPurpose.USER_FILTERED : DBCExecutionPurpose.USER;
    progressMonitor.beginTask("Read data", 1);
    try (DBCSession session = getExecutionContext().openSession(progressMonitor, purpose, NLS.bind(ResultSetMessages.controls_rs_pump_job_context_name, dataContainer.toString()))) {
        progressMonitor.subTask("Read data from container");
        DBExecUtils.tryExecuteRecover(monitor, session.getDataSource(), monitor1 -> {
            try {
                statistics = dataContainer.readData(ResultSetJobDataRead.this, session, controller.getDataReceiver(), dataFilter, offset, maxRows, finalFlags, 0);
            } catch (Throwable e) {
                throw new InvocationTargetException(e);
            }
        });
    } catch (Throwable e) {
        error = e;
    } finally {
        visualizer.completeLoading(null);
        progressMonitor.done();
    }
    return Status.OK_STATUS;
}
Also used : ProgressLoaderVisualizer(org.jkiss.dbeaver.ui.controls.ProgressLoaderVisualizer) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with ProgressLoaderVisualizer

use of org.jkiss.dbeaver.ui.controls.ProgressLoaderVisualizer in project dbeaver by serge-rider.

the class SessionManagerViewer method loadPlainTextDetails.

private void loadPlainTextDetails(DBAServerSessionDetails data, StyledText styledText) {
    SessionDetailsLoadService loadingService = new SessionDetailsLoadService(data);
    LoadingJob.createService(loadingService, new ProgressLoaderVisualizer<Collection<DBPObject>>(loadingService, styledText) {

        @Override
        public void completeLoading(Collection<DBPObject> dbpObjects) {
            StringBuilder text = new StringBuilder();
            for (DBPObject item : dbpObjects) {
                if (item instanceof DBPObjectWithDescription) {
                    text.append(((DBPObjectWithDescription) item).getDescription());
                    text.append(GeneralUtils.getDefaultLineSeparator());
                }
            }
            styledText.setText(text.toString());
        }
    }).schedule();
}
Also used : DBPObject(org.jkiss.dbeaver.model.DBPObject) ProgressLoaderVisualizer(org.jkiss.dbeaver.ui.controls.ProgressLoaderVisualizer) DBPObjectWithDescription(org.jkiss.dbeaver.model.DBPObjectWithDescription)

Aggregations

ProgressLoaderVisualizer (org.jkiss.dbeaver.ui.controls.ProgressLoaderVisualizer)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)2 DBException (org.jkiss.dbeaver.DBException)1 DBPObject (org.jkiss.dbeaver.model.DBPObject)1 DBPObjectWithDescription (org.jkiss.dbeaver.model.DBPObjectWithDescription)1 DBCExecutionPurpose (org.jkiss.dbeaver.model.exec.DBCExecutionPurpose)1 DBCSession (org.jkiss.dbeaver.model.exec.DBCSession)1