Author: adietish
Date: 2010-11-17 11:28:22 -0500 (Wed, 17 Nov 2010)
New Revision: 26678
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
Log:
[JBIDE-7597] added exception reporting to destroy instance
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-17 16:27:16
UTC (rev 26677)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-17 16:28:22
UTC (rev 26678)
@@ -1,5 +1,7 @@
2010-11-17 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
(.run):
+ [JBIDE-7597] added exception reporting
* src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java (refresh):
* src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java (refresh):
* src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java (refresh):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-11-17
16:27:16 UTC (rev 26677)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-11-17
16:28:22 UTC (rev 26678)
@@ -1,33 +1,38 @@
package org.jboss.tools.deltacloud.ui.views;
+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.swt.widgets.Display;
import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.ui.ErrorUtils;
public class PerformDestroyInstanceActionThread extends Job {
private DeltaCloud cloud;
private DeltaCloudInstance instance;
private String taskName;
-
- public PerformDestroyInstanceActionThread(DeltaCloud cloud, DeltaCloudInstance
instance,
- String title, String taskName) {
- super(title);
- this.cloud = cloud;
- this.instance = instance;
- this.taskName = taskName;
- }
-
- @Override
- public IStatus run(IProgressMonitor pm) {
- String id = instance.getId();
- try {
- pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
- pm.worked(1);
- // To handle the user starting a new action when we haven't confirmed the last one
yet,
+
+ public PerformDestroyInstanceActionThread(DeltaCloud cloud, DeltaCloudInstance
instance,
+ String title, String taskName) {
+ super(title);
+ this.cloud = cloud;
+ this.instance = instance;
+ this.taskName = taskName;
+ }
+
+ @Override
+ public IStatus run(IProgressMonitor pm) {
+ String id = instance.getId();
+ try {
+ pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
+ pm.worked(1);
+ // To handle the user starting a new action when we haven't
+ // confirmed the last one yet,
// cancel the previous job and then go on performing this action
Job job = cloud.getInstanceJob(id);
if (job != null) {
@@ -39,16 +44,22 @@
}
}
cloud.registerInstanceJob(id, this);
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- cloud.destroyInstance(instance.getId());
- }
- });
- } finally {
- cloud.removeInstanceJob(id, this);
- pm.done();
- }
- return Status.OK_STATUS;
- }
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ cloud.destroyInstance(instance.getId());
+ } catch (DeltaCloudException e) {
+ ErrorUtils.openErrorDialog("Error",
+ MessageFormat.format("Could not destroy instance {0}",
instance.getName()), e,
+ Display.getDefault().getActiveShell());
+ }
+ }
+ });
+ } finally {
+ cloud.removeInstanceJob(id, this);
+ pm.done();
+ }
+ return Status.OK_STATUS;
+ }
}
Show replies by date