Search in sources :

Example 86 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project jbosstools-openshift by jbosstools.

the class DeployImageWizard method performFinish.

@Override
public boolean performFinish() {
    // checks if we need to push the image, first
    final Job job = getJobChain(getModel());
    job.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            final IStatus status = event.getResult();
            UsageStats.getInstance().newV3Application(getModel().getConnection().getHost(), isFailed(status));
            super.done(event);
        }
    });
    job.schedule();
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) RefreshResourcesJob(org.jboss.tools.openshift.internal.ui.job.RefreshResourcesJob) DeployImageJob(org.jboss.tools.openshift.internal.ui.job.DeployImageJob) PushImageToRegistryJob(org.jboss.tools.openshift.internal.core.docker.PushImageToRegistryJob) Job(org.eclipse.core.runtime.jobs.Job)

Example 87 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project jbosstools-openshift by jbosstools.

the class ImportApplicationWizard method createImportJob.

private void createImportJob(boolean reuseGitRepository) {
    if (reuseGitRepository) {
        this.importJob = new ImportJob(model.getGitUrl(), model.getGitRef(), model.getRepoPath(), model.isCheckoutBranchReusedRepo());
    } else {
        this.importJob = new ImportJob(model.getGitUrl(), model.getGitRef(), model.getRepoPath());
    }
    String gitContextDir = model.getGitContextDir();
    if (StringUtils.isNotEmpty(gitContextDir)) {
        importJob.setFilters(Collections.singleton(gitContextDir));
    }
    importJob.setUser(true);
    importJob.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            boolean success = JobUtils.isOk(importJob.getResult());
            if (success) {
                saveRepoPath();
            }
            UsageStats.getInstance().importV3Application(model.getConnection().getHost(), success);
        }
    });
    for (IJobChangeListener importJobChangeListener : importJobChangeListenersList) {
        importJob.addJobChangeListener(importJobChangeListener);
    }
}
Also used : JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeListener(org.eclipse.core.runtime.jobs.IJobChangeListener) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent)

Example 88 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project jbosstools-openshift by jbosstools.

the class NewResourceWizard method performFinish.

@Override
public boolean performFinish() {
    boolean success = false;
    try (InputStream is = (OpenshiftUIConstants.URL_VALIDATOR.isValid(model.getSource())) ? new URL(model.getSource()).openStream() : new FileInputStream(VariablesHelper.replaceVariables(model.getSource()))) {
        final CreateResourceJob createJob = new CreateResourceJob(model.getProject(), is);
        createJob.addJobChangeListener(new JobChangeAdapter() {

            @Override
            public void done(IJobChangeEvent event) {
                IStatus status = event.getResult();
                if (JobUtils.isOk(status) || JobUtils.isWarning(status)) {
                    Display.getDefault().syncExec(new Runnable() {

                        @Override
                        public void run() {
                            new ResourceSummaryDialog(getShell(), createJob.getResource(), "Create Resource Summary", "Results of creating the resource(s)").open();
                        }
                    });
                    OpenShiftUIUtils.showOpenShiftExplorer();
                }
            }
        });
        IStatus status = runInWizard(createJob, createJob.getDelegatingProgressMonitor(), getContainer());
        success = isSuccess(status);
    } catch (InvocationTargetException | InterruptedException | IOException e) {
        page.setErrorMessage(e.getClass().getName() + ": " + e.getLocalizedMessage());
        success = false;
    }
    return success;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) ResourceSummaryDialog(org.jboss.tools.openshift.internal.ui.dialog.ResourceSummaryDialog) CreateResourceJob(org.jboss.tools.openshift.internal.ui.job.CreateResourceJob) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) IOException(java.io.IOException) URL(java.net.URL) FileInputStream(java.io.FileInputStream) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 89 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project jbosstools-openshift by jbosstools.

the class DeployImageHandler method runWizard.

public void runWizard(final Shell shell, final IDockerConnection dockerConnection, final IDockerImage image, final IProject project, final Connection connection) {
    if (connection != null) {
        final boolean[] authorized = new boolean[1];
        Job job = new AbstractDelegatingMonitorJob("Checking connection...") {

            @Override
            protected IStatus doRun(IProgressMonitor monitor) {
                try {
                    authorized[0] = connection.isAuthorized(new NullProgressMonitor());
                    return Status.OK_STATUS;
                } catch (Exception e) {
                    return new Status(Status.ERROR, OpenShiftUIActivator.PLUGIN_ID, "Unable to load the OpenShift projects for the selected connection.", e);
                }
            }
        };
        job.addJobChangeListener(new JobChangeAdapter() {

            @Override
            public void done(IJobChangeEvent event) {
                shell.getDisplay().asyncExec(() -> {
                    DeployImageWizard wizard = new DeployImageWizard(dockerConnection, image, connection, project, authorized[0]);
                    WizardUtils.openWizardDialog(500, 500, wizard, shell);
                });
            }
        });
        job.schedule();
    } else {
        DeployImageWizard wizard = new DeployImageWizard(dockerConnection, image, connection, project, false);
        WizardUtils.openWizardDialog(600, 1500, wizard, shell);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) AbstractDelegatingMonitorJob(org.jboss.tools.openshift.internal.common.core.job.AbstractDelegatingMonitorJob) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) AbstractDelegatingMonitorJob(org.jboss.tools.openshift.internal.common.core.job.AbstractDelegatingMonitorJob) Job(org.eclipse.core.runtime.jobs.Job) ExecutionException(org.eclipse.core.commands.ExecutionException) DeployImageWizard(org.jboss.tools.openshift.internal.ui.wizard.deployimage.DeployImageWizard)

Example 90 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project translationstudio8 by heartsome.

the class PreloadingRepositoryHandler method doExecuteAndLoad.

void doExecuteAndLoad() {
    if (preloadRepositories()) {
        // cancel any load that is already running
        final IStatus[] checkStatus = new IStatus[1];
        Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
        final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI()) {

            public IStatus runModal(IProgressMonitor monitor) {
                SubMonitor sub = SubMonitor.convert(monitor, getProgressTaskName(), 1000);
                IStatus status = super.runModal(sub.newChild(500));
                if (status.getSeverity() == IStatus.CANCEL)
                    return status;
                if (status.getSeverity() != IStatus.OK) {
                    // 记录检查错误
                    checkStatus[0] = status;
                    return Status.OK_STATUS;
                }
                try {
                    doPostLoadBackgroundWork(sub.newChild(500));
                } catch (OperationCanceledException e) {
                    return Status.CANCEL_STATUS;
                }
                return status;
            }
        };
        setLoadJobProperties(loadJob);
        loadJob.setName(P2UpdateUtil.CHECK_UPDATE_JOB_NAME);
        if (waitForPreload()) {
            loadJob.addJobChangeListener(new JobChangeAdapter() {

                public void done(IJobChangeEvent event) {
                    if (PlatformUI.isWorkbenchRunning())
                        if (event.getResult().isOK()) {
                            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

                                public void run() {
                                    if (checkStatus[0] != null) {
                                        // 提示连接异常
                                        P2UpdateUtil.openConnectErrorInfoDialog(getShell(), P2UpdateUtil.INFO_TYPE_CHECK);
                                        return;
                                    }
                                    doExecute(loadJob);
                                }
                            });
                        }
                }
            });
            loadJob.setUser(true);
            loadJob.schedule();
        } else {
            loadJob.setSystem(true);
            loadJob.setUser(false);
            loadJob.schedule();
            doExecute(null);
        }
    } else {
        doExecute(null);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) SubMonitor(org.eclipse.core.runtime.SubMonitor) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) LoadMetadataRepositoryJob(org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob)

Aggregations

IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)172 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)163 Job (org.eclipse.core.runtime.jobs.Job)46 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)45 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 File (java.io.File)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)12 CoreException (org.eclipse.core.runtime.CoreException)12 DataSourceJob (org.jkiss.dbeaver.runtime.jobs.DataSourceJob)12 Status (org.eclipse.core.runtime.Status)11 IJobChangeListener (org.eclipse.core.runtime.jobs.IJobChangeListener)11 IOException (java.io.IOException)10 DBException (org.jkiss.dbeaver.DBException)10 AbstractJob (org.jkiss.dbeaver.model.runtime.AbstractJob)10 IProject (org.eclipse.core.resources.IProject)9 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)8 Composite (org.eclipse.swt.widgets.Composite)7