Index: src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java =================================================================== --- src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java (revision 39749) +++ src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java (working copy) @@ -187,12 +187,14 @@ private boolean createApplication() { try { final String applicationName = wizardModel.getApplicationName(); + final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor(); IStatus status = WizardUtils.runInWizard( new Job(NLS.bind("Creating application \"{0}\"...", applicationName)) { @Override protected IStatus run(IProgressMonitor monitor) { try { - getWizardModel().createApplication(monitor); + delegatingMonitor.add(monitor); + getWizardModel().createApplication(delegatingMonitor); return Status.OK_STATUS; } catch (OpenShiftEndpointException e) { // TODO: refresh user @@ -205,7 +207,7 @@ } } - }, null, getContainer(), 300); + }, delegatingMonitor, getContainer(), 300); return status.isOK(); } catch (Exception e) { return false; Index: src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java =================================================================== --- src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java (revision 39749) +++ src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java (working copy) @@ -8,6 +8,10 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.FutureTask; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; @@ -24,6 +28,7 @@ import org.jboss.tools.openshift.express.internal.core.console.UserDelegate; import org.jboss.tools.openshift.express.internal.core.console.UserModel; import org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages; +import org.jboss.tools.openshift.express.internal.ui.utils.Logger; import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ConfigureGitSharedProject; import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ConfigureUnsharedProject; import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ImportNewProject; @@ -40,7 +45,7 @@ protected HashMap dataModel = new HashMap(); - private static final int APP_CREATION_TIMEOUT = 120; + private static final int APP_CREATION_TIMEOUT = 180; private static final String KEY_SELECTED_EMBEDDABLE_CARTRIDGES = "selectedEmbeddableCartridges"; public OpenShiftExpressApplicationWizardModel(UserDelegate user, IProject project, IApplication application, boolean useExistingApplication) { @@ -343,15 +348,45 @@ } } - protected IApplication createApplication(String name, ICartridge cartridge, IProgressMonitor monitor) + protected IApplication createApplication(final String name, final ICartridge cartridge, final IProgressMonitor monitor) throws OpenShiftApplicationNotAvailableException, OpenShiftException { - IUser user = getUser(); + final IUser user = getUser(); if (user == null) { throw new OpenShiftException("Could not create application, have no valid user credentials"); } - IApplication application = user.createApplication(name, cartridge); - waitForAccessible(application, monitor); - return application; + ExecutorService executor = Executors.newFixedThreadPool(1); + try { + FutureTask future = new FutureTask( + new Callable() { + @Override + public IApplication call() throws Exception { + monitor.setTaskName("Creating application \"" + name + "\"..."); + Logger.debug("creating application..."); + final IApplication application + = user.createApplication(name, cartridge); + monitor.beginTask("Waiting for application to be reachable...", + IProgressMonitor.UNKNOWN); + Logger.debug("Waiting for application to be reachable..."); + waitForAccessible(application, monitor); + return application; + } + }); + executor.execute(future); + while (!future.isDone()) { + if(monitor.isCanceled()) { + throw new OpenShiftException("Operation was cancelled by user."); + } + Thread.sleep(1000); + } + final IApplication application = future.get(); + return application; + } catch (Exception e) { // InterruptedException and ExecutionException + Throwable cause = e.getCause() !=null ?e.getCause() : e; + Logger.error("Failed to create application", cause); + throw new OpenShiftException("Failed to create application: {0}", cause.getMessage()); + } finally { + executor.shutdown(); + } } public void createApplication(IProgressMonitor monitor) throws OpenShiftApplicationNotAvailableException,