Search in sources :

Example 1 with DBPRefreshableObject

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

the class ERDEditorEmbedded method loadDiagram.

@Override
protected synchronized void loadDiagram(final boolean refreshMetadata) {
    final DBSObject object = getRootObject();
    if (object == null) {
        return;
    }
    if (diagramLoadingJob != null) {
        // Do not start new one while old is running
        return;
    }
    diagramLoadingJob = LoadingJob.createService(new DatabaseLoadService<EntityDiagram>("Load diagram '" + object.getName() + "'", object.getDataSource()) {

        @Override
        public EntityDiagram evaluate(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            if (refreshMetadata && object instanceof DBPRefreshableObject) {
                try {
                    getEditorInput().getNavigatorNode().refreshNode(monitor, ERDEditorEmbedded.this);
                } catch (DBException e) {
                    log.warn("Error refreshing database metadata", e);
                }
            }
            try {
                return loadFromDatabase(monitor);
            } catch (DBException e) {
                log.error("Error loading ER diagram", e);
            }
            return null;
        }
    }, progressControl.createLoadVisualizer());
    diagramLoadingJob.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            diagramLoadingJob = null;
        }
    });
    diagramLoadingJob.schedule();
}
Also used : DBException(org.jkiss.dbeaver.DBException) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) DatabaseLoadService(org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) DBPRefreshableObject(org.jkiss.dbeaver.model.DBPRefreshableObject)

Aggregations

IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 DBException (org.jkiss.dbeaver.DBException)1 DBPRefreshableObject (org.jkiss.dbeaver.model.DBPRefreshableObject)1 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)1 DatabaseLoadService (org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService)1