Search in sources :

Example 1 with CreateResourceJob

use of org.jboss.tools.openshift.internal.ui.job.CreateResourceJob 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)

Aggregations

FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URL (java.net.URL)1 IStatus (org.eclipse.core.runtime.IStatus)1 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 ResourceSummaryDialog (org.jboss.tools.openshift.internal.ui.dialog.ResourceSummaryDialog)1 CreateResourceJob (org.jboss.tools.openshift.internal.ui.job.CreateResourceJob)1