Author: adietish
Date: 2011-03-23 06:22:28 -0400 (Wed, 23 Mar 2011)
New Revision: 29973
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnectionWizard.java
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
Log:
[JBIDE-8148] editing and creating clouds in background jobs now
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
---
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-03-23
10:17:11 UTC (rev 29972)
+++
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-03-23
10:22:28 UTC (rev 29973)
@@ -1,3 +1,10 @@
+2011-03-23 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties:
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java
(createCloud):
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnectionWizard.java
(editCloud):
+ [JBIDE-8148] editing and creating clouds in background jobs now
+
2011-03-22 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
* src/org/jboss/tools/deltacloud/ui/views/Columns.java:
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnectionWizard.java
===================================================================
---
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnectionWizard.java 2011-03-23
10:17:11 UTC (rev 29972)
+++
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnectionWizard.java 2011-03-23
10:22:28 UTC (rev 29973)
@@ -10,13 +10,16 @@
*******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import java.text.MessageFormat;
-
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbench;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.Driver;
-import org.jboss.tools.deltacloud.ui.ErrorUtils;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
+import org.jboss.tools.internal.deltacloud.ui.utils.WizardUtils;
/**
* @author Jeff Johnston
@@ -42,14 +45,25 @@
String username = mainPage.getModel().getUsername();
String password = mainPage.getModel().getPassword();
Driver driver = mainPage.getModel().getDriver();
+ return editCloud(initialCloud, name, url, username, password, driver);
+ }
+
+ private boolean editCloud(final DeltaCloud cloud, final String name, final String url,
final String username,
+ final String password, final Driver driver) {
try {
- initialCloud.update(name, url, username, password, driver);
+ Job job = new
AbstractCloudJob(WizardMessages.getFormattedString("EditCloudConnection.message",
cloud.getName()), cloud) {
+
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ initialCloud.update(name, url, username, password, driver);
+ return Status.OK_STATUS;
+ }
+ };
+ WizardUtils.runInWizard(job, getContainer());
+ return job.getResult() != null && job.getResult().getCode() != IStatus.ERROR;
} catch (Exception e) {
- // TODO internationalize strings
- ErrorUtils.handleError("Error",
- MessageFormat.format("Could not edit cloud \"{0}\"",
initialCloud.getName()),
- e, getShell());
+ return false;
}
- return true;
}
+
}
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java
===================================================================
---
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java 2011-03-23
10:17:11 UTC (rev 29972)
+++
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java 2011-03-23
10:22:28 UTC (rev 29973)
@@ -10,12 +10,15 @@
*******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import java.text.MessageFormat;
-
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.common.log.StatusFactory;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
@@ -24,6 +27,7 @@
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.internal.deltacloud.ui.preferences.IPreferenceKeys;
import org.jboss.tools.internal.deltacloud.ui.preferences.StringPreferenceValue;
+import org.jboss.tools.internal.deltacloud.ui.utils.WizardUtils;
/**
* @author Jeff Johnston
@@ -114,14 +118,32 @@
String password = mainPage.getModel().getPassword();
Driver driver = mainPage.getModel().getDriver();
+ return createCloud(name, url, username, password, driver);
+ }
+
+ private boolean createCloud(final String name, final String url, final String username,
final String password,
+ final Driver driver) {
+ Job job = new Job(WizardMessages.getFormattedString("CloudConnection.msg",
name)) {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ DeltaCloud newCloud = new DeltaCloud(name, url, username, password, driver);
+ DeltaCloudManager.getDefault().addCloud(newCloud);
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ // TODO internationalize strings
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ WizardMessages.getFormattedString("CloudConnectionError.msg", name),
e);
+ }
+ }
+
+ };
try {
- DeltaCloud newCloud = new DeltaCloud(name, url, username, password, driver);
- DeltaCloudManager.getDefault().addCloud(newCloud);
+ WizardUtils.runInWizard(job, getContainer());
+ return job.getResult() != null && job.getResult().getCode() != IStatus.ERROR;
} catch (Exception e) {
- // TODO internationalize strings
- ErrorUtils
- .handleError("Error", MessageFormat.format("Could not create cloud
{0}", name), e, getShell());
+ return false;
}
- return true;
}
}
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
===================================================================
---
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2011-03-23
10:17:11 UTC (rev 29972)
+++
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2011-03-23
10:22:28 UTC (rev 29973)
@@ -11,6 +11,8 @@
CloudConnection.desc=Specify connection details for a cloud you wish to access
CloudConnection.title=Cloud Connection
CloudConnection.name=Cloud Connection
+CloudConnection.msg=Create cloud {0}
+CloudConnectionError.msg=Could not create cloud {0}
CloudConnectionTestSuccess.msg=Connection Test successful
CloudConnectionTestFailure.msg=Connection Test failed
CloudConnectionTestingCredentials.msg=Testing credentials...
@@ -18,6 +20,7 @@
NewCloudConnection.name=New Cloud Connection
EditCloudConnection.name=Edit Cloud Connection
+EditCloudConnection.message=Edit Cloud {0}
EditCloudConnectionError.title=Error Editing Cloud Connection
EditCloudConnectionError.message=Could not open connection wizard