Author: adietish
Date: 2012-01-26 07:33:43 -0500 (Thu, 26 Jan 2012)
New Revision: 38200
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressWizardFragment.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java
Log:
[JBIDE-10719] WizardUtils#runInWizard now returns IStatus (was: Future<IStatus>).
renamed WizardUtils#runInWizardSynch to WizardUtils#runInWizard
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java 2012-01-26
11:12:20 UTC (rev 38199)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java 2012-01-26
12:33:43 UTC (rev 38200)
@@ -11,7 +11,6 @@
package org.jboss.tools.common.ui;
import java.lang.reflect.InvocationTargetException;
-import java.util.concurrent.Future;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -53,15 +52,13 @@
* @see IWizardContainer#run(boolean, boolean, IRunnableWithProgress)
* @see Job
*/
- public static Future<IStatus> runInWizard(final Job job, IWizardContainer
container)
- throws InvocationTargetException,
- InterruptedException {
+ public static IStatus runInWizard(final Job job, IWizardContainer container)
+ throws InvocationTargetException, InterruptedException {
return runInWizard(job, null, container);
}
/**
- * Runs the given job in the given wizard container. This method will return
- * immediately, it will not wait for the job completion.
+ * Runs the given job in the given wizard container.
* <p>
* In order to have the wizard displaying a progress bar, you need to set
* Wizard#setNeedsProgressMonitor to <code>true</code>.
@@ -77,42 +74,44 @@
* @throws InvocationTargetException
* @throws InterruptedException
*/
- public static Future<IStatus> runInWizard(final Job job, final
DelegatingProgressMonitor delegatingMonitor,
+ public static IStatus runInWizard(final Job job, final DelegatingProgressMonitor
delegatingMonitor,
IWizardContainer container) throws InvocationTargetException, InterruptedException {
- JobResultFuture future = new JobResultFuture(job);
- // Currently this impl is wrong and does not return the future immediately. Not sure
how to fix
- runInWizardSynchronous(job, delegatingMonitor, container);
- return future;
- }
-
- /**
- * @since 3.3
- */
- public static void runInWizardSynchronous(final Job job, final DelegatingProgressMonitor
delegatingMonitor,
- IWizardContainer container) throws InvocationTargetException, InterruptedException {
+ final IStatus[] statusHolder = new IStatus[1];
container.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- if (delegatingMonitor == null) {
- monitor.beginTask(job.getName(), IProgressMonitor.UNKNOWN);
- } else {
- delegatingMonitor.add(monitor);
- delegatingMonitor.beginTask(job.getName(), IProgressMonitor.UNKNOWN);
- }
+ IProgressMonitor monitorToUse = setupDelegatingMonitorIfPresent(delegatingMonitor,
monitor);
+ monitorToUse.beginTask(job.getName(), IProgressMonitor.UNKNOWN);
job.schedule();
job.join();
-
- if (delegatingMonitor == null) {
- monitor.done();
- } else {
- delegatingMonitor.done();
- }
+ statusHolder[0] = job.getResult();
+ monitorToUse.done();
}
+
});
+ return statusHolder[0];
}
/**
+ * Returns the delegating monitor if present or the simple monitor
+ * otherwise. The simple monitor is added to the delegating one.
+ *
+ * @param delegatingMonitor
+ * @param monitor
+ * @return
+ */
+ private static IProgressMonitor
setupDelegatingMonitorIfPresent(DelegatingProgressMonitor delegatingMonitor,
+ IProgressMonitor monitor) {
+ if (delegatingMonitor == null) {
+ return monitor;
+ }
+
+ delegatingMonitor.add(monitor);
+ return delegatingMonitor;
+ }
+
+ /**
* Runs the given job in the given wizard container.
* <p>
* Furhtermore it updates the models and targets of the given data binding
@@ -134,17 +133,17 @@
* @throws InterruptedException
* the interrupted exception
*/
- public static Future<IStatus> runInWizard(final Job job, IWizardContainer
container, DataBindingContext dbc)
+ public static IStatus runInWizard(final Job job, IWizardContainer container,
DataBindingContext dbc)
throws InvocationTargetException, InterruptedException {
return runInWizard(job, null, container);
}
- public static Future<IStatus> runInWizard(Job job, DelegatingProgressMonitor
monitor, IWizardContainer container,
+ public static IStatus runInWizard(Job job, DelegatingProgressMonitor monitor,
IWizardContainer container,
DataBindingContext dbc) throws InvocationTargetException, InterruptedException {
- Future<IStatus> jobResult = runInWizard(job, monitor, container);
+ IStatus status = runInWizard(job, monitor, container);
dbc.updateTargets();
dbc.updateModels();
- return jobResult;
+ return status;
}
/**
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressWizardFragment.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressWizardFragment.java 2012-01-26
11:12:20 UTC (rev 38199)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressWizardFragment.java 2012-01-26
12:33:43 UTC (rev 38200)
@@ -165,7 +165,7 @@
};
IWizardContainer container = ((WizardPage)handle).getWizard().getContainer();
try {
- WizardUtils.runInWizardSynchronous(j, null, container);
+ WizardUtils.runInWizard(j, null, container);
postLongRunningValidate();
} catch(Exception e) {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizard.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizard.java 2012-01-26
11:12:20 UTC (rev 38199)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizard.java 2012-01-26
12:33:43 UTC (rev 38200)
@@ -12,7 +12,6 @@
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -34,7 +33,7 @@
import com.openshift.express.client.OpenShiftException;
/**
- * @author Andr� Dietisheim
+ * @author Andr� Dietisheim
* @author Xavier Coulon
*/
public class CreateNewApplicationWizard extends
AbstractOpenShiftApplicationWizard<CreateNewApplicationWizardModel> implements
INewWizard {
@@ -70,11 +69,11 @@
if(successfull) {
try {
final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor();
- Future<IStatus> jobResult =
+ IStatus jobResult =
WizardUtils.runInWizard(
new ImportJob(delegatingMonitor),
delegatingMonitor, getContainer());
- return JobUtils.isOk(jobResult.get(10, TimeUnit.SECONDS));
+ return JobUtils.isOk(jobResult);
} catch (Exception e) {
ErrorDialog.openError(getShell(), "Error", "Could not create local git
repository.",
new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizard.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizard.java 2012-01-26
11:12:20 UTC (rev 38199)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizard.java 2012-01-26
12:33:43 UTC (rev 38200)
@@ -13,8 +13,6 @@
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
@@ -36,7 +34,7 @@
import com.openshift.express.client.OpenShiftException;
/**
- * @author Andr� Dietisheim
+ * @author Andr� Dietisheim
* @author Xavier Coulon
*/
public class ImportExistingApplicationWizard extends
AbstractOpenShiftApplicationWizard<ImportExistingApplicationWizardModel> implements
IImportWizard {
@@ -55,11 +53,11 @@
public boolean performFinish() {
try {
final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor();
- Future<IStatus> jobResult =
+ IStatus jobResult =
WizardUtils.runInWizard(
new ImportJob(delegatingMonitor),
delegatingMonitor, getContainer());
- return JobUtils.isOk(jobResult.get(10, TimeUnit.SECONDS));
+ return JobUtils.isOk(jobResult);
} catch (Exception e) {
ErrorDialog.openError(getShell(), "Error", "Could not create local git
repository.",
new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java 2012-01-26
11:12:20 UTC (rev 38199)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java 2012-01-26
12:33:43 UTC (rev 38200)
@@ -10,9 +10,6 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateListStrategy;
@@ -190,8 +187,8 @@
}
};
try {
- Future<IStatus> jobResult = WizardUtils.runInWizard(job, delegatingMonitor,
getContainer());
- return JobUtils.isOk(jobResult.get(10, TimeUnit.SECONDS));
+ IStatus jobResult = WizardUtils.runInWizard(job, delegatingMonitor, getContainer());
+ return JobUtils.isOk(jobResult);
} catch (Exception e) {
OpenShiftUIActivator.log(e);
return false;
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java 2012-01-26
11:12:20 UTC (rev 38199)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java 2012-01-26
12:33:43 UTC (rev 38200)
@@ -13,8 +13,6 @@
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
@@ -39,7 +37,6 @@
import org.jboss.tools.openshift.express.internal.ui.wizard.AdapterWizardPage;
import org.jboss.tools.openshift.express.internal.ui.wizard.ApplicationWizardPage;
import org.jboss.tools.openshift.express.internal.ui.wizard.CreateNewApplicationWizard;
-import org.jboss.tools.openshift.express.internal.ui.wizard.CredentialsWizardPage;
import
org.jboss.tools.openshift.express.internal.ui.wizard.ImportExistingApplicationWizard;
import com.openshift.express.client.OpenShiftException;
@@ -66,11 +63,10 @@
public boolean performFinish() {
try {
final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor();
- Future<IStatus> jobResult =
- WizardUtils.runInWizard(
+ IStatus jobResult = WizardUtils.runInWizard(
new ImportJob(delegatingMonitor),
delegatingMonitor, getContainer());
- return JobUtils.isOk(jobResult.get(10, TimeUnit.SECONDS));
+ return JobUtils.isOk(jobResult);
} catch (Exception e) {
ErrorDialog.openError(getShell(), "Error", "Could not create local git
repository.",
new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,