Author: adietish
Date: 2010-12-09 09:30:23 -0500 (Thu, 09 Dec 2010)
New Revision: 27278
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetImagesCommand.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetInstancesCommand.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/DeltaCloud.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryItem.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/AbstractCloudElementViewLabelAndContentProvider.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
Log:
[JBIDE-7848] separated the usecases: actively getting images/instances and passive
updates. You now get the images and dont need to trigger getting and get the update of it.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-09 14:28:38
UTC (rev 27277)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-09 14:30:23
UTC (rev 27278)
@@ -1,5 +1,11 @@
2010-12-09 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (loadImages):
+ (loadInstances):
+ (getInstances):
+ (getImages):
+ [JBIDE-7848] separated the usecases: actively getting images/instances and passive
updates. You now get the images and dont need to trigger getting and get the update of it.
* src/org/jboss/tools/deltacloud/core/DeltaCloudImage.java:
[JBIDE-7849] removed shadowing instance variable to DeltaCloud
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-09
14:28:38 UTC (rev 27277)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-09
14:30:23 UTC (rev 27278)
@@ -347,6 +347,7 @@
private void loadInstances() throws DeltaCloudException {
try {
getInstancesRepository().add(client.listInstances(), this);
+ notifyImageListListeners(images.get());
} catch (DeltaCloudClientException e) {
throw new DeltaCloudException(MessageFormat.format("Could not load instances of
cloud {0}: {1}",
getName(), e.getMessage()), e);
@@ -380,11 +381,11 @@
*
* @throws DeltaCloudException
*/
- protected void asyncGetInstances() throws DeltaCloudException {
+ public DeltaCloudInstance[] getInstances() throws DeltaCloudException {
if (instances == null) {
loadInstances();
}
- notifyInstanceListListeners(instances.get());
+ return instances.get();
}
private DeltaCloudImagesRepository getImagesRepository() {
@@ -394,13 +395,11 @@
return images;
}
- protected void asyncGetImages() throws DeltaCloudException {
+ public DeltaCloudImage[] getImages() throws DeltaCloudException {
if (images == null) {
loadImages();
}
- // TODO: remove notification with all instances, replace by
- // notifying the changed instance
- notifyImageListListeners(getImagesRepository().get());
+ return images.get();
}
/**
@@ -537,6 +536,7 @@
private void loadImages() throws DeltaCloudException {
try {
getImagesRepository().add(client.listImages(), this);
+ notifyImageListListeners(images.get());
} catch (DeltaCloudClientException e) {
clearImages();
throw new DeltaCloudException(MessageFormat.format("Could not load images of
cloud {0}: {1}",
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetImagesCommand.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetImagesCommand.java 2010-12-09
14:28:38 UTC (rev 27277)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetImagesCommand.java 2010-12-09
14:30:23 UTC (rev 27278)
@@ -1,47 +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.core;
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
-
-/**
- * @author Andre Dietisheim
- */
-public class GetImagesCommand extends AbstractDeltaCloudCommand {
-
- public GetImagesCommand(DeltaCloud cloud) {
- super(cloud);
- }
-
- public void execute() {
- // TODO: internationalize strings
- new AbstractCloudJob(
- MessageFormat.format("Get images from cloud {0}", getCloud().getName()),
getCloud()) {
-
- @Override
- protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- asyncGetImages();
- return Status.OK_STATUS;
- }
-
-
- }.schedule();
- }
-
- protected void asyncGetImages() throws DeltaCloudException {
- getCloud().asyncGetImages();
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetInstancesCommand.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetInstancesCommand.java 2010-12-09
14:28:38 UTC (rev 27277)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetInstancesCommand.java 2010-12-09
14:30:23 UTC (rev 27278)
@@ -1,47 +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.core;
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
-
-/**
- * @author Andre Dietisheim
- */
-public class GetInstancesCommand extends AbstractDeltaCloudCommand {
-
- public GetInstancesCommand(DeltaCloud cloud) {
- super(cloud);
- }
-
- public void execute() {
- // TODO: internationalize strings
- new AbstractCloudJob(
- MessageFormat.format("Get instances from cloud {0}", getCloud().getName()),
getCloud()) {
-
- @Override
- protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- asyncGetInstances();
- return Status.OK_STATUS;
- }
-
-
- }.schedule();
- }
-
- protected void asyncGetInstances() throws DeltaCloudException {
- getCloud().asyncGetInstances();
- }
-}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-09 14:28:38
UTC (rev 27277)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-09 14:30:23
UTC (rev 27278)
@@ -1,5 +1,16 @@
2010-12-09 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
+ (.modifyText):
+ (asyncSetImagesToViewer):
+ * src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java
(asyncAddCloudElements):
+ * src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java
(asyncAddCloudElements):
+ *
src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java
(asyncAddCloudElements):
+ *
src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
(asyncAddCloudElements):
+ * src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryItem.java
+ (getChildren):
+ (asyncAddCloudElements):
+ [JBIDE-7848] separated the usecases: actively getting images/instances and passive
updates. You now get the images and dont need to trigger getting and get the update of it.
*
src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java
(.selectionChanged):
[JBIDE-7849] only change selected cloud if a new cloud has been selected
*
src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java
(dispose):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryItem.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryItem.java 2010-12-09
14:28:38 UTC (rev 27277)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryItem.java 2010-12-09
14:30:23 UTC (rev 27278)
@@ -34,8 +34,7 @@
@Override
public Object[] getChildren() {
if (!initialized.get()) {
-// setLoadingIndicator();
- asyncGetCloudElements();
+ asyncAddCloudElements();
initialized.set(true);
}
return super.getChildren();
@@ -45,7 +44,7 @@
children.add(new LoadingItem(this, viewer));
}
- protected abstract void asyncGetCloudElements();
+ protected abstract void asyncAddCloudElements();
protected void addChildren(Object[] modelElements) {
if (modelElements.length > NumericFoldingItem.FOLDING_SIZE) {
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-09
14:28:38 UTC (rev 27277)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java 2010-12-09
14:30:23 UTC (rev 27278)
@@ -12,13 +12,16 @@
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.jface.viewers.TreeViewer;
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.core.GetImagesCommand;
import org.jboss.tools.deltacloud.core.IImageFilter;
import org.jboss.tools.deltacloud.core.IImageListListener;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
@@ -39,21 +42,25 @@
}
@Override
- protected void asyncGetCloudElements() {
+ protected void asyncAddCloudElements() {
setLoadingIndicator();
- new GetImagesCommand(getCloud()){
+ new AbstractCloudJob(
+ MessageFormat.format("Get images from cloud {0}", getCloud().getName()),
getCloud()) {
@Override
- protected void asyncGetImages() throws DeltaCloudException {
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
try {
- super.asyncGetImages();
+ DeltaCloudImage[] images = getCloud().getImages();
+ clearChildren();
+ addChildren(images);
+ expand();
+ return Status.OK_STATUS;
} catch(DeltaCloudException e) {
clearChildren();
throw e;
}
}
-
- }.execute();
+ }.schedule();
}
@Override
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-09
14:28:38 UTC (rev 27277)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java 2010-12-09
14:30:23 UTC (rev 27278)
@@ -12,13 +12,16 @@
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.jface.viewers.TreeViewer;
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.core.GetInstancesCommand;
import org.jboss.tools.deltacloud.core.IInstanceFilter;
import org.jboss.tools.deltacloud.core.IInstanceListListener;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
@@ -39,21 +42,26 @@
}
@Override
- protected void asyncGetCloudElements() {
+ protected void asyncAddCloudElements() {
setLoadingIndicator();
- new GetInstancesCommand(getCloud()){
+ new AbstractCloudJob(
+ MessageFormat.format("Get instances from cloud {0}", getCloud().getName()),
getCloud()) {
@Override
- protected void asyncGetInstances() throws DeltaCloudException {
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
try {
- super.asyncGetInstances();
+ DeltaCloudInstance[] instances = getCloud().getInstances();
+ clearChildren();
+ addChildren(instances);
+ expand();
+ return Status.OK_STATUS;
} catch(DeltaCloudException e) {
clearChildren();
throw e;
}
}
+ }.schedule();
- }.execute();
}
@Override
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java 2010-12-09
14:28:38 UTC (rev 27277)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java 2010-12-09
14:30:23 UTC (rev 27278)
@@ -54,7 +54,7 @@
removeListener(currentCloud);
this.currentCloud = (DeltaCloud) newInput;
addListener(currentCloud);
- asyncGetCloudElements(currentCloud);
+ asyncAddCloudElements(currentCloud);
}
public void listChanged(final DeltaCloud cloud, final CLOUDELEMENT[] cloudElements) {
@@ -69,14 +69,13 @@
&& cloud.getName().equals(currentCloud.getName());
}
- private void addToViewer(final CLOUDELEMENT[] cloudElements) {
+ protected void addToViewer(final CLOUDELEMENT[] cloudElements) {
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
try {
Object[] elements = filter(getFilter(currentCloud), cloudElements);
-// viewer.getTable().clearAll();
viewer.add(elements);
} catch (DeltaCloudException e) {
// TODO: internationalize strings
@@ -121,5 +120,5 @@
protected abstract ICloudElementFilter<CLOUDELEMENT> getCloudFilter(DeltaCloud
cloud);
- protected abstract void asyncGetCloudElements(DeltaCloud cloud);
+ protected abstract void asyncAddCloudElements(DeltaCloud cloud);
}
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-09
14:28:38 UTC (rev 27277)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java 2010-12-09
14:30:23 UTC (rev 27278)
@@ -10,16 +10,21 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.ui.views.cloudelements;
+import java.text.MessageFormat;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.swt.graphics.Image;
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.core.GetImagesCommand;
import org.jboss.tools.deltacloud.core.ICloudElementFilter;
import org.jboss.tools.deltacloud.core.IImageListListener;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
/**
* @author Jeff Johnston
@@ -93,8 +98,20 @@
}
@Override
- protected void asyncGetCloudElements(DeltaCloud cloud) {
- new GetImagesCommand(cloud).execute();
+ protected void asyncAddCloudElements(final DeltaCloud cloud) {
+ new AbstractCloudJob(
+ MessageFormat.format("Get images from cloud {0}", cloud.getName()), cloud)
{
+
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
+ try {
+ addToViewer(cloud.getImages());;
+ return Status.OK_STATUS;
+ } catch(DeltaCloudException e) {
+ throw e;
+ }
+ }
+ }.schedule();
}
@Override
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-09
14:28:38 UTC (rev 27277)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java 2010-12-09
14:30:23 UTC (rev 27278)
@@ -10,18 +10,23 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.ui.views.cloudelements;
+import java.text.MessageFormat;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
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.core.GetInstancesCommand;
import org.jboss.tools.deltacloud.core.ICloudElementFilter;
import org.jboss.tools.deltacloud.core.IInstanceListListener;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
/**
@@ -122,8 +127,20 @@
}
@Override
- protected void asyncGetCloudElements(DeltaCloud cloud) {
- new GetInstancesCommand(cloud).execute();
+ protected void asyncAddCloudElements(final DeltaCloud cloud) {
+ new AbstractCloudJob(
+ MessageFormat.format("Get instances from cloud {0}", cloud.getName()),
cloud) {
+
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
+ try {
+ addToViewer(cloud.getInstances());;
+ return Status.OK_STATUS;
+ } catch(DeltaCloudException e) {
+ throw e;
+ }
+ }
+ }.schedule();
}
@Override
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-09
14:28:38 UTC (rev 27277)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java 2010-12-09
14:30:23 UTC (rev 27278)
@@ -1,5 +1,10 @@
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.jface.layout.TableColumnLayout;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -23,17 +28,17 @@
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.deltacloud.core.AllImageFilter;
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.core.GetImagesCommand;
import org.jboss.tools.deltacloud.core.IImageFilter;
-import org.jboss.tools.deltacloud.core.IImageListListener;
import org.jboss.tools.deltacloud.core.ImageFilter;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
import
org.jboss.tools.deltacloud.ui.views.cloudelements.ImageViewLabelAndContentProvider;
import org.jboss.tools.deltacloud.ui.views.cloudelements.TableViewerColumnComparator;
-public class FindImagePage extends WizardPage implements IImageListListener {
+public class FindImagePage extends WizardPage {
private final static String NAME = "FindImage.name"; //$NON-NLS-1$
private final static String TITLE = "FindImage.title"; //$NON-NLS-1$
@@ -135,7 +140,7 @@
filter = new ImageFilter(cloud);
filter.setRules(newRules);
oldRules = newRules;
- new GetImagesCommand(cloud).execute();
+ asyncSetImagesToViewer();
}
}
setPageComplete(isComplete && !hasError);
@@ -295,14 +300,30 @@
validate();
}
- @Override
- public void listChanged(DeltaCloud cloud, final DeltaCloudImage[] images) {
+ private void asyncSetImagesToViewer() {
+ new AbstractCloudJob(
+ MessageFormat.format("Get images from cloud {0}", cloud.getName()), cloud)
{
+
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
+ try {
+ setViewerInput(cloud.getImages());
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ setViewerInput(new DeltaCloudImage[] {});
+ throw e;
+ }
+ }
+ }.schedule();
+ }
+
+ private void setViewerInput(final DeltaCloudImage[] images) {
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
viewer.setInput(images);
- }});
+ }
+ });
}
-
}