Search in sources :

Example 1 with DeployImageWizard

use of org.jboss.tools.openshift.internal.ui.wizard.deployimage.DeployImageWizard 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(new Runnable() {

                    @Override
                    public void run() {
                        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)

Aggregations

ExecutionException (org.eclipse.core.commands.ExecutionException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Status (org.eclipse.core.runtime.Status)1 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 Job (org.eclipse.core.runtime.jobs.Job)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 AbstractDelegatingMonitorJob (org.jboss.tools.openshift.internal.common.core.job.AbstractDelegatingMonitorJob)1 DeployImageWizard (org.jboss.tools.openshift.internal.ui.wizard.deployimage.DeployImageWizard)1