Search in sources :

Example 1 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project tdi-studio-se by Talend.

the class PaletteSettingPage method okPressed.

protected void okPressed() {
    ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayUtils.getDefaultShell());
    IRunnableWithProgress rwp = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
            try {
                prf.saveProject(project);
                ShowStandardAction.getInstance().doRun();
                if (needCodeGen) {
                    Job refreshTemplates = CorePlugin.getDefault().getCodeGeneratorService().refreshTemplates();
                    refreshTemplates.addJobChangeListener(new JobChangeAdapter() {

                        @Override
                        public void done(IJobChangeEvent event) {
                            CorePlugin.getDefault().getLibrariesService().resetModulesNeeded();
                        }
                    });
                }
            // ComponentUtilities.updatePalette();
            } catch (Exception ex) {
                ExceptionHandler.process(ex);
            }
        }
    };
    try {
        pmd.run(true, false, rwp);
    } catch (InvocationTargetException e) {
        ExceptionHandler.process(e);
    } catch (InterruptedException e) {
        ExceptionHandler.process(e);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Job(org.eclipse.core.runtime.jobs.Job) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 2 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project tdi-studio-se by Talend.

the class UploadRevisionAction method run.

public void run() {
    if (extension == null) {
        return;
    }
    try {
        final UploadRevisionJob job = new UploadRevisionJob(extension);
        job.addJobChangeListener(new JobChangeAdapter() {

            @Override
            public void done(final IJobChangeEvent event) {
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        updateUI(job, event);
                    }
                });
            }
        });
        ExchangeUtils.scheduleUserJob(job);
    } catch (Throwable e) {
        ExceptionHandler.process(e);
    }
}
Also used : UploadRevisionJob(org.talend.designer.components.exchange.jobs.UploadRevisionJob) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent)

Example 3 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project tdi-studio-se by Talend.

the class DeleteExtensionAction method run.

public void run() {
    if (extension == null) {
        return;
    }
    try {
        final DeleteExtensionJob job = new DeleteExtensionJob(extension);
        job.addJobChangeListener(new JobChangeAdapter() {

            @Override
            public void done(final IJobChangeEvent event) {
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        updateUI(job, event);
                    }
                });
            }
        });
        ExchangeUtils.scheduleUserJob(job);
    } catch (Throwable e) {
        ExceptionHandler.process(e);
    }
}
Also used : JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) DeleteExtensionJob(org.talend.designer.components.exchange.jobs.DeleteExtensionJob)

Example 4 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project tdi-studio-se by Talend.

the class DownloadComponenentsAction method updateUI.

/**
     * Update ui after job finished.
     * 
     * @param action
     * @param event
     */
private void updateUI(final IJobChangeEvent event) {
    // activate aection again after job finished
    if (fExtensionDownloaded > 0) {
        // refresh palette
        ExchangeUtils.reloadComponents();
        // update needed modules.
        CorePlugin.getDefault().getLibrariesService().resetModulesNeeded();
        // see feature 0005050: confirmation popup once the component is installed
        confirmInstallation();
        // Start Code Generation Init
        ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
        Job job = codeGenService.refreshTemplates();
        job.addJobChangeListener(new JobChangeAdapter() {

            @Override
            public void done(IJobChangeEvent event) {
                ComponentPaletteUtilities.setSkipUpdatePalette(false);
            }
        });
        RefreshComponenentsAction action = new RefreshComponenentsAction();
        action.run(new String[] { RefreshComponenentsAction.REFRESH_INSTALLED }, ContentConstants.UL_DOWNLOADED_EXTENSIONS);
    }
}
Also used : JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Job(org.eclipse.core.runtime.jobs.Job) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService)

Example 5 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project tdi-studio-se by Talend.

the class DownloadComponenentsAction method run.

@Override
public void run() {
    try {
        final ComponentExtension selectedExtension = ExchangeManager.getInstance().getSelectedExtension();
        Job job = new DownloadJob(selectedExtension);
        fExtensionDownloaded = 0;
        fDownloadedComponents = new ArrayList<ComponentExtension>();
        job.addJobChangeListener(new JobChangeAdapter() {

            @Override
            public void done(final IJobChangeEvent event) {
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        updateUI(event);
                    }
                });
            }
        });
        ExchangeUtils.scheduleUserJob(job);
    } catch (Throwable e) {
        ExceptionHandler.process(e);
    }
}
Also used : JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) ComponentExtension(org.talend.designer.components.exchange.model.ComponentExtension) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Job(org.eclipse.core.runtime.jobs.Job)

Aggregations

IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)166 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)157 Job (org.eclipse.core.runtime.jobs.Job)44 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)43 IStatus (org.eclipse.core.runtime.IStatus)36 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)30 ArrayList (java.util.ArrayList)13 IFile (org.eclipse.core.resources.IFile)13 CoreException (org.eclipse.core.runtime.CoreException)12 DataSourceJob (org.jkiss.dbeaver.runtime.jobs.DataSourceJob)12 Status (org.eclipse.core.runtime.Status)11 IOException (java.io.IOException)10 DBException (org.jkiss.dbeaver.DBException)10 AbstractJob (org.jkiss.dbeaver.model.runtime.AbstractJob)10 File (java.io.File)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 IJobChangeListener (org.eclipse.core.runtime.jobs.IJobChangeListener)8 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)8 Composite (org.eclipse.swt.widgets.Composite)7 IProject (org.eclipse.core.resources.IProject)6