Author: adietish
Date: 2010-11-12 09:03:40 -0500 (Fri, 12 Nov 2010)
New Revision: 26510
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java
Log:
[JBIDE-7365] split code into several methods
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java 2010-11-12
13:59:21 UTC (rev 26509)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java 2010-11-12
14:03:40 UTC (rev 26510)
@@ -53,26 +53,9 @@
// 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.getActionJob(id);
- if (job != null) {
- job.cancel();
- try {
- job.join();
- } catch (InterruptedException e) {
- // do nothing, this is ok
- }
- }
+ cancelPreviousJob(id);
cloud.performInstanceAction(id, action);
- while (instance != null && expectedState != null
- && !(instance.getState().equals(expectedState))
- && !(instance.getState().equals(DeltaCloudInstance.TERMINATED))) {
- instance = cloud.refreshInstance(id);
- try {
- Thread.sleep(300);
- } catch (InterruptedException e) {
- break;
- }
- }
+ waitForInstanceState(id);
} catch (DeltaCloudException e) {
final IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
e.getMessage(), e);
Activator.log(status);
@@ -93,4 +76,29 @@
}
return Status.OK_STATUS;
}
+
+ private void cancelPreviousJob(String id) {
+ Job job = cloud.getActionJob(id);
+ if (job != null) {
+ job.cancel();
+ try {
+ job.join();
+ } catch (InterruptedException e) {
+ // do nothing, this is ok
+ }
+ }
+ }
+
+ private void waitForInstanceState(String id) {
+ while (instance != null && expectedState != null
+ && !(instance.getState().equals(expectedState))
+ && !(instance.getState().equals(DeltaCloudInstance.TERMINATED))) {
+ instance = cloud.refreshInstance(id);
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ break;
+ }
+ }
+ }
}
Show replies by date