Search in sources :

Example 1 with AbstractLoadService

use of org.jkiss.dbeaver.model.runtime.load.AbstractLoadService in project dbeaver by serge-rider.

the class ERDEditorStandalone method loadDiagram.

/*
    protected void createActions()
    {
        super.createActions();

        //addEditorAction(new SaveAction(this));
    }
*/
@Override
protected synchronized void loadDiagram(boolean refreshMetadata) {
    if (diagramLoadingJob != null) {
        // Do not start new one while old is running
        return;
    }
    diagramLoadingJob = LoadingJob.createService(new AbstractLoadService<EntityDiagram>("Load diagram '" + getEditorInput().getName() + "'") {

        @Override
        public EntityDiagram evaluate(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                return loadContentFromFile(monitor);
            } catch (DBException e) {
                log.error(e);
            }
            return null;
        }

        @Override
        public Object getFamily() {
            return ERDEditorStandalone.this;
        }
    }, progressControl.createLoadVisualizer());
    diagramLoadingJob.addJobChangeListener(new JobChangeAdapter() {

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

Example 2 with AbstractLoadService

use of org.jkiss.dbeaver.model.runtime.load.AbstractLoadService in project dbeaver by dbeaver.

the class LoadingJob method run.

private IStatus run(DBRProgressMonitor monitor, boolean lazy) {
    monitor = visualizer.overwriteMonitor(monitor);
    if (this.loadingService instanceof AbstractLoadService) {
        ((AbstractLoadService) this.loadingService).initService(monitor, this);
    }
    LoadingUIJob<RESULT> updateUIJob = new LoadingUIJob<>(this);
    updateUIJob.schedule();
    Throwable error = null;
    RESULT result = null;
    try {
        result = this.loadingService.evaluate(monitor);
    } catch (InvocationTargetException e) {
        error = e.getTargetException();
    } catch (InterruptedException e) {
        return new Status(Status.CANCEL, DBeaverCore.PLUGIN_ID, "Loading interrupted");
    } finally {
        loadFinished = true;
        DBeaverUI.asyncExec(new LoadFinisher(result, error));
    }
    return Status.OK_STATUS;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) AbstractLoadService(org.jkiss.dbeaver.model.runtime.load.AbstractLoadService) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with AbstractLoadService

use of org.jkiss.dbeaver.model.runtime.load.AbstractLoadService in project dbeaver by serge-rider.

the class ERDEditorStandalone method loadDiagram.

/*
    protected void createActions()
    {
        super.createActions();

        //addEditorAction(new SaveAction(this));
    }
*/
@Override
protected synchronized void loadDiagram(boolean refreshMetadata) {
    if (diagramLoadingJob != null) {
        // Do not start new one while old is running
        return;
    }
    diagramLoadingJob = LoadingJob.createService(new AbstractLoadService<EntityDiagram>("Load diagram '" + getEditorInput().getName() + "'") {

        @Override
        public EntityDiagram evaluate(DBRProgressMonitor monitor) {
            try {
                return loadContentFromFile(monitor);
            } catch (DBException e) {
                log.error(e);
            }
            return null;
        }

        @Override
        public Object getFamily() {
            return ERDEditorStandalone.this;
        }
    }, progressControl.createLoadVisualizer());
    diagramLoadingJob.addJobChangeListener(new JobChangeAdapter() {

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

Example 4 with AbstractLoadService

use of org.jkiss.dbeaver.model.runtime.load.AbstractLoadService in project dbeaver by dbeaver.

the class ERDEditorStandalone method loadDiagram.

/*
    protected void createActions()
    {
        super.createActions();

        //addEditorAction(new SaveAction(this));
    }
*/
@Override
protected synchronized void loadDiagram(boolean refreshMetadata) {
    if (diagramLoadingJob != null) {
        // Do not start new one while old is running
        return;
    }
    diagramLoadingJob = LoadingJob.createService(new AbstractLoadService<EntityDiagram>("Load diagram '" + getEditorInput().getName() + "'") {

        @Override
        public EntityDiagram evaluate(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                return loadContentFromFile(monitor);
            } catch (DBException e) {
                log.error(e);
            }
            return null;
        }

        @Override
        public Object getFamily() {
            return ERDEditorStandalone.this;
        }
    }, progressControl.createLoadVisualizer());
    diagramLoadingJob.addJobChangeListener(new JobChangeAdapter() {

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

Example 5 with AbstractLoadService

use of org.jkiss.dbeaver.model.runtime.load.AbstractLoadService in project dbeaver by serge-rider.

the class LoadingJob method run.

private IStatus run(DBRProgressMonitor monitor, boolean lazy) {
    monitor = visualizer.overwriteMonitor(monitor);
    if (this.loadingService instanceof AbstractLoadService) {
        ((AbstractLoadService) this.loadingService).initService(monitor, this);
    }
    LoadingUIJob<RESULT> updateUIJob = new LoadingUIJob<>(this);
    updateUIJob.schedule();
    Throwable error = null;
    RESULT result = null;
    monitor.beginTask("Run service " + getName(), 1);
    try {
        result = this.loadingService.evaluate(monitor);
    } catch (InvocationTargetException e) {
        log.debug(e.getTargetException());
        error = e.getTargetException();
    } catch (InterruptedException e) {
        return new Status(Status.CANCEL, UIActivator.PLUGIN_ID, "Loading interrupted");
    } finally {
        loadFinished = true;
        UIUtils.asyncExec(new LoadFinisher(result, error));
        monitor.done();
    }
    return Status.OK_STATUS;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) AbstractLoadService(org.jkiss.dbeaver.model.runtime.load.AbstractLoadService) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

AbstractLoadService (org.jkiss.dbeaver.model.runtime.load.AbstractLoadService)6 DBException (org.jkiss.dbeaver.DBException)4 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)3 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)3 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Action (org.eclipse.jface.action.Action)1 IContributionManager (org.eclipse.jface.action.IContributionManager)1 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 CellLabelProvider (org.eclipse.jface.viewers.CellLabelProvider)1 IFontProvider (org.eclipse.jface.viewers.IFontProvider)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 SWT (org.eclipse.swt.SWT)1