Author: adietish
Date: 2010-11-18 12:17:15 -0500 (Thu, 18 Nov 2010)
New Revision: 26726
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVRootElement.java
Log:
[JBIDE-7628] getClouds() can throw DeltaCloudException now (since it may trigger cloud
loading) -> added proper exception catching & reporting
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVRootElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVRootElement.java 2010-11-18
17:16:14 UTC (rev 26725)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVRootElement.java 2010-11-18
17:17:15 UTC (rev 26726)
@@ -27,21 +27,8 @@
public CVRootElement(TreeViewer viewer) {
super(DeltaCloudManager.getDefault(), "root"); //$NON-NLS-1$
this.viewer = viewer;
- loadClouds();
}
- private void loadClouds() {
- try {
- DeltaCloudManager.getDefault().loadClouds();
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- ErrorUtils.openErrorDialog(
- "Error",
- "Errors occurred while loading all clouds",
- e, Display.getDefault().getActiveShell());
- }
- }
-
@Override
public IPropertySource getPropertySource() {
// no property source for the root element
@@ -52,14 +39,23 @@
public Object[] getChildren() {
if (!initialized) {
DeltaCloudManager m = DeltaCloudManager.getDefault();
- DeltaCloud[] clouds = m.getClouds();
- for (int i = 0; i < clouds.length; ++i) {
- DeltaCloud cloud = clouds[i];
- CVCloudElement e = new CVCloudElement(cloud, cloud.getName(), viewer);
- addChild(e);
+ m.removeCloudManagerListener(this);
+ try {
+ DeltaCloud[] clouds = m.getClouds();
+ for (int i = 0; i < clouds.length; ++i) {
+ DeltaCloud cloud = clouds[i];
+ CVCloudElement e = new CVCloudElement(cloud, cloud.getName(), viewer);
+ addChild(e);
+ }
+ m.addCloudManagerListener(this);
+ initialized = true;
+ } catch (DeltaCloudException e) {
+ // TODO: internationalize strings
+ ErrorUtils.openErrorDialog(
+ "Error",
+ "Could not get all clouds",
+ e, Display.getDefault().getActiveShell());
}
- m.addCloudManagerListener(this);
- initialized = true;
}
return super.getChildren();
}
@@ -70,23 +66,31 @@
super.finalize();
}
- public void changeEvent(int type) {
+ public void cloudsChanged(int type) {
DeltaCloudManager m = DeltaCloudManager.getDefault();
- m.removeCloudManagerListener(this);
- DeltaCloud[] clouds = m.getClouds();
- for (int i = 0; i < clouds.length; ++i) {
- DeltaCloud cloud = clouds[i];
- CVCloudElement e = new CVCloudElement(cloud, cloud.getName(), viewer);
- addChild(e);
+ try {
+ m.removeCloudManagerListener(this);
+ DeltaCloud[] clouds = m.getClouds();
+ for (int i = 0; i < clouds.length; ++i) {
+ DeltaCloud cloud = clouds[i];
+ CVCloudElement e = new CVCloudElement(cloud, cloud.getName(), viewer);
+ addChild(e);
+ }
+ initialized = true;
+ m.addCloudManagerListener(this);
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ ((TreeViewer) viewer).refresh(this, false);
+ }
+ });
+ } catch (DeltaCloudException e) {
+ // TODO: internationalize strings
+ ErrorUtils.openErrorDialog(
+ "Error",
+ "Could not get all clouds",
+ e, Display.getDefault().getActiveShell());
}
- initialized = true;
- m.addCloudManagerListener(this);
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- ((TreeViewer) viewer).refresh(this, false);
- }
- });
}
}
Show replies by date