Author: adietish
Date: 2010-11-15 12:34:15 -0500 (Mon, 15 Nov 2010)
New Revision: 26571
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/RefreshImagesHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java
Log:
[JBIDE-7599] added background jobs
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-11-15
17:30:22 UTC (rev 26570)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java 2010-11-15
17:34:15 UTC (rev 26571)
@@ -14,16 +14,15 @@
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.handlers.HandlerUtil;
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.ui.Activator;
import org.jboss.tools.deltacloud.ui.views.CloudViewElement;
import org.jboss.tools.internal.deltacloud.ui.utils.CloudViewElementUtils;
@@ -39,38 +38,35 @@
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
CloudViewElement cloudViewElement = UIUtils.getFirstAdaptedElement(selection,
CloudViewElement.class);
- try {
- refresh(cloudViewElement);
- } catch (Exception e) {
- IStatus status = StatusFactory.getInstance(
- IStatus.ERROR,
- Activator.PLUGIN_ID,
- e.getMessage(),
- e);
- // TODO: internationalize strings
- ErrorDialog.openError(Display.getDefault().getActiveShell(),
- "Error",
- "Cloud not get load children for " + getCloudName(cloudViewElement),
status);
- }
+ refresh(cloudViewElement);
}
return Status.OK_STATUS;
}
- private String getCloudName(CloudViewElement cloudViewElement) {
- DeltaCloud cloud = CloudViewElementUtils.getCloud(cloudViewElement);
- if (cloud == null) {
- return "";
- } else {
- return cloud.getName();
- }
- }
-
- private void refresh(CloudViewElement cloudViewElement) throws DeltaCloudException {
+ private void refresh(final CloudViewElement cloudViewElement) {
if (cloudViewElement != null) {
- DeltaCloud cloud = CloudViewElementUtils.getCloud(cloudViewElement);
+ final DeltaCloud cloud = CloudViewElementUtils.getCloud(cloudViewElement);
if (cloud != null) {
- cloud.loadChildren();
+ // TODO: internationalize strings
+ new Job("Refreshing images and instances on " + cloud.getName()) {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ cloud.loadChildren();
+ } catch (Exception e) {
+ IStatus status = StatusFactory.getInstance(
+ IStatus.ERROR,
+ Activator.PLUGIN_ID,
+ e.getMessage(),
+ e);
+ // TODO: internationalize strings
+ return status;
+ }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
}
}
}
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-11-15
17:30:22 UTC (rev 26570)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java 2010-11-15
17:34:15 UTC (rev 26571)
@@ -14,16 +14,15 @@
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.handlers.HandlerUtil;
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.DeltaCloudImage;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
@@ -38,29 +37,36 @@
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
DeltaCloudImage deltaCloudImage = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudImage.class);
- try {
- refresh(deltaCloudImage);
- } catch (Exception e) {
- IStatus status = StatusFactory.getInstance(
- IStatus.ERROR,
- Activator.PLUGIN_ID,
- e.getMessage(),
- e);
- // TODO: internationalize strings
- ErrorDialog.openError(Display.getDefault().getActiveShell(),
- "Error",
- "Cloud not get load children for " +
deltaCloudImage.getDeltaCloud().getName(), status);
- }
+ refresh(deltaCloudImage);
}
return Status.OK_STATUS;
}
- private void refresh(DeltaCloudImage deltaCloudImage) throws DeltaCloudException {
+ private void refresh(DeltaCloudImage deltaCloudImage) {
if (deltaCloudImage != null) {
- DeltaCloud cloud = deltaCloudImage.getDeltaCloud();
+ final DeltaCloud cloud = deltaCloudImage.getDeltaCloud();
if (cloud != null) {
- cloud.loadChildren();
+ // TODO: internationalize strings
+ new Job("Refreshing images on cloud " + cloud.getName()) {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ cloud.loadChildren();
+ return Status.OK_STATUS;
+
+ } catch (Exception e) {
+ IStatus status = StatusFactory.getInstance(
+ IStatus.ERROR,
+ Activator.PLUGIN_ID,
+ e.getMessage(),
+ e);
+ return status;
+ }
+
+ }
+ }.schedule();
}
}
}
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-11-15
17:30:22 UTC (rev 26570)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java 2010-11-15
17:34:15 UTC (rev 26571)
@@ -14,16 +14,15 @@
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.handlers.HandlerUtil;
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.DeltaCloudInstance;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
@@ -38,30 +37,37 @@
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
DeltaCloudInstance deltaCloudInstance = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudInstance.class);
- try {
- refresh(deltaCloudInstance);
- } catch (Exception e) {
- IStatus status = StatusFactory.getInstance(
- IStatus.ERROR,
- Activator.PLUGIN_ID,
- e.getMessage(),
- e);
- // TODO: internationalize strings
- ErrorDialog.openError(Display.getDefault().getActiveShell(),
- "Error",
- "Cloud not get load children for " +
deltaCloudInstance.getDeltaCloud().getName(), status);
- }
+ refresh(deltaCloudInstance);
}
return Status.OK_STATUS;
}
- private void refresh(DeltaCloudInstance deltaCloudInstance) throws DeltaCloudException
{
+ private void refresh(final DeltaCloudInstance deltaCloudInstance) {
+ // TODO: internationalize strings
if (deltaCloudInstance != null) {
- DeltaCloud cloud = deltaCloudInstance.getDeltaCloud();
+ final DeltaCloud cloud = deltaCloudInstance.getDeltaCloud();
if (cloud != null) {
- cloud.loadChildren();
+ new Job("Refreshing instances on cloud " + cloud.getName()) {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ cloud.loadChildren();
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ IStatus status = StatusFactory.getInstance(
+ IStatus.ERROR,
+ Activator.PLUGIN_ID,
+ e.getMessage(),
+ e);
+ return status;
+ }
+ }
+
+ }.schedule();
}
}
+
}
}
Show replies by date