Author: adietish
Date: 2010-12-14 04:11:36 -0500 (Tue, 14 Dec 2010)
New Revision: 27429
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/DestroyCloudInstanceJob.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceActionJob.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceSchedulingRule.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceStateJob.java
Removed:
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/PerformInstanceActionJob.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudJob.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DestroyInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
Log:
[JBIDE-7594]
* added instance related job & scheduling rule (blocks instance jobs on same instance
and superclass jobs on same cloud & element)
* corrected scheduling rule to block superclass scheduling rule on the same cloud
* added scheduling element that reflects cloud properties being processed (instances,
images, realms, profiles)
* switched RefreshImagesHandler and RefreshInstancesHandler to AbstractCloudElementJob to
have consistent blocking with all other jobs
* switched DestroyInstanceHandler to DestroyInstanceJob to have consistent blocking with
all other jobs
* switched AbstractInstanceHandler to InstanceActionJob to have consistent blocking with
all other jobs
* switched InstancesCategoryItem to AbstractCloudElementJob to have consistent blocking
with all other jobs
* switched ImagesCategoryItem to AbstractCloudElementJob to have consistent blocking with
all other jobs
* switched ImageViewLabelAndContentProvider to AbstractCloudElementJob to have consistent
blocking with all other jobs
* switched InstanceViewLabelAndContentProvider to AbstractCloudElementJob to have
consistent blocking with all other jobs
* switched FindImagePage to AbstractCloudElementJob to have consistent blocking with all
other jobs
* switched NewInstancePage to AbstractCloudElementJob to have consistent blocking with all
other jobs
* switched NewInstanceWizard#WatchInstanceJob to InstanceStateJob to have consistent
blocking with all other jobs
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-14 08:46:56
UTC (rev 27428)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-14 09:11:36
UTC (rev 27429)
@@ -1,3 +1,15 @@
+2010-12-14 André Dietisheim <adietish(a)redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/job/InstanceSchedulingRule.java:
+ * src/org/jboss/tools/deltacloud/core/job/InstanceStateJob.java:
+ * src/org/jboss/tools/deltacloud/core/job/InstanceActionJob.java:
+ [JBIDE-7594] added instance related job & scheduling rule
+ (blocks instance jobs on same instance and superclass jobs on same cloud & element)
+ * src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java
(isOnSameElement):
+ [JBIDE-7594] corrected scheduling rule to block superclass scheduling rule on the same
cloud
+ * src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java (CLOUDELEMENT):
+ [JBIDE-7594] added scheduling element that reflects cloud properties being processed
(instances, images, realms, profiles)
+
2010-12-13 André Dietisheim <adietish(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/DeltaCloud.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -10,8 +10,6 @@
******************************************************************************/
package org.jboss.tools.deltacloud.core.job;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.jboss.tools.deltacloud.core.DeltaCloud;
@@ -21,7 +19,7 @@
public abstract class AbstractCloudElementJob extends AbstractCloudJob {
public static enum CLOUDELEMENT {
- IMAGES, INSTANCES
+ IMAGES, INSTANCES, PROFILES, REALMS
}
private CLOUDELEMENT cloudElement;
@@ -32,10 +30,13 @@
// setUser(true);
}
- protected abstract IStatus doRun(IProgressMonitor monitor) throws Exception;
-
@Override
protected ISchedulingRule getSchedulingRule() {
return new CloudElementSchedulingRule(getCloud(), cloudElement);
}
+
+ protected CLOUDELEMENT getCloudElement() {
+ return cloudElement;
+ }
+
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudJob.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudJob.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudJob.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -30,7 +30,6 @@
public AbstractCloudJob(String name, DeltaCloud cloud) {
super(name);
this.cloud = cloud;
- // setUser(true);
}
@Override
@@ -38,7 +37,6 @@
ISchedulingRule rule = getSchedulingRule();
Job.getJobManager().beginRule(rule, monitor);
monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
- monitor.worked(1);
try {
return doRun(monitor);
} catch (Exception e) {
@@ -46,6 +44,7 @@
return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
MessageFormat.format("Could not {0}", getName()));
} finally {
+ monitor.done();
Job.getJobManager().endRule(rule);
}
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -30,19 +30,19 @@
}
@Override
- public boolean contains(ISchedulingRule rule) {
- return rule == this;
- }
-
- @Override
public boolean isConflicting(ISchedulingRule rule) {
return super.isConflicting(rule)
&& isOnSameElement(rule);
}
private boolean isOnSameElement(ISchedulingRule rule) {
- return rule.getClass().isAssignableFrom(CloudElementSchedulingRule.class)
- && ((CloudElementSchedulingRule) rule).getCloudElement().equals(element);
+ if (CloudElementSchedulingRule.class.isAssignableFrom(rule.getClass())) {
+ return ((CloudElementSchedulingRule) rule).getCloudElement().equals(element);
+ } else {
+ // this rules conflicts with a cloud rule which is not an element
+ // rule
+ return true;
+ }
}
private CLOUDELEMENT getCloudElement() {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -47,10 +47,20 @@
}
private boolean isCloudRule(ISchedulingRule rule) {
- return rule.getClass().isAssignableFrom(CloudSchedulingRule.class);
+ return CloudSchedulingRule.class.isAssignableFrom(rule.getClass());
}
- private DeltaCloud getCloud() {
+ protected DeltaCloud getCloud() {
return cloud;
}
+
+ public String toString() {
+ return new StringBuilder()
+ .append("[InstanceSchedulingRule ")
+ .append("cloud :\"")
+ .append(getCloud().getName())
+ .append("\"")
+ .append("]")
+ .toString();
+ }
}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/DestroyCloudInstanceJob.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/DestroyCloudInstanceJob.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/DestroyCloudInstanceJob.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.deltacloud.core.job;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+
+/**
+ * @author André Dietisheim
+ */
+public class DestroyCloudInstanceJob extends InstanceActionJob {
+
+ public DestroyCloudInstanceJob(String name, DeltaCloudInstance instance) {
+ super(name, instance, DeltaCloudInstance.Action.DESTROY,
DeltaCloudInstance.State.TERMINATED);
+ }
+
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ String id = getInstance().getId();
+ getCloud().performInstanceAction(id, getAction());
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ protected ISchedulingRule getSchedulingRule() {
+ return new InstanceSchedulingRule(getCloud(), getCloudElement(), getInstance());
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/DestroyCloudInstanceJob.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceActionJob.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceActionJob.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceActionJob.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.deltacloud.core.job;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance.Action;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance.State;
+
+/**
+ * @author André Dietisheim
+ */
+public class InstanceActionJob extends InstanceStateJob {
+
+ private Action action;
+
+ public InstanceActionJob(String name, DeltaCloudInstance instance,
+ Action action, State expectedState) {
+ super(name, instance, expectedState);
+ this.action = action;
+ }
+
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ String id = getInstance().getId();
+ getCloud().performInstanceAction(id, action);
+ getCloud().waitForState(id, getExpectedState(), monitor);
+ return Status.OK_STATUS;
+ }
+
+ protected Action getAction() {
+ return action;
+ }
+
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceActionJob.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceSchedulingRule.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceSchedulingRule.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceSchedulingRule.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.deltacloud.core.job;
+
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
+
+/**
+ * A scheduling rule for jobs that prevents 2 jobs from running on the same
+ * cloud instance.
+ *
+ * @author André Dietisheim
+ */
+public class InstanceSchedulingRule extends CloudElementSchedulingRule {
+
+ private DeltaCloudInstance instance;
+
+ public InstanceSchedulingRule(DeltaCloud cloud, CLOUDELEMENT element, DeltaCloudInstance
instance) {
+ super(cloud, element);
+ this.instance = instance;
+ }
+
+ @Override
+ public boolean isConflicting(ISchedulingRule rule) {
+ return super.isConflicting(rule)
+ && isOnSameInstance(rule);
+ }
+
+ private boolean isOnSameInstance(ISchedulingRule rule) {
+ if (InstanceSchedulingRule.class.isAssignableFrom(rule.getClass())) {
+ return instance.equals(((InstanceSchedulingRule) rule).getInstance());
+ } else {
+ // this rules conflicts with a cloud element rule which is not an instance rule
+ return true;
+ }
+ }
+
+ protected DeltaCloudInstance getInstance() {
+ return instance;
+ }
+
+ public String toString() {
+ return new StringBuilder()
+ .append("[InstanceSchedulingRule ")
+ .append("cloud :\"")
+ .append(getCloud().getName())
+ .append("\"")
+ .append("instance :\"")
+ .append(getInstance().getName())
+ .append("\"")
+ .append("]")
+ .toString();
+ }
+
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceSchedulingRule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceStateJob.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceStateJob.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceStateJob.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.deltacloud.core.job;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance.State;
+
+/**
+ * @author André Dietisheim
+ */
+public class InstanceStateJob extends AbstractCloudElementJob {
+
+ private DeltaCloudInstance instance;
+ private State expectedState;
+
+ public InstanceStateJob(String name, DeltaCloudInstance instance, State expectedState)
{
+ super(name, instance.getDeltaCloud(), CLOUDELEMENT.INSTANCES);
+ this.instance = instance;
+ this.expectedState = expectedState;
+ }
+
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ String id = instance.getId();
+ getCloud().waitForState(id, expectedState, monitor);
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ protected ISchedulingRule getSchedulingRule() {
+ return new InstanceSchedulingRule(getCloud(), getCloudElement(), instance);
+ }
+
+ protected DeltaCloudInstance getInstance() {
+ return instance;
+ }
+
+ protected State getExpectedState() {
+ return expectedState;
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/InstanceStateJob.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-14 08:46:56
UTC (rev 27428)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-14 09:11:36
UTC (rev 27429)
@@ -1,5 +1,37 @@
+2010-12-14 André Dietisheim <adietish(a)redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
(WatchCreateJob):
+ [JBIDE-7594] switched WatchCreateJob to InstanceStateJob to have consistent blocking
with all other jobs
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
(asyncGetProfiles):
+ [JBIDE-7594] switched to AbstractCloudElementJob to have consistent blocking with all
other jobs
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
(asyncSetImagesToViewer):
+ [JBIDE-7594] switched to AbstractCloudElementJob to have consistent blocking with all
other jobs
+ *
src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
(asyncAddCloudElements):
+ *
src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java
(asyncAddCloudElements):
+ [JBIDE-7594] switched to AbstractCloudElementJob to have consistent blocking with all
other jobs
+ * src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java
(asyncAddCloudElements):
+ * src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java
(asyncAddCloudElements):
+ [JBIDE-7594] switched to AbstractCloudElementJob to have consistent blocking with all
other jobs
+ * src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java (refresh):
+ * src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java (refresh):
+ [JBIDE-7594] switched to AbstractCloudElementJob to have consistent blocking with all
other jobs
+ * src/org/jboss/tools/deltacloud/ui/commands/DestroyInstanceHandler.java
(destroyInstance):
+ [JBIDE-7594] switched to DestroyInstanceJob to have consistent blocking with all other
jobs
+ * src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java
(executeInstanceAction):
+ [JBIDE-7594] switched to InstanceActionJob to have consistent blocking with all other
jobs
+
+
2010-12-13 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
(asyncGetRealms):
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
(asyncSetImagesToViewer):
+ *
src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java
(asyncAddCloudElements):
+ * src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java
(asyncAddCloudElements):
+ * src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java
(asyncAddCloudElements):
+ * src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java:
+ * src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java:
+ *
src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
(asyncAddCloudElements):
+ [JBIDE-7594] switched all cloud element jobs to cloud element related jobs, so that
scheduling rules may be applied
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
(performFinish):
*
src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
(getStatusIcon):
* src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java (run):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -15,7 +15,7 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.ui.views.PerformInstanceActionJob;
+import org.jboss.tools.deltacloud.core.job.InstanceActionJob;
import org.jboss.tools.internal.deltacloud.ui.utils.StringUtils;
import org.jboss.tools.internal.deltacloud.ui.utils.StringUtils.IElementFormatter;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
@@ -27,25 +27,19 @@
*/
public abstract class AbstractInstanceHandler extends AbstractHandler implements IHandler
{
- protected void executeInstanceAction(DeltaCloudInstance instance,
DeltaCloudInstance.Action action, DeltaCloudInstance.State expectedState,
- String title, String message) {
+ protected void executeInstanceAction(DeltaCloudInstance instance,
DeltaCloudInstance.Action action,
+ DeltaCloudInstance.State expectedState, String title, String message) {
if (instance != null) {
- PerformInstanceActionJob t = new PerformInstanceActionJob(
- instance.getDeltaCloud(),
- instance,
- action,
- title,
- message,
- expectedState);
- t.setUser(true);
- t.schedule();
+ // TODO internationalize strings
+ new InstanceActionJob(message, instance, action, expectedState)
+ .schedule();
}
}
-
+
protected boolean isSingleInstanceSelected(ISelection selection) {
return UIUtils.isSingleSelection(selection, DeltaCloudInstance.class);
}
-
+
@SuppressWarnings("unchecked")
protected String getInstanceNames(ISelection selection) {
return StringUtils.getFormattedString(((IStructuredSelection) selection).toList(),
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DestroyInstanceHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DestroyInstanceHandler.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DestroyInstanceHandler.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -22,19 +22,15 @@
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.common.log.StatusFactory;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.core.job.DestroyCloudInstanceJob;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.deltacloud.ui.views.PerformDestroyInstanceActionThread;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Andre Dietisheim
*/
public class DestroyInstanceHandler extends AbstractInstanceHandler {
-
- private final static String DESTROYING_INSTANCE_TITLE =
"DestroyingInstance.title"; //$NON-NLS-1$
- private final static String DESTROYING_INSTANCE_MSG =
"DestroyingInstance.msg"; //$NON-NLS-1$
-
private final static String DESTROY_INSTANCE_TITLE =
"DestroyInstancesDialog.title"; //$NON-NLS-1$
private final static String DESTROY_INSTANCE_MSG =
"DestroyInstancesDialog.msg"; //$NON-NLS-1$
@@ -61,10 +57,11 @@
@SuppressWarnings("unchecked")
private void destroyWithDialog(IStructuredSelection selection) {
- List<DeltaCloudInstance> deltaCloudInstances =
UIUtils.adapt((List<DeltaCloudInstance>) selection.toList(),
DeltaCloudInstance.class);
+ List<DeltaCloudInstance> deltaCloudInstances =
+ UIUtils.adapt((List<DeltaCloudInstance>)
selection.toList(),DeltaCloudInstance.class);
DeltaCloudInstanceDialog dialog = new DeltaCloudInstanceDialog(
UIUtils.getActiveShell()
- , deltaCloudInstances
+ , deltaCloudInstances
, CVMessages.getString(DESTROY_INSTANCE_TITLE)
, CVMessages.getString(DESTROY_INSTANCE_MSG));
dialog.setInitialElementSelections(deltaCloudInstances);
@@ -81,13 +78,8 @@
private void destroyInstance(DeltaCloudInstance instance) {
if (instance != null) {
- PerformDestroyInstanceActionThread t = new PerformDestroyInstanceActionThread(
- instance.getDeltaCloud(),
- instance,
- CVMessages.getString(DESTROYING_INSTANCE_TITLE),
- CVMessages.getFormattedString(DESTROYING_INSTANCE_MSG, new String[] {
instance.getName() }));
- t.setUser(true);
- t.schedule();
+ new DestroyCloudInstanceJob("Destroy" + instance.getName(), instance)
+ .schedule();
}
}
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -58,9 +58,7 @@
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
try {
- monitor.worked(1);
cloud.loadChildren();
- monitor.done();
} catch (DeltaCloudMultiException e) {
return ErrorUtils.createMultiStatus(e);
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -15,7 +15,8 @@
import org.eclipse.core.runtime.Status;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
/**
* @author Andre Dietisheim
@@ -24,7 +25,7 @@
protected void refresh(final DeltaCloud cloud) {
// TODO: internationalize strings
- new AbstractCloudJob("Refreshing images on cloud " + cloud.getName(), cloud)
{
+ new AbstractCloudElementJob("Refreshing images on cloud " + cloud.getName(),
cloud, CLOUDELEMENT.IMAGES) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -15,7 +15,8 @@
import org.eclipse.core.runtime.Status;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
/**
* @author Andre Dietisheim
@@ -25,17 +26,16 @@
protected void refresh(final DeltaCloud cloud) {
if (cloud != null) {
// TODO: internationalize strings
- new AbstractCloudJob("Refreshing instances on cloud " + cloud.getName(),
cloud) {
+ new AbstractCloudElementJob("Refreshing instances on cloud " +
cloud.getName(), cloud,
+ CLOUDELEMENT.INSTANCES) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- monitor.worked(1);
cloud.loadInstances();
- monitor.done();
return Status.OK_STATUS;
}
- }.setUser(true);
+ }.schedule();
}
}
}
Deleted:
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-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -1,66 +0,0 @@
-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,
- // cancel the previous job and then go on performing this action
- Job job = cloud.getInstanceJob(id);
- if (job != null) {
- job.cancel();
- try {
- job.join();
- } catch (InterruptedException e) {
- // do nothing, this is ok
- }
- }
- cloud.registerInstanceJob(id, this);
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- try {
- cloud.performInstanceAction(instance.getId(), DeltaCloudInstance.Action.DESTROY);
- } catch (DeltaCloudException e) {
- // TODO internationalize strings
- ErrorUtils.handleError("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;
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views;
-
-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.dialogs.ErrorDialog;
-import org.eclipse.swt.widgets.Display;
-import org.jboss.tools.common.log.StatusFactory;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.ui.Activator;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
-
-public class PerformInstanceActionJob extends Job {
-
- private static final String INSTANCEACTION_ERROR_TITLE =
"InstanceActionError.title"; //$NON-NLS-1$
- private static final String INSTANCEACTION_ERROR_MESSAGE =
"InstanceActionError.msg"; //$NON-NLS-1$
-
- private DeltaCloud cloud;
- private DeltaCloudInstance instance;
- private DeltaCloudInstance.Action action;
- private String taskName;
- private DeltaCloudInstance.State expectedState;
-
- public PerformInstanceActionJob(DeltaCloud cloud, DeltaCloudInstance instance,
- DeltaCloudInstance.Action action, String title, String taskName,
DeltaCloudInstance.State expectedState) {
- super(title);
- this.cloud = cloud;
- this.instance = instance;
- this.action = action;
- this.taskName = taskName;
- this.expectedState = expectedState;
- }
-
- @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
- cancelPreviousJob(id);
- cloud.performInstanceAction(id, action);
- cloud.waitForState(id, expectedState, pm);
- } catch (Exception e) {
- final IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
e.getMessage(), e);
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- ErrorDialog.openError(
- UIUtils.getActiveShell(),
- CVMessages.getString(INSTANCEACTION_ERROR_TITLE),
- CVMessages.getFormattedString(INSTANCEACTION_ERROR_MESSAGE, action.getName(),
instance.getName()),
- status);
- }
- });
-
- } finally {
- cloud.removeInstanceJob(id, this);
- pm.done();
- }
- return Status.OK_STATUS;
- }
-
- private void cancelPreviousJob(String id) {
- Job job = cloud.getInstanceJob(id);
- if (job != null) {
- job.cancel();
- try {
- job.join();
- } catch (InterruptedException e) {
- // do nothing, this is ok
- }
- }
- }
-}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -21,7 +21,8 @@
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.IImageFilter;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
@@ -44,8 +45,8 @@
@Override
protected void asyncAddCloudElements() {
setLoadingIndicator();
- new AbstractCloudJob(
- MessageFormat.format("Get images from cloud {0}", getModel().getName()),
getModel()) {
+ new AbstractCloudElementJob(
+ MessageFormat.format("Get images from cloud {0}", getModel().getName()),
getModel(), CLOUDELEMENT.IMAGES) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -21,7 +21,8 @@
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.core.IInstanceFilter;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
@@ -44,8 +45,9 @@
@Override
protected void asyncAddCloudElements() {
setLoadingIndicator();
- new AbstractCloudJob(
- MessageFormat.format("Get instances from cloud {0}", getModel().getName()),
getModel()) {
+ new AbstractCloudElementJob(
+ MessageFormat.format("Get instances from cloud {0}", getModel().getName()),
getModel(),
+ CLOUDELEMENT.INSTANCES) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
@@ -55,7 +57,7 @@
addChildren(instances);
expand();
return Status.OK_STATUS;
- } catch(DeltaCloudException e) {
+ } catch (DeltaCloudException e) {
clearChildren();
throw e;
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -24,7 +24,8 @@
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.ICloudElementFilter;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
/**
* @author Jeff Johnston
@@ -99,8 +100,8 @@
@Override
protected void asyncAddCloudElements(final DeltaCloud cloud) {
- new AbstractCloudJob(
- MessageFormat.format("Get images from cloud {0}", cloud.getName()), cloud)
{
+ new AbstractCloudElementJob(
+ MessageFormat.format("Get images from cloud {0}", cloud.getName()), cloud,
CLOUDELEMENT.IMAGES) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -26,7 +26,8 @@
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.core.ICloudElementFilter;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
/**
@@ -124,8 +125,8 @@
@Override
protected void asyncAddCloudElements(final DeltaCloud cloud) {
- new AbstractCloudJob(
- MessageFormat.format("Get instances from cloud {0}", cloud.getName()),
cloud) {
+ new AbstractCloudElementJob(
+ MessageFormat.format("Get instances from cloud {0}", cloud.getName()),
cloud, CLOUDELEMENT.INSTANCES) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -32,7 +32,8 @@
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.IImageFilter;
import org.jboss.tools.deltacloud.core.ImageFilter;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
import
org.jboss.tools.deltacloud.ui.views.cloudelements.ImageViewLabelAndContentProvider;
@@ -301,8 +302,8 @@
}
private void asyncSetImagesToViewer() {
- new AbstractCloudJob(
- MessageFormat.format("Get images from cloud {0}", cloud.getName()), cloud)
{
+ new AbstractCloudElementJob(
+ MessageFormat.format("Get images from cloud {0}", cloud.getName()), cloud,
CLOUDELEMENT.IMAGES) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -63,7 +63,8 @@
import org.jboss.tools.deltacloud.core.DeltaCloudHardwareProfile;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.DeltaCloudRealm;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
import
org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.MandatoryStringValidator;
@@ -528,7 +529,7 @@
private void asyncGetRealms() {
// TODO: internationalize strings
- new AbstractCloudJob("Get realms", cloud) {
+ new AbstractCloudElementJob("Get realms", cloud, CLOUDELEMENT.REALMS) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws Exception {
@@ -545,7 +546,7 @@
private void asyncGetProfiles() {
// TODO: internationalize strings
- new AbstractCloudJob("Get Profiles", cloud) {
+ new AbstractCloudElementJob("Get Profiles", cloud, CLOUDELEMENT.PROFILES) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws Exception {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2010-12-14
08:46:56 UTC (rev 27428)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2010-12-14
09:11:36 UTC (rev 27429)
@@ -16,7 +16,6 @@
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.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
@@ -27,6 +26,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
+import org.jboss.tools.deltacloud.core.job.InstanceStateJob;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
@@ -40,7 +40,6 @@
private final static String CONFIRM_CREATE_TITLE = "ConfirmCreate.title";
//$NON-NLS-1$
private final static String CONFIRM_CREATE_MSG = "ConfirmCreate.msg";
//$NON-NLS-1$
private final static String DONT_SHOW_THIS_AGAIN_MSG =
"DontShowThisAgain.msg"; //$NON-NLS-1$
- private final static String STARTING_INSTANCE_MSG = "StartingInstance.msg";
//$NON-NLS-1$
private final static String STARTING_INSTANCE_TITLE =
"StartingInstance.title"; //$NON-NLS-1$
protected NewInstancePage mainPage;
@@ -63,7 +62,7 @@
@Override
public void addPages() {
mainPage = new NewInstancePage(cloud);
- if( image != null )
+ if (image != null)
mainPage.setImage(image);
addPage(mainPage);
}
@@ -73,56 +72,39 @@
return mainPage.isPageComplete();
}
- private class WatchCreateJob extends Job {
+ private class WatchCreateJob extends InstanceStateJob {
- private DeltaCloud cloud;
- private String instanceId;
- private String instanceName;
-
- public WatchCreateJob(String title, DeltaCloud cloud,
- String instanceId, String instanceName) {
- super(title);
- this.cloud = cloud;
- this.instanceId = instanceId;
- this.instanceName = instanceName;
+ public WatchCreateJob(DeltaCloudInstance instance) {
+ super(WizardMessages.getString(STARTING_INSTANCE_TITLE), instance,
DeltaCloudInstance.State.RUNNING);
+ setUser(true);
}
- public IStatus run(IProgressMonitor pm) {
- if (!pm.isCanceled()) {
- DeltaCloudInstance instance = null;
- try {
- pm.beginTask(
- WizardMessages.getFormattedString(STARTING_INSTANCE_MSG, new String[] {
instanceName }),
- IProgressMonitor.UNKNOWN);
- pm.worked(1);
- cloud.registerInstanceJob(instanceId, this);
- instance = cloud.waitWhilePending(instanceId, pm);
- } catch (Exception e) {
- // do nothing
- } finally {
- cloud.replaceInstance(instance);
- cloud.removeInstanceJob(instanceId, this);
- String hostname = RSEUtils.createHostName(instance);
- if (hostname != null && hostname.length() > 0 && isAutoconnect())
{
- try {
- String connectionName = RSEUtils.createConnectionName(instance);
- IHost host = RSEUtils.createHost(connectionName,
+ @Override
+ public IStatus doRun(IProgressMonitor monitor) {
+ // DeltaCloudInstance instance = null;
+ try {
+ super.doRun(monitor);
+ } catch (Exception e) {
+ // do nothing
+ } finally {
+ // cloud.replaceInstance(instance);
+ String hostname = RSEUtils.createHostName(instance);
+ if (hostname != null && hostname.length() > 0 && isAutoconnect())
{
+ try {
+ String connectionName = RSEUtils.createConnectionName(instance);
+ IHost host = RSEUtils.createHost(connectionName,
RSEUtils.createHostName(instance),
RSEUtils.getSSHOnlySystemType(),
RSEUtils.getSystemRegistry());
- RSEUtils.connect(connectionName, RSEUtils.getConnectorService(host));
- } catch (Exception e) {
- return ErrorUtils.handleError("Error", "Could not launch remote
system explorer for instance \""
- + instance.getName() + "\"", e, getShell());
- }
+ RSEUtils.connect(connectionName, RSEUtils.getConnectorService(host));
+ } catch (Exception e) {
+ return ErrorUtils.handleError("Error",
+ "Could not launch remote system explorer for instance \""
+ + instance.getName() + "\"", e, getShell());
}
- pm.done();
}
- return Status.OK_STATUS;
- } else {
- pm.done();
- return Status.CANCEL_STATUS;
}
+ return Status.OK_STATUS;
}
private boolean isAutoconnect() {
@@ -176,12 +158,7 @@
result = true;
}
if (instance != null &&
instance.getState().equals(DeltaCloudInstance.State.PENDING)) {
- final String instanceId = instance.getId();
- final String instanceName = name;
- Job job = new WatchCreateJob(WizardMessages.getString(STARTING_INSTANCE_TITLE),
- cloud, instanceId, instanceName);
- job.setUser(true);
- job.schedule();
+ new WatchCreateJob(instance).schedule();
}
} catch (DeltaCloudException ex) {
e = ex;