Author: adietish
Date: 2010-11-16 11:27:02 -0500 (Tue, 16 Nov 2010)
New Revision: 26627
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/CVInstancesCategoryElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageViewLabelAndContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java
Log:
[JBIDE-7597] load images / instances now throw of DeltaCloudExceptions (exceptions are not
swallowed any longer), errors while loading images/instances are now reported (exceptions
are not swallowed any longer)
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-16 16:22:05
UTC (rev 26626)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-16 16:27:02
UTC (rev 26627)
@@ -1,5 +1,12 @@
2010-11-16 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java
(inputChanged):
+ * src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java (getKey):
+ [JBIDE-7597] errors while loading images/instances are now reported (exceptions are not
swallowed any longer)
+ * src/org/jboss/tools/deltacloud/ui/views/ImageViewLabelAndContentProvider.java
(inputChanged):
+ [JBIDE-7597] using ErrorUtils now (removed code duplication)
+ * src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java (getChildren):
+ [JBIDE-7597] errors while loading images/instances are now reported (exceptions are not
swallowed any longer)
* src/org/jboss/tools/deltacloud/ui/RSEUtils.java (createHostName):
[JBIDE-7603] added null check
* src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java (run):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-11-16
16:22:05 UTC (rev 26626)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-11-16
16:27:02 UTC (rev 26627)
@@ -13,10 +13,12 @@
import java.util.ArrayList;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Display;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.core.IInstanceFilter;
import org.jboss.tools.deltacloud.core.IInstanceListListener;
+import org.jboss.tools.deltacloud.ui.ErrorUtils;
public class CVInstancesCategoryElement extends CVCategoryElement implements
IInstanceListListener {
@@ -67,11 +69,18 @@
public Object[] getChildren() {
if (!initialized) {
DeltaCloud cloud = (DeltaCloud) getElement();
- cloud.removeInstanceListListener(this);
- DeltaCloudInstance[] instances = filter(cloud.getCurrInstances());
- addInstances(instances);
- initialized = true;
- cloud.addInstanceListListener(this);
+ try {
+ cloud.removeInstanceListListener(this);
+ DeltaCloudInstance[] instances = filter(cloud.getCurrInstances());
+ addInstances(instances);
+ initialized = true;
+ cloud.addInstanceListListener(this);
+ } catch (Exception e) {
+ ErrorUtils.openErrorDialog(
+ "Error",
+ "Colud not get instances from cloud " + cloud.getName(),
+ e, Display.getDefault().getActiveShell());
+ }
}
return super.getChildren();
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageViewLabelAndContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageViewLabelAndContentProvider.java 2010-11-16
16:22:05 UTC (rev 26626)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageViewLabelAndContentProvider.java 2010-11-16
16:27:02 UTC (rev 26627)
@@ -15,18 +15,16 @@
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.common.log.StatusFactory;
+import org.eclipse.swt.widgets.Display;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.IImageFilter;
-import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.deltacloud.ui.ErrorUtils;
public class ImageViewLabelAndContentProvider extends BaseLabelProvider implements
IStructuredContentProvider,
ITableLabelProvider {
@@ -90,19 +88,14 @@
if (newInput instanceof DeltaCloudImage[]) {
images = filter((DeltaCloudImage[]) newInput);
} else {
+ cloud = (DeltaCloud) newInput;
try {
- cloud = (DeltaCloud) newInput;
images = filter(cloud.getCurrImages());
} catch (Exception e) {
- IStatus status = StatusFactory.getInstance(
- IStatus.ERROR,
- Activator.PLUGIN_ID,
- e.getMessage(),
- e);
- // TODO: internationalize strings
- ErrorDialog.openError(viewer.getControl().getShell(),
+ ErrorUtils.openErrorDialog(
"Error",
- "Cloud not get images from cloud " + cloud.getName(), status);
+ "Could not get images for cloud " + cloud.getName(),
+ e, Display.getDefault().getActiveShell());
}
}
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java 2010-11-16
16:22:05 UTC (rev 26626)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java 2010-11-16
16:27:02 UTC (rev 26627)
@@ -12,19 +12,22 @@
import java.util.List;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
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;
import org.jboss.tools.internal.deltacloud.ui.utils.CloudViewElementUtils;
public class InstancePropertySource implements IPropertySource {
private static final String PROPERTY_NAME = "deltacloud.views.instance.name";
//$NON-NLS-1$
private static final String PROPERTY_ID = "deltacloud.views.instance.id";
//$NON-NLS-1$
- public static final String PROPERTY_OWNER =
"deltacloud.views.instance.owner"; //$NON-NLS-1$
- public static final String PROPERTY_STATE =
"deltacloud.views.instance.state"; //$NON-NLS-1$
+ public static final String PROPERTY_OWNER = "deltacloud.views.instance.owner";
//$NON-NLS-1$
+ public static final String PROPERTY_STATE = "deltacloud.views.instance.state";
//$NON-NLS-1$
private static final String PROPERTY_HOSTNAME =
"deltacloud.views.instance.hostname"; //$NON-NLS-1$
private static final String PROPERTY_KEYNAME =
"deltacloud.views.instance.keyname"; //$NON-NLS-1$
private static final String PROPERTY_PROFILEID =
"deltacloud.views.instance.profileid"; //$NON-NLS-1$
@@ -39,15 +42,16 @@
private static final String PROPERTY_PROFILEID_TITLE =
"PropertyProfileId.title"; //$NON-NLS-1$
private static final String PROPERTY_REALMID_TITLE = "PropertyRealmId.title";
//$NON-NLS-1$
private static final String PROPERTY_IMAGEID_TITLE = "PropertyImageId.title";
//$NON-NLS-1$
-
+
private IPropertyDescriptor[] propertyDescriptors;
private DeltaCloudInstance instance;
private DeltaCloud cloud;
+
public InstancePropertySource(CVInstanceElement element, Object o) {
cloud = CloudViewElementUtils.getCloud(element);
- instance = (DeltaCloudInstance)o;
+ instance = (DeltaCloudInstance) o;
}
-
+
@Override
public Object getEditableValue() {
return null;
@@ -56,25 +60,25 @@
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
if (propertyDescriptors == null) {
- PropertyDescriptor nameDescriptor = new PropertyDescriptor(PROPERTY_NAME,
+ PropertyDescriptor nameDescriptor = new PropertyDescriptor(PROPERTY_NAME,
CVMessages.getString(PROPERTY_NAME_TITLE));
- PropertyDescriptor idDescriptor = new PropertyDescriptor(PROPERTY_ID,
+ PropertyDescriptor idDescriptor = new PropertyDescriptor(PROPERTY_ID,
CVMessages.getString(PROPERTY_ID_TITLE));
- PropertyDescriptor ownerDescriptor = new PropertyDescriptor(PROPERTY_OWNER,
+ PropertyDescriptor ownerDescriptor = new PropertyDescriptor(PROPERTY_OWNER,
CVMessages.getString(PROPERTY_OWNER_TITLE));
- PropertyDescriptor stateDescriptor = new PropertyDescriptor(PROPERTY_STATE,
+ PropertyDescriptor stateDescriptor = new PropertyDescriptor(PROPERTY_STATE,
CVMessages.getString(PROPERTY_STATE_TITLE));
- PropertyDescriptor hardwareDescriptor = new PropertyDescriptor(PROPERTY_PROFILEID,
+ PropertyDescriptor hardwareDescriptor = new PropertyDescriptor(PROPERTY_PROFILEID,
CVMessages.getString(PROPERTY_PROFILEID_TITLE));
- PropertyDescriptor realmDescriptor = new PropertyDescriptor(PROPERTY_REALMID,
+ PropertyDescriptor realmDescriptor = new PropertyDescriptor(PROPERTY_REALMID,
CVMessages.getString(PROPERTY_REALMID_TITLE));
- PropertyDescriptor imageDescriptor = new PropertyDescriptor(PROPERTY_IMAGEID,
+ PropertyDescriptor imageDescriptor = new PropertyDescriptor(PROPERTY_IMAGEID,
CVMessages.getString(PROPERTY_IMAGEID_TITLE));
- PropertyDescriptor hostnameDescriptor = new PropertyDescriptor(PROPERTY_HOSTNAME,
+ PropertyDescriptor hostnameDescriptor = new PropertyDescriptor(PROPERTY_HOSTNAME,
CVMessages.getString(PROPERTY_HOSTNAME_TITLE));
- PropertyDescriptor keyDescriptor = new PropertyDescriptor(PROPERTY_KEYNAME,
+ PropertyDescriptor keyDescriptor = new PropertyDescriptor(PROPERTY_KEYNAME,
CVMessages.getString(PROPERTY_KEYNAME_TITLE));
-
+
propertyDescriptors = new IPropertyDescriptor[] {
nameDescriptor,
idDescriptor,
@@ -105,14 +109,30 @@
if (id.equals(PROPERTY_IMAGEID))
return instance.getImageId();
if (id.equals(PROPERTY_KEYNAME)) {
- // At present (Deltacloud 0.0.7), the keyname is omitted
- // in the data passed back from a listInstances request.
- // If an instance is running and the keyname is missing,
- // we can refresh the instance by its id and this will give us
- // the full data. We can then replace the instance so that
- // it will be complete for future requests until a refresh gets the
- // entire list again.
- String key = instance.getKey();
+ return getKey();
+ }
+ if (id.equals(PROPERTY_STATE)) {
+ return instance.getState();
+ }
+ if (id.equals(PROPERTY_HOSTNAME)) {
+ List<String> hostnames = instance.getHostNames();
+ if (hostnames.size() >= 1)
+ return hostnames.get(0);
+ }
+ return null;
+ }
+
+ private Object getKey() {
+ // At present (Deltacloud 0.0.7), the keyname is omitted
+ // in the data passed back from a listInstances request.
+ // If an instance is running and the keyname is missing,
+ // we can refresh the instance by its id and this will give us
+ // the full data. We can then replace the instance so that
+ // it will be complete for future requests until a refresh gets the
+ // entire list again.
+ String key = null;
+ try {
+ key = instance.getKey();
if (!cloud.getType().equals(DeltaCloud.MOCK_TYPE)) {
if (instance.getState().equals(DeltaCloudInstance.RUNNING) && (key == null ||
key.length() == 0)) {
instance = cloud.refreshInstance(instance.getId());
@@ -123,17 +143,12 @@
}
}
}
- return key;
+ } catch (DeltaCloudException e) {
+ ErrorUtils.openErrorDialog(
+ "Error", "Could not get key for instance " +
instance.getName(),
+ e, Display.getDefault().getActiveShell());
}
- if (id.equals(PROPERTY_STATE)) {
- return instance.getState();
- }
- if (id.equals(PROPERTY_HOSTNAME)) {
- List<String> hostnames = instance.getHostNames();
- if (hostnames.size() >= 1)
- return hostnames.get(0);
- }
- return null;
+ return key;
}
@Override
@@ -141,7 +156,6 @@
return false;
}
-
@Override
public void resetPropertyValue(Object id) {
// do nothing
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java 2010-11-16
16:22:05 UTC (rev 26626)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java 2010-11-16
16:27:02 UTC (rev 26627)
@@ -20,11 +20,13 @@
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.core.IInstanceFilter;
+import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
public class InstanceViewLabelAndContentProvider extends BaseLabelProvider implements
IStructuredContentProvider,
@@ -83,7 +85,14 @@
instances = filter((DeltaCloudInstance[]) newInput);
} else {
cloud = (DeltaCloud) newInput;
- instances = filter(cloud.getCurrInstances());
+ try {
+ instances = filter(cloud.getCurrInstances());
+ } catch (Exception e) {
+ ErrorUtils.openErrorDialog(
+ "Error",
+ "Could not get instances for cloud " + cloud.getName(),
+ e, Display.getDefault().getActiveShell());
+ }
}
}
}