Author: adietish
Date: 2010-12-07 07:40:13 -0500 (Tue, 07 Dec 2010)
New Revision: 27210
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElementTypeMapper.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewLabelProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudElementViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootViewElement.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVCloudElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVCloudElementCategoryElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVImageElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVImagesCategoryElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVInstanceElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVInstancesCategoryElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVNumericFoldingElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVRootElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVTypeMapper.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewLabelProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudViewElement.java
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/GetImagesCommand.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetInstancesCommand.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/adapter/CloudViewElementAdapterFactory.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceHandler2.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DisconnectCloudHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.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/views/cloud/CloudViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java
Log:
[JBIDE-7819] loading imges and instances is now asyncronous.
[JBIDE-7569] displaying "Loading..." now when images or instances are being
loaded
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-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -160,7 +160,7 @@
if (!rules.equals(ruleString)) {
// TODO: remove notification with all instances, replace by
// notifying the changed instance
- notifyInstanceListListeners(instances.get());
+ notifyInstanceListListeners(getInstancesRepository().get());
}
}
@@ -187,7 +187,7 @@
String rules = getImageFilter().toString();
this.imageFilter = createImageFilter(ruleString);
if (!rules.equals(ruleString)) {
- notifyImageListListeners(images.get());
+ notifyImageListListeners(getImagesRepository().get());
}
}
@@ -342,11 +342,7 @@
*/
private void loadInstances() throws DeltaCloudException {
try {
- clearInstances();
- if (instances == null) {
- instances = new DeltaCloudInstancesRepository();
- }
- instances.add(client.listInstances(), this);
+ getInstancesRepository().add(client.listInstances(), this);
} catch (DeltaCloudClientException e) {
throw new DeltaCloudException(MessageFormat.format("Could not load instances of
cloud {0}: {1}",
getName(), e.getMessage()), e);
@@ -367,13 +363,19 @@
}
}
- protected DeltaCloudInstance[] getInstances() throws DeltaCloudException {
+ private DeltaCloudInstancesRepository getInstancesRepository() {
if (instances == null) {
- loadInstances();
+ instances = new DeltaCloudInstancesRepository();
}
- return instances.get();
+ return instances;
}
+ /**
+ * Gets the instances in async manner. The method does not return the
+ * instances but notifies observers of the instances.
+ *
+ * @throws DeltaCloudException
+ */
protected void asyncGetInstances() throws DeltaCloudException {
if (instances == null) {
loadInstances();
@@ -381,11 +383,11 @@
notifyInstanceListListeners(instances.get());
}
- protected DeltaCloudImage[] getImages() throws DeltaCloudException {
+ private DeltaCloudImagesRepository getImagesRepository() {
if (images == null) {
- loadImages();
+ images = new DeltaCloudImagesRepository();
}
- return images.get();
+ return images;
}
protected void asyncGetImages() throws DeltaCloudException {
@@ -394,12 +396,12 @@
}
// TODO: remove notification with all instances, replace by
// notifying the changed instance
- notifyImageListListeners(images.get());
+ notifyImageListListeners(getImagesRepository().get());
}
public DeltaCloudImage getImage(String id) throws DeltaCloudException {
DeltaCloudImage matchingImage = null;
- for (DeltaCloudImage image : getImages()) {
+ for (DeltaCloudImage image : getImagesRepository().get()) {
if (id.equals(image.getId())) {
matchingImage = image;
break;
@@ -438,12 +440,12 @@
replaceInstance(instance, instanceToReplace);
// TODO: remove notification with all instances, replace by
// notifying the changed instance
- notifyInstanceListListeners(instances.get());
+ notifyInstanceListListeners(getInstancesRepository().get());
}
}
private DeltaCloudInstance findInstanceById(String instanceId) {
- return instances.getById(instanceId);
+ return getInstancesRepository().getById(instanceId);
}
// TODO: remove duplicate code with #replaceInstance
@@ -458,7 +460,7 @@
if (!(deltaCloudInstance.getState().equals(DeltaCloudInstance.BOGUS))
&& !(currentInstance.getState().equals(deltaCloudInstance.getState()))) {
replaceInstance(deltaCloudInstance, currentInstance);
- notifyInstanceListListeners(instances.get());
+ notifyInstanceListListeners(getInstancesRepository().get());
}
} catch (DeltaCloudClientException e) {
// TODO: is this correct?
@@ -469,8 +471,8 @@
}
private void replaceInstance(DeltaCloudInstance deltaCloudInstance, DeltaCloudInstance
currentInstance) {
- instances.remove(currentInstance);
- instances.add(deltaCloudInstance);
+ getInstancesRepository().remove(currentInstance);
+ getInstancesRepository().add(deltaCloudInstance);
}
public boolean performInstanceAction(String instanceId, String actionId) throws
DeltaCloudException {
@@ -487,7 +489,7 @@
if (result) {
// TODO: remove notification with all instances, replace by
// notifying the changed instance
- notifyInstanceListListeners(instances.get());
+ notifyInstanceListListeners(getInstancesRepository().get());
}
return result;
} catch (DeltaCloudClientException e) {
@@ -522,12 +524,9 @@
*/
private void loadImages() throws DeltaCloudException {
try {
- clearImages();
- if (images == null) {
- images = new DeltaCloudImagesRepository();
- }
- images.add(client.listImages(), this);
+ getImagesRepository().add(client.listImages(), this);
} catch (DeltaCloudClientException e) {
+ clearImages();
throw new DeltaCloudException(MessageFormat.format("Could not load images of
cloud {0}: {1}",
getName(), e.getMessage()), e);
}
@@ -537,7 +536,7 @@
public DeltaCloudImage loadImage(String imageId) throws DeltaCloudException {
try {
Image image = client.listImages(imageId);
- return images.add(image, this);
+ return getImagesRepository().add(image, this);
} catch (DeltaCloudClientException e) {
throw new DeltaCloudException(e);
}
@@ -581,10 +580,9 @@
instance = client.createInstance(imageId, profileId, realmId, name, memory,
storage);
}
if (instance != null) {
- getInstances(); // make sure instances are initialized
- DeltaCloudInstance deltaCloudInstance = instances.add(instance, this);
+ DeltaCloudInstance deltaCloudInstance = getInstancesRepository().add(instance,
this);
deltaCloudInstance.setGivenName(name);
- notifyInstanceListListeners(instances.get());
+ notifyInstanceListListeners(getInstancesRepository().get());
return deltaCloudInstance;
}
} catch (DeltaCloudClientException e) {
Modified:
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-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetImagesCommand.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -32,10 +32,15 @@
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- getCloud().asyncGetImages();
+ asyncGetImages();
return Status.OK_STATUS;
}
+
}.schedule();
}
+
+ protected void asyncGetImages() throws DeltaCloudException {
+ getCloud().asyncGetImages();
+ }
}
Modified:
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-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetInstancesCommand.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -32,10 +32,15 @@
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- getCloud().asyncGetInstances();
+ 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-07 12:16:53
UTC (rev 27209)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-07 12:40:13
UTC (rev 27210)
@@ -2,7 +2,7 @@
* src/org/jboss/tools/deltacloud/ui/views/cloud/CVCloudElementCategoryElement.java
(setLoadingIndicator):
* src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudViewElement.java:
- [JBIDE-7819] I now show the user that things are being loaded ("Loading..."
node)
+ [JBIDE-7569] I now show the user that things are being loaded ("Loading..."
node)
* src/org/jboss/tools/deltacloud/ui/views/cloud/CVImagesCategoryElement.java
(listChanged):
* src/org/jboss/tools/deltacloud/ui/views/cloud/CVInstancesCategoryElement.java
(listChanged):
* src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewElement.java
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2010-12-07 12:16:53
UTC (rev 27209)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2010-12-07 12:40:13
UTC (rev 27210)
@@ -40,7 +40,7 @@
point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
<propertyContributor
contributorId="org.jboss.tools.deltacloud.ui.views.CloudView"
-
typeMapper="org.jboss.tools.deltacloud.ui.views.cloud.CVTypeMapper">
+
typeMapper="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElementTypeMapper">
<propertyCategory
category="main"></propertyCategory>
</propertyContributor>
@@ -65,7 +65,7 @@
id="org.jboss.tools.deltacloud.ui.propertySection.advanced"
tab="cloudview.advancedTab">
<input
-
type="org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement">
+
type="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
</input>
</propertySection>
</propertySections>
@@ -116,7 +116,7 @@
variable="selection">
<iterate>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
</instanceof>
</iterate>
</with>
@@ -136,7 +136,7 @@
variable="selection">
<iterate>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
</instanceof>
</iterate>
</with>
@@ -158,7 +158,7 @@
<count value="+" />
<iterate>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
</instanceof>
</iterate>
</and>
@@ -299,7 +299,7 @@
variable="selection">
<iterate>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
</instanceof>
</iterate>
</with>
@@ -675,7 +675,7 @@
variable="selection">
<iterate>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.CVImageElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.ImageViewElement">
</instanceof>
</iterate>
</with>
@@ -699,11 +699,11 @@
<iterate>
<and>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
</instanceof>
<not>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.CVImageElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.ImageViewElement">
</instanceof>
</not>
</and>
@@ -870,7 +870,7 @@
<extension
point="org.eclipse.core.runtime.adapters">
<factory
-
adaptableType="org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement"
+
adaptableType="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement"
class="org.jboss.tools.deltacloud.ui.adapter.CloudViewElementAdapterFactory">
<adapter
type="org.jboss.tools.deltacloud.core.DeltaCloudInstance">
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/adapter/CloudViewElementAdapterFactory.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/adapter/CloudViewElementAdapterFactory.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/adapter/CloudViewElementAdapterFactory.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -16,9 +16,9 @@
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.ui.views.cloud.CVImageElement;
-import org.jboss.tools.deltacloud.ui.views.cloud.CVInstanceElement;
-import org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.ImageViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.InstanceViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
import org.jboss.tools.internal.deltacloud.ui.utils.CloudViewElementUtils;
public class CloudViewElementAdapterFactory implements IAdapterFactory {
@@ -33,8 +33,8 @@
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
- Assert.isLegal(adaptableObject instanceof CloudViewElement);
- CloudViewElement element = (CloudViewElement) adaptableObject;
+ Assert.isLegal(adaptableObject instanceof DeltaCloudViewElement);
+ DeltaCloudViewElement element = (DeltaCloudViewElement) adaptableObject;
if (adapterType == IPropertySource.class) {
return element.getPropertySource();
} else if (adapterType == DeltaCloudImage.class) {
@@ -48,17 +48,17 @@
}
}
- private DeltaCloudInstance getDeltaCloudInstance(CloudViewElement element) {
- if (element instanceof CVInstanceElement) {
- return (DeltaCloudInstance) element.getElement();
+ private DeltaCloudInstance getDeltaCloudInstance(DeltaCloudViewElement element) {
+ if (element instanceof InstanceViewElement) {
+ return (DeltaCloudInstance) element.getModel();
} else {
return null;
}
}
- private DeltaCloudImage getDeltaCloudImage(CloudViewElement element) {
- if (element instanceof CVImageElement) {
- return (DeltaCloudImage) element.getElement();
+ private DeltaCloudImage getDeltaCloudImage(DeltaCloudViewElement element) {
+ if (element instanceof ImageViewElement) {
+ return (DeltaCloudImage) element.getModel();
} else {
return null;
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceHandler2.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceHandler2.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceHandler2.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -21,8 +21,8 @@
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.ui.views.cloud.CVCloudElement;
import org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
import org.jboss.tools.internal.deltacloud.ui.wizards.NewInstanceWizard2;
@@ -35,13 +35,13 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- CloudViewElement element = UIUtils.getFirstAdaptedElement(selection,
CloudViewElement.class);
- while (element != null && !(element instanceof CVCloudElement)) {
- element = (CloudViewElement) element.getParent();
+ DeltaCloudViewElement element = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudViewElement.class);
+ while (element != null && !(element instanceof CloudViewElement)) {
+ element = (DeltaCloudViewElement) element.getParent();
}
if (element != null) {
- CVCloudElement cloudElement = (CVCloudElement) element;
- DeltaCloud cloud = (DeltaCloud) cloudElement.getElement();
+ CloudViewElement cloudElement = (CloudViewElement) element;
+ DeltaCloud cloud = (DeltaCloud) cloudElement.getModel();
IWizard wizard = new NewInstanceWizard2(cloud);
WizardDialog dialog = new
WizardDialog(UIUtils.getActiveWorkbenchWindow().getShell(),
wizard);
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DisconnectCloudHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DisconnectCloudHandler.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DisconnectCloudHandler.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -38,8 +38,8 @@
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.deltacloud.ui.views.cloud.CVCloudElement;
import org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
/**
* @author Andre Dietisheim
@@ -132,8 +132,8 @@
DeltaCloud deltaCloud = null;
if (selectedElements.size() > 0) {
Object object = selectedElements.get(0);
- if (object instanceof CVCloudElement) {
- Object element = ((CVCloudElement) object).getElement();
+ if (object instanceof CloudViewElement) {
+ Object element = ((CloudViewElement) object).getModel();
if (element instanceof DeltaCloud) {
deltaCloud = (DeltaCloud) element;
}
@@ -154,11 +154,11 @@
}
private DeltaCloud getDeltaCloud(Object item) {
- if (!(item instanceof CloudViewElement)) {
+ if (!(item instanceof DeltaCloudViewElement)) {
return null;
}
- DeltaCloud cloud = getDeltaCloud((CloudViewElement) item);
+ DeltaCloud cloud = getDeltaCloud((DeltaCloudViewElement) item);
if (cloud == null) {
return null;
@@ -166,16 +166,16 @@
return cloud;
}
- private DeltaCloud getDeltaCloud(CloudViewElement element) {
+ private DeltaCloud getDeltaCloud(DeltaCloudViewElement element) {
if (element == null) {
return null;
}
- Object cloud = element.getElement();
+ Object cloud = element.getModel();
if (cloud instanceof DeltaCloud) {
return (DeltaCloud) cloud;
}
- return getDeltaCloud((CloudViewElement) element.getParent());
+ return getDeltaCloud((DeltaCloudViewElement) element.getParent());
}
private void removeDeltaClouds(Object[] deltaClouds) throws DeltaCloudException {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -21,8 +21,8 @@
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.ui.views.cloud.CVCloudElement;
import org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
import org.jboss.tools.internal.deltacloud.ui.wizards.EditCloudConnectionWizard;
@@ -35,13 +35,13 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- CloudViewElement element = UIUtils.getFirstAdaptedElement(selection,
CloudViewElement.class);
- while (element != null && !(element instanceof CVCloudElement)) {
- element = (CloudViewElement) element.getParent();
+ DeltaCloudViewElement element = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudViewElement.class);
+ while (element != null && !(element instanceof CloudViewElement)) {
+ element = (DeltaCloudViewElement) element.getParent();
}
if (element != null) {
- CVCloudElement cloudElement = (CVCloudElement) element;
- DeltaCloud cloud = (DeltaCloud) cloudElement.getElement();
+ CloudViewElement cloudElement = (CloudViewElement) element;
+ DeltaCloud cloud = (DeltaCloud) cloudElement.getModel();
IWizard wizard = new EditCloudConnectionWizard(cloud);
WizardDialog dialog = new WizardDialog(UIUtils.getActiveWorkbenchWindow().getShell(),
wizard);
dialog.create();
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-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -25,7 +25,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudMultiException;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
-import org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
import org.jboss.tools.internal.deltacloud.ui.utils.CloudViewElementUtils;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
@@ -38,14 +38,14 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- CloudViewElement cloudViewElement = UIUtils.getFirstAdaptedElement(selection,
CloudViewElement.class);
+ DeltaCloudViewElement cloudViewElement = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudViewElement.class);
refresh(cloudViewElement);
}
return Status.OK_STATUS;
}
- private void refresh(final CloudViewElement cloudViewElement) {
+ private void refresh(final DeltaCloudViewElement cloudViewElement) {
if (cloudViewElement != null) {
final DeltaCloud cloud = CloudViewElementUtils.getCloud(cloudViewElement);
if (cloud != null) {
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVCloudElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVCloudElement.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVCloudElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views.cloud;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.ui.views.cloud.property.CloudPropertySource;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class CVCloudElement extends CloudViewElement {
-
- private TreeViewer viewer;
-
- public CVCloudElement(Object element, CloudViewElement parent, TreeViewer viewer) {
- super(element, parent, viewer);
- this.viewer = viewer;
- }
-
- public String getName() {
- Object element = getElement();
- if (element instanceof DeltaCloud) {
- return ((DeltaCloud) element).getName();
- } else {
- return "";
- }
- }
-
- @Override
- public boolean hasChildren() {
- return true;
- }
-
- @Override
- public synchronized Object[] getChildren() {
- if (!initialized.get()) {
- DeltaCloud cloud = (DeltaCloud) getElement();
- CVCloudElementCategoryElement instances = new CVInstancesCategoryElement(cloud, this,
viewer);
- addCategory(instances);
- CVCloudElementCategoryElement images = new CVImagesCategoryElement(cloud, this,
viewer);
- addCategory(images);
- }
- initialized.set(true);
- return super.getChildren();
- }
-
- private void addCategory(CVCloudElementCategoryElement categoryElement) {
- children.add(categoryElement);
- }
-
- @Override
- public IPropertySource getPropertySource() {
- return new CloudPropertySource(getElement());
- }
-
-
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVCloudElementCategoryElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVCloudElementCategoryElement.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVCloudElementCategoryElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views.cloud;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public abstract class CVCloudElementCategoryElement extends CloudViewElement {
-
- public CVCloudElementCategoryElement(Object element, CloudViewElement parent, TreeViewer
viewer) {
- super(element, parent, viewer);
- addCloudElementListener(getCloud());
- }
-
- @Override
- public boolean hasChildren() {
- return true;
- }
-
- @Override
- public Object[] getChildren() {
- if (!initialized.get()) {
- setLoadingIndicator();
- asyncGetCloudElements();
- initialized.set(true);
- }
- return super.getChildren();
- }
-
- private void setLoadingIndicator() {
- children.add(new LoadingCloudViewElement(this, viewer));
- }
-
- protected abstract void asyncGetCloudElements();
-
- protected void addChildren(Object[] modelElements) {
- if (modelElements.length > CVNumericFoldingElement.FOLDING_SIZE) {
- addFoldedChildren(modelElements);
- } else {
- addChildren(getElements(modelElements, 0, modelElements.length));
- }
- }
-
- protected void addFoldedChildren(Object[] modelElements) {
- int min = 0;
- int max = CVNumericFoldingElement.FOLDING_SIZE;
- int length = modelElements.length;
- while (length > CVNumericFoldingElement.FOLDING_SIZE) {
- CVNumericFoldingElement f = new CVNumericFoldingElement(min, max, this, viewer);
- addChild(f);
- f.addChildren(getElements(modelElements, min, max));
- min += CVNumericFoldingElement.FOLDING_SIZE;
- max += CVNumericFoldingElement.FOLDING_SIZE;
- length -= CVNumericFoldingElement.FOLDING_SIZE;
- }
- if (length > 0) {
- CVNumericFoldingElement f = new CVNumericFoldingElement(min, max, this, viewer);
- addChild(f);
- f.addChildren(getElements(modelElements, min, min + length));
- }
- }
-
- protected abstract CloudViewElement[] getElements(Object[] modelElements, int
startIndex, int stopIndex);
-
- @Override
- public IPropertySource getPropertySource() {
- // no property source for cathegories
- return null;
- }
-
- protected DeltaCloud getCloud() {
- return (DeltaCloud) getElement();
- }
-
- @Override
- protected void dispose() {
- removeCloudElementListener(getCloud());
- }
-
- protected abstract void addCloudElementListener(DeltaCloud cloud);
-
- protected abstract void removeCloudElementListener(DeltaCloud cloud);
-
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVImageElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVImageElement.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVImageElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views.cloud;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.jboss.tools.deltacloud.core.DeltaCloudImage;
-import org.jboss.tools.deltacloud.ui.views.cloud.property.ImagePropertySource;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class CVImageElement extends CloudViewElement {
-
- public CVImageElement(Object element, CloudViewElement parent, TreeViewer viewer) {
- super(element, parent, viewer);
- }
-
- public String getName() {
- Object element = getElement();
- if (element instanceof DeltaCloudImage) {
- return ((DeltaCloudImage) element).getName();
- } else {
- return "";
- }
- }
-
- @Override
- public IPropertySource getPropertySource() {
- return new ImagePropertySource(getElement());
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVImagesCategoryElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVImagesCategoryElement.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVImagesCategoryElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views.cloud;
-
-import java.text.MessageFormat;
-
-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.ui.ErrorUtils;
-import org.jboss.tools.deltacloud.ui.views.CVMessages;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class CVImagesCategoryElement extends CVCloudElementCategoryElement implements
IImageListListener {
-
- private static final String IMAGE_CATEGORY_NAME = "ImageCategoryName";
//$NON-NLS-1$
-
- public CVImagesCategoryElement(Object element, CloudViewElement parent, TreeViewer
viewer) {
- super(element, parent, viewer);
- }
-
- public String getName() {
- return CVMessages.getString(IMAGE_CATEGORY_NAME);
- }
-
- protected void asyncGetCloudElements() {
- new GetImagesCommand(getCloud()).execute();
- }
-
- @Override
- protected CloudViewElement[] getElements(Object[] modelElements, int startIndex, int
stopIndex) {
- CloudViewElement[] elements = new CloudViewElement[stopIndex - startIndex];
- for (int i = startIndex; i < stopIndex; ++i) {
- elements[i - startIndex] = new CVImageElement(modelElements[i], this, viewer);
- }
- return elements;
- }
-
- @Override
- public synchronized void listChanged(DeltaCloud cloud, DeltaCloudImage[] newImages) {
- try {
- clearChildren();
- initialized.set(false);
- DeltaCloudImage[] images = filter(newImages);
- addChildren(images);
- expand();
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- MessageFormat.format("Could not get images from cloud \"{0}\"",
cloud.getName()), e,
- viewer.getControl().getShell());
- } finally {
- initialized.set(true);
- }
- }
-
- public DeltaCloudImage[] filter(DeltaCloudImage[] images) throws DeltaCloudException {
- DeltaCloud cloud = (DeltaCloud) getElement();
- IImageFilter f = cloud.getImageFilter();
- return f.filter(images).toArray(new DeltaCloudImage[images.length]);
- }
-
- protected void addCloudElementListener(DeltaCloud cloud) {
- if (cloud != null) {
- cloud.addImageListListener(this);
- }
- }
-
- protected void removeCloudElementListener(DeltaCloud cloud) {
- if (cloud != null) {
- cloud.removeImageListListener(this);
- }
- }
-
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVInstanceElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVInstanceElement.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVInstanceElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views.cloud;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.ui.views.cloud.property.InstancePropertySource;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class CVInstanceElement extends CloudViewElement {
-
- public CVInstanceElement(Object element, CloudViewElement parent, TreeViewer viewer) {
- super(element, parent, viewer);
- }
-
- public String getName() {
- Object element = getElement();
- StringBuilder sb = new StringBuilder();
- if (element instanceof DeltaCloudInstance) {
- DeltaCloudInstance instance = (DeltaCloudInstance) element;
- if (instance.getName() != null) {
- sb.append(instance.getName());
- }
- if (instance.getId() != null) {
- sb.append(" [").append(instance.getId()).append("] ");
- }
- }
- return sb.toString();
-
- }
-
- @Override
- public IPropertySource getPropertySource() {
- return new InstancePropertySource(this, getElement());
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVInstancesCategoryElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVInstancesCategoryElement.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVInstancesCategoryElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views.cloud;
-
-import java.text.MessageFormat;
-
-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.ui.ErrorUtils;
-import org.jboss.tools.deltacloud.ui.views.CVMessages;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class CVInstancesCategoryElement extends CVCloudElementCategoryElement implements
IInstanceListListener {
-
- private static final String INSTANCE_CATEGORY_NAME = "InstanceCategoryName";
//$NON-NLS-1$
-
- public CVInstancesCategoryElement(Object element, CloudViewElement parent, TreeViewer
viewer) {
- super(element, parent, viewer);
- }
-
- public String getName() {
- return CVMessages.getString(INSTANCE_CATEGORY_NAME);
- }
-
- protected void asyncGetCloudElements() {
- new GetInstancesCommand(getCloud()).execute();
- }
-
- @Override
- protected CloudViewElement[] getElements(Object[] modelElements, int startIndex, int
stopIndex) {
- CloudViewElement[] elements = new CloudViewElement[stopIndex - startIndex];
- for (int i = startIndex; i < stopIndex; ++i) {
- elements[i - startIndex] = new CVInstanceElement(modelElements[i], this, viewer);
- }
- return elements;
- }
-
- @Override
- public void listChanged(DeltaCloud cloud, DeltaCloudInstance[] newInstances) {
- try {
- clearChildren();
- initialized.set(false);
- final DeltaCloudInstance[] instances = filter(newInstances);
- addChildren(instances);
- expand();
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- MessageFormat.format("Could not get instanceso from cloud
\"{0}\"", cloud.getName()), e,
- viewer.getControl().getShell());
- } finally {
- initialized.set(true);
- }
- }
-
- public DeltaCloudInstance[] filter(DeltaCloudInstance[] instances) throws
DeltaCloudException {
- IInstanceFilter f = getCloud().getInstanceFilter();
- return f.filter(instances).toArray(new DeltaCloudInstance[instances.length]);
- }
-
- protected void addCloudElementListener(DeltaCloud cloud) {
- if (cloud != null) {
- cloud.addInstanceListListener(this);
- }
- }
-
- protected void removeCloudElementListener(DeltaCloud cloud) {
- if (cloud != null) {
- cloud.removeInstanceListListener(this);
- }
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVNumericFoldingElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVNumericFoldingElement.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVNumericFoldingElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views.cloud;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class CVNumericFoldingElement extends CloudViewElement {
-
- public static int FOLDING_SIZE = 50;
- private Object min;
- private int max;
-
- public CVNumericFoldingElement(int min, int max, CloudViewElement parent, TreeViewer
viewer) {
- super(null, parent, viewer);
- this.min = min;
- this.max = max;
- }
-
- @Override
- public String getName() {
- return new StringBuilder()
- .append("[")
- .append(min)
- .append("..")
- .append(max - 1)
- .append("]").toString();
- }
-
- @Override
- public Object[] getChildren() {
- return super.getChildren();
- }
-
- @Override
- public boolean hasChildren() {
- return true;
- }
-
- @Override
- public IPropertySource getPropertySource() {
- return null;
- }
-
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVRootElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVRootElement.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVRootElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views.cloud;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.core.DeltaCloudException;
-import org.jboss.tools.deltacloud.core.DeltaCloudManager;
-import org.jboss.tools.deltacloud.core.ICloudManagerListener;
-import org.jboss.tools.deltacloud.ui.ErrorUtils;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class CVRootElement extends CloudViewElement implements ICloudManagerListener {
-
- public CVRootElement(TreeViewer viewer) {
- super(DeltaCloudManager.getDefault(), null, viewer); //$NON-NLS-1$
- DeltaCloudManager.getDefault().addCloudManagerListener(this);
- }
-
- @Override
- public String getName() {
- return "root"; //$NON-NLS-1$
- }
-
- @Override
- public IPropertySource getPropertySource() {
- // no property source for the root element
- return null;
- }
-
- @Override
- public Object[] getChildren() {
- if (!initialized.get()) {
- DeltaCloudManager m = DeltaCloudManager.getDefault();
- try {
- addClouds(m.getClouds());
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- ErrorUtils.handleError("Error", "Could not get clouds", e,
Display.getDefault().getActiveShell());
- } finally {
- initialized.set(true);
- }
- }
- return super.getChildren();
- }
-
- private void addClouds(DeltaCloud[] clouds) {
- for (DeltaCloud cloud : clouds) {
- addCloud(cloud);
- }
- }
-
- private void addCloud(DeltaCloud cloud) {
- CVCloudElement e = new CVCloudElement(cloud, this, viewer);
- children.add(e);
- }
-
- private CloudViewElement getCloudViewElement(DeltaCloud cloudToMatch) {
- for (CloudViewElement cloudElement : children) {
- DeltaCloud cloud = (DeltaCloud) cloudElement.getElement();
- if (cloudToMatch.equals(cloud)) {
- return cloudElement;
- }
- }
- return null;
- }
-
- @Override
- public void dispose() {
- DeltaCloudManager.getDefault().removeCloudManagerListener(this);
- }
-
- public void cloudsChanged(int type, DeltaCloud cloud) {
- switch (type) {
- case ICloudManagerListener.ADD_EVENT:
- addChild(new CVCloudElement(cloud, this, viewer));
- break;
- case ICloudManagerListener.REMOVE_EVENT:
- removeChild(getCloudViewElement(cloud));
- break;
- case ICloudManagerListener.RENAME_EVENT:
- CloudViewElement cloudViewElement = getCloudViewElement(cloud);
- viewer.refresh(cloudViewElement);
- break;
- }
- initialized.set(true);
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVTypeMapper.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVTypeMapper.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVTypeMapper.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views.cloud;
-
-import org.eclipse.jface.viewers.TreeNode;
-import org.eclipse.ui.views.properties.tabbed.AbstractTypeMapper;
-
-public class CVTypeMapper extends AbstractTypeMapper {
-
- @SuppressWarnings("rawtypes")
- @Override
- public Class mapType(Object object) {
- if (object instanceof TreeNode) {
- return ((TreeNode) object).getValue().getClass();
- }
- return super.mapType(object);
- }
-
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryViewElement.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVCloudElementCategoryElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryViewElement.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryViewElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public abstract class CloudElementCategoryViewElement<CLOUDELEMENT> extends
DeltaCloudViewElement {
+
+ protected CloudElementCategoryViewElement(Object model, DeltaCloudViewElement parent,
TreeViewer viewer) {
+ super(model, parent, viewer);
+ addCloudElementListener(getCloud());
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return true;
+ }
+
+ @Override
+ public Object[] getChildren() {
+ if (!initialized.get()) {
+// setLoadingIndicator();
+ asyncGetCloudElements();
+ initialized.set(true);
+ }
+ return super.getChildren();
+ }
+
+ protected void setLoadingIndicator() {
+ children.add(new LoadingCloudElementViewElement(this, viewer));
+ }
+
+ protected abstract void asyncGetCloudElements();
+
+ protected void addChildren(Object[] modelElements) {
+ if (modelElements.length > NumericFoldingViewElement.FOLDING_SIZE) {
+ addFoldedChildren(modelElements);
+ } else {
+ addChildren(getElements(modelElements, 0, modelElements.length));
+ }
+ }
+
+ protected void addFoldedChildren(Object[] modelElements) {
+ int min = 0;
+ int max = NumericFoldingViewElement.FOLDING_SIZE;
+ int length = modelElements.length;
+ while (length > NumericFoldingViewElement.FOLDING_SIZE) {
+ NumericFoldingViewElement f = new NumericFoldingViewElement(min, max, this, viewer);
+ addChild(f);
+ f.addChildren(getElements(modelElements, min, max));
+ min += NumericFoldingViewElement.FOLDING_SIZE;
+ max += NumericFoldingViewElement.FOLDING_SIZE;
+ length -= NumericFoldingViewElement.FOLDING_SIZE;
+ }
+ if (length > 0) {
+ NumericFoldingViewElement f = new NumericFoldingViewElement(min, max, this, viewer);
+ addChild(f);
+ f.addChildren(getElements(modelElements, min, min + length));
+ }
+ }
+
+ protected void onListChanged(DeltaCloud cloud, CLOUDELEMENT[] cloudElements) throws
DeltaCloudException {
+ try {
+ clearChildren();
+ initialized.set(false);
+ final CLOUDELEMENT[] filteredElements = filter(cloudElements);
+ addChildren(filteredElements);
+ expand();
+ } finally {
+ initialized.set(true);
+ }
+ }
+
+ protected abstract CLOUDELEMENT[] filter(CLOUDELEMENT[] cloudElements) throws
DeltaCloudException;
+
+ protected abstract DeltaCloudViewElement[] getElements(Object[] modelElements, int
startIndex, int stopIndex);
+
+ @Override
+ public IPropertySource getPropertySource() {
+ // no property source for cathegories
+ return null;
+ }
+
+ protected DeltaCloud getCloud() {
+ return (DeltaCloud) getModel();
+ }
+
+ @Override
+ protected void dispose() {
+ removeCloudElementListener(getCloud());
+ }
+
+ protected abstract void addCloudElementListener(DeltaCloud cloud);
+
+ protected abstract void removeCloudElementListener(DeltaCloud cloud);
+
+}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewContentProvider.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewContentProvider.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views.cloud;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-public class CloudViewContentProvider implements ITreeContentProvider {
-
- private CloudViewElement root;
-
- @Override
- public Object[] getChildren(Object element) {
- if (element instanceof CloudViewElement) {
- return ((CloudViewElement) element).getChildren();
- } else {
- return null;
- }
- }
-
- @Override
- public Object getParent(Object element) {
- if (element instanceof CloudViewElement) {
- return ((CloudViewElement) element).getParent();
- } else {
- return null;
- }
- }
-
- @Override
- public boolean hasChildren(Object element) {
- CloudViewElement e = (CloudViewElement) element;
- return e.hasChildren();
- }
-
- @Override
- public Object[] getElements(Object inputElement) {
- return root.getChildren();
- }
-
- @Override
- public void dispose() {
-
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- root = (CloudViewElement) newInput;
- }
-
-}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewElement.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -10,154 +10,59 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.ui.views.cloud;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.ui.views.cloud.property.CloudPropertySource;
/**
* @author Jeff Johnston
* @author Andre Dietisheim
*/
-public abstract class CloudViewElement implements IAdaptable {
+public class CloudViewElement extends DeltaCloudViewElement {
- private Object element;
- private CloudViewElement parent;
- protected List<CloudViewElement> children =
- Collections.synchronizedList(new ArrayList<CloudViewElement>());
- protected TreeViewer viewer;
- protected AtomicBoolean initialized = new AtomicBoolean();
+ private TreeViewer viewer;
- public CloudViewElement(Object element, CloudViewElement parent, TreeViewer viewer) {
- this.element = element;
- this.parent = parent;
+ protected CloudViewElement(Object element, DeltaCloudViewElement parent, TreeViewer
viewer) {
+ super(element, parent, viewer);
this.viewer = viewer;
- initDisposeListener(viewer);
}
- public abstract String getName();
-
- public Object[] getChildren() {
- return children.toArray();
+ public String getName() {
+ Object element = getModel();
+ if (element instanceof DeltaCloud) {
+ return ((DeltaCloud) element).getName();
+ } else {
+ return "";
+ }
}
- protected void clearChildren() {
- getDisplay().syncExec(new Runnable() {
-
- @Override
- public void run() {
- // viewer.getTree().setRedraw(false);
- for (final CloudViewElement element : children) {
- viewer.remove(element);
- }
- // viewer.getTree().setRedraw(true);
- }
- });
- children.clear();
- }
-
+ @Override
public boolean hasChildren() {
- return children.size() > 0;
+ return true;
}
- public Object getParent() {
- return parent;
- }
-
- public void addChild(final CloudViewElement element) {
- children.add(element);
-
- getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- viewer.add(CloudViewElement.this, element);
- }
- });
- }
-
- public void addChildren(final CloudViewElement[] elements) {
- for (CloudViewElement element : elements) {
- children.add(element);
+ @Override
+ public synchronized Object[] getChildren() {
+ if (!initialized.get()) {
+ DeltaCloud cloud = (DeltaCloud) getModel();
+ CloudElementCategoryViewElement instances = new InstancesCategoryViewElement(cloud,
this, viewer);
+ addCategory(instances);
+ CloudElementCategoryViewElement images = new ImagesCategoryViewElement(cloud, this,
viewer);
+ addCategory(images);
}
-
- getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- viewer.add(CloudViewElement.this, elements);
- }
- });
+ initialized.set(true);
+ return super.getChildren();
}
- public void removeChild(final CloudViewElement element) {
-
- getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (element != null) {
- int index = children.indexOf(element);
- viewer.remove(CloudViewElement.this, index);
- }
- }
- });
+ private void addCategory(CloudElementCategoryViewElement categoryElement) {
+ children.add(categoryElement);
}
- protected void expand() {
- getDisplay().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- viewer.setExpandedState(CloudViewElement.this, true);
- }
- });
- }
-
- public Object getElement() {
- return element;
- }
-
- @SuppressWarnings("rawtypes")
@Override
- public Object getAdapter(Class adapter) {
- if (adapter == IPropertySource.class) {
- IPropertySource p = getPropertySource();
- return p;
- }
- return null;
+ public IPropertySource getPropertySource() {
+ return new CloudPropertySource(getModel());
}
-
- public abstract IPropertySource getPropertySource();
-
- private void initDisposeListener(Viewer viewer) {
- final Control control = viewer.getControl();
- control.getDisplay().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- control.addDisposeListener(new DisposeListener() {
-
- @Override
- public void widgetDisposed(DisposeEvent e) {
- dispose();
- }
- });
- }
- });
- }
-
- protected Display getDisplay() {
- return viewer.getControl().getDisplay();
- }
-
- protected void dispose() {
- // nothing to do
- }
+
+
}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewLabelProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewLabelProvider.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewLabelProvider.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.ui.views.cloud;
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
-
-public class CloudViewLabelProvider extends LabelProvider {
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof CVCloudElement) {
- return SWTImagesFactory.get(SWTImagesFactory.IMG_CLOUD);
- } else if (element instanceof CVCloudElementCategoryElement ||
- element instanceof CVNumericFoldingElement) {
- return SWTImagesFactory.get(SWTImagesFactory.IMG_FOLDER);
- } else if (element instanceof CVInstanceElement) {
- return SWTImagesFactory.get(SWTImagesFactory.IMG_INSTANCE);
- } else if (element instanceof CVImageElement) {
- return SWTImagesFactory.get(SWTImagesFactory.IMG_IMAGE);
- }
- return null;
- }
-
- @Override
- public String getText(Object element) {
- CloudViewElement e = (CloudViewElement)element;
- return e.getName();
- }
-
-}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -53,10 +53,10 @@
private TreeViewer createTreeViewer(Composite parent) {
TreeViewer viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.BORDER);
- viewer.setContentProvider(new CloudViewContentProvider());
- viewer.setLabelProvider(new CloudViewLabelProvider());
+ viewer.setContentProvider(new DeltaCloudViewContentProvider());
+ viewer.setLabelProvider(new DeltaCloudViewLabelProvider());
viewer.setUseHashlookup(true);
- viewer.setInput(new CVRootElement(viewer));
+ viewer.setInput(new RootViewElement(viewer));
viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
getSite().setSelectionProvider(viewer);
return viewer;
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewContentProvider.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewContentProvider.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewContentProvider.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewContentProvider.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class DeltaCloudViewContentProvider implements ITreeContentProvider {
+
+ private DeltaCloudViewElement root;
+
+ @Override
+ public Object[] getChildren(Object element) {
+ if (element instanceof DeltaCloudViewElement) {
+ return ((DeltaCloudViewElement) element).getChildren();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ if (element instanceof DeltaCloudViewElement) {
+ return ((DeltaCloudViewElement) element).getParent();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ DeltaCloudViewElement e = (DeltaCloudViewElement) element;
+ return e.hasChildren();
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return root.getChildren();
+ }
+
+ @Override
+ public void dispose() {
+
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ root = (DeltaCloudViewElement) newInput;
+ }
+
+}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElement.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElement.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public abstract class DeltaCloudViewElement implements IAdaptable {
+
+ private Object model;
+ private DeltaCloudViewElement parent;
+ protected List<DeltaCloudViewElement> children =
+ Collections.synchronizedList(new ArrayList<DeltaCloudViewElement>());
+ protected TreeViewer viewer;
+ protected AtomicBoolean initialized = new AtomicBoolean();
+
+ protected DeltaCloudViewElement(Object model, DeltaCloudViewElement parent, TreeViewer
viewer) {
+ this.model = model;
+ this.parent = parent;
+ this.viewer = viewer;
+ initDisposeListener(viewer);
+ }
+
+ public abstract String getName();
+
+ public Object[] getChildren() {
+ return children.toArray();
+ }
+
+ protected void clearChildren() {
+ getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ // viewer.getTree().setRedraw(false);
+ for (final DeltaCloudViewElement element : children) {
+ viewer.remove(element);
+ }
+ // viewer.getTree().setRedraw(true);
+ }
+ });
+ children.clear();
+ }
+
+ public boolean hasChildren() {
+ return children.size() > 0;
+ }
+
+ public Object getParent() {
+ return parent;
+ }
+
+ public void addChild(final DeltaCloudViewElement element) {
+ children.add(element);
+
+ getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ viewer.add(DeltaCloudViewElement.this, element);
+ }
+ });
+ }
+
+ public void addChildren(final DeltaCloudViewElement[] elements) {
+ for (DeltaCloudViewElement element : elements) {
+ children.add(element);
+ }
+
+ getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ viewer.add(DeltaCloudViewElement.this, elements);
+ }
+ });
+ }
+
+ public void removeChild(final DeltaCloudViewElement element) {
+
+ getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (element != null) {
+ int index = children.indexOf(element);
+ viewer.remove(DeltaCloudViewElement.this, index);
+ }
+ }
+ });
+ }
+
+ protected void expand() {
+ getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ viewer.setExpandedState(DeltaCloudViewElement.this, true);
+ }
+ });
+ }
+
+ public Object getModel() {
+ return model;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySource.class) {
+ IPropertySource p = getPropertySource();
+ return p;
+ }
+ return null;
+ }
+
+ public abstract IPropertySource getPropertySource();
+
+ private void initDisposeListener(Viewer viewer) {
+ final Control control = viewer.getControl();
+ control.getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ control.addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ }
+ });
+ }
+ });
+ }
+
+ protected Display getDisplay() {
+ return viewer.getControl().getDisplay();
+ }
+
+ protected void dispose() {
+ // nothing to do
+ }
+}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElementTypeMapper.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVTypeMapper.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElementTypeMapper.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElementTypeMapper.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud;
+
+import org.eclipse.jface.viewers.TreeNode;
+import org.eclipse.ui.views.properties.tabbed.AbstractTypeMapper;
+
+public class DeltaCloudViewElementTypeMapper extends AbstractTypeMapper {
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Class mapType(Object object) {
+ if (object instanceof TreeNode) {
+ return ((TreeNode) object).getValue().getClass();
+ }
+ return super.mapType(object);
+ }
+
+}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewLabelProvider.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewLabelProvider.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewLabelProvider.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewLabelProvider.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
+
+public class DeltaCloudViewLabelProvider extends LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof CloudViewElement) {
+ return SWTImagesFactory.get(SWTImagesFactory.IMG_CLOUD);
+ } else if (element instanceof CloudElementCategoryViewElement ||
+ element instanceof NumericFoldingViewElement) {
+ return SWTImagesFactory.get(SWTImagesFactory.IMG_FOLDER);
+ } else if (element instanceof InstanceViewElement) {
+ return SWTImagesFactory.get(SWTImagesFactory.IMG_INSTANCE);
+ } else if (element instanceof ImageViewElement) {
+ return SWTImagesFactory.get(SWTImagesFactory.IMG_IMAGE);
+ }
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ DeltaCloudViewElement e = (DeltaCloudViewElement)element;
+ return e.getName();
+ }
+
+}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageViewElement.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVImageElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageViewElement.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageViewElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloudImage;
+import org.jboss.tools.deltacloud.ui.views.cloud.property.ImagePropertySource;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class ImageViewElement extends DeltaCloudViewElement {
+
+ protected ImageViewElement(Object model, DeltaCloudViewElement parent, TreeViewer
viewer) {
+ super(model, parent, viewer);
+ }
+
+ public String getName() {
+ Object element = getModel();
+ if (element instanceof DeltaCloudImage) {
+ return ((DeltaCloudImage) element).getName();
+ } else {
+ return "";
+ }
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ return new ImagePropertySource(getModel());
+ }
+}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryViewElement.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVImagesCategoryElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryViewElement.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryViewElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud;
+
+import java.text.MessageFormat;
+
+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.ui.ErrorUtils;
+import org.jboss.tools.deltacloud.ui.views.CVMessages;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class ImagesCategoryViewElement extends
CloudElementCategoryViewElement<DeltaCloudImage> implements IImageListListener {
+
+ private static final String IMAGE_CATEGORY_NAME = "ImageCategoryName";
//$NON-NLS-1$
+
+ protected ImagesCategoryViewElement(Object model, DeltaCloudViewElement parent,
TreeViewer viewer) {
+ super(model, parent, viewer);
+ }
+
+ public String getName() {
+ return CVMessages.getString(IMAGE_CATEGORY_NAME);
+ }
+
+ @Override
+ protected void asyncGetCloudElements() {
+ setLoadingIndicator();
+ new GetImagesCommand(getCloud()){
+
+ @Override
+ protected void asyncGetImages() throws DeltaCloudException {
+ try {
+ super.asyncGetImages();
+ } catch(DeltaCloudException e) {
+ clearChildren();
+ throw e;
+ }
+ }
+
+ }.execute();
+ }
+
+ @Override
+ protected DeltaCloudViewElement[] getElements(Object[] modelElements, int startIndex,
int stopIndex) {
+ DeltaCloudViewElement[] elements = new DeltaCloudViewElement[stopIndex - startIndex];
+ for (int i = startIndex; i < stopIndex; ++i) {
+ elements[i - startIndex] = new ImageViewElement(modelElements[i], this, viewer);
+ }
+ return elements;
+ }
+
+ @Override
+ public synchronized void listChanged(DeltaCloud cloud, DeltaCloudImage[] newImages) {
+ try {
+ onListChanged(cloud, newImages);
+ } catch (DeltaCloudException e) {
+ // TODO: internationalize strings
+ ErrorUtils.handleError(
+ "Error",
+ MessageFormat.format("Could not get images from cloud \"{0}\"",
cloud.getName()), e,
+ viewer.getControl().getShell());
+ }
+ }
+
+ @Override
+ protected DeltaCloudImage[] filter(DeltaCloudImage[] images) throws DeltaCloudException
{
+ DeltaCloud cloud = (DeltaCloud) getModel();
+ IImageFilter f = cloud.getImageFilter();
+ return f.filter(images).toArray(new DeltaCloudImage[images.length]);
+ }
+
+ protected void addCloudElementListener(DeltaCloud cloud) {
+ if (cloud != null) {
+ cloud.addImageListListener(this);
+ }
+ }
+
+ protected void removeCloudElementListener(DeltaCloud cloud) {
+ if (cloud != null) {
+ cloud.removeImageListListener(this);
+ }
+ }
+
+}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceViewElement.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVInstanceElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceViewElement.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceViewElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.ui.views.cloud.property.InstancePropertySource;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class InstanceViewElement extends DeltaCloudViewElement {
+
+ protected InstanceViewElement(Object model, DeltaCloudViewElement parent, TreeViewer
viewer) {
+ super(model, parent, viewer);
+ }
+
+ public String getName() {
+ Object element = getModel();
+ StringBuilder sb = new StringBuilder();
+ if (element instanceof DeltaCloudInstance) {
+ DeltaCloudInstance instance = (DeltaCloudInstance) element;
+ if (instance.getName() != null) {
+ sb.append(instance.getName());
+ }
+ if (instance.getId() != null) {
+ sb.append(" [").append(instance.getId()).append("] ");
+ }
+ }
+ return sb.toString();
+
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ return new InstancePropertySource(this, getModel());
+ }
+}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryViewElement.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVInstancesCategoryElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryViewElement.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryViewElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud;
+
+import java.text.MessageFormat;
+
+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.ui.ErrorUtils;
+import org.jboss.tools.deltacloud.ui.views.CVMessages;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class InstancesCategoryViewElement extends
CloudElementCategoryViewElement<DeltaCloudInstance> implements IInstanceListListener
{
+
+ private static final String INSTANCE_CATEGORY_NAME = "InstanceCategoryName";
//$NON-NLS-1$
+
+ protected InstancesCategoryViewElement(Object model, DeltaCloudViewElement parent,
TreeViewer viewer) {
+ super(model, parent, viewer);
+ }
+
+ public String getName() {
+ return CVMessages.getString(INSTANCE_CATEGORY_NAME);
+ }
+
+ @Override
+ protected void asyncGetCloudElements() {
+ setLoadingIndicator();
+ new GetInstancesCommand(getCloud()){
+
+ @Override
+ protected void asyncGetInstances() throws DeltaCloudException {
+ try {
+ super.asyncGetInstances();
+ } catch(DeltaCloudException e) {
+ clearChildren();
+ throw e;
+ }
+ }
+
+ }.execute();
+ }
+
+ @Override
+ protected DeltaCloudViewElement[] getElements(Object[] modelElements, int startIndex,
int stopIndex) {
+ DeltaCloudViewElement[] elements = new DeltaCloudViewElement[stopIndex - startIndex];
+ for (int i = startIndex; i < stopIndex; ++i) {
+ elements[i - startIndex] = new InstanceViewElement(modelElements[i], this, viewer);
+ }
+ return elements;
+ }
+
+ @Override
+ public void listChanged(DeltaCloud cloud, DeltaCloudInstance[] newInstances) {
+ try {
+ onListChanged(cloud, newInstances);
+ } catch (DeltaCloudException e) {
+ // TODO: internationalize strings
+ ErrorUtils.handleError(
+ "Error",
+ MessageFormat.format("Could not get instances from cloud
\"{0}\"", cloud.getName()), e,
+ viewer.getControl().getShell());
+ }
+ }
+
+ @Override
+ protected DeltaCloudInstance[] filter(DeltaCloudInstance[] instances) throws
DeltaCloudException {
+ DeltaCloud cloud = (DeltaCloud) getModel();
+ IInstanceFilter f = cloud.getInstanceFilter();
+ return f.filter(instances).toArray(new DeltaCloudInstance[instances.length]);
+ }
+
+ protected void addCloudElementListener(DeltaCloud cloud) {
+ if (cloud != null) {
+ cloud.addInstanceListListener(this);
+ }
+ }
+
+ protected void removeCloudElementListener(DeltaCloud cloud) {
+ if (cloud != null) {
+ cloud.removeInstanceListListener(this);
+ }
+ }
+}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudElementViewElement.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudElementViewElement.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudElementViewElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.cloud;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * A tree element that shows the user that the tree is currently loading
+ * elements
+ */
+public class LoadingCloudElementViewElement extends DeltaCloudViewElement {
+
+ protected LoadingCloudElementViewElement(DeltaCloudViewElement parent, TreeViewer
viewer) {
+ super(null, parent, viewer);
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ // no property source for this element
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ // TODO: internationalize strings
+ return "Loading...";
+ }
+}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudViewElement.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudViewElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -1,36 +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.cloud;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * A tree element that shows the user that the tree is currently loading
- * elements
- */
-public class LoadingCloudViewElement extends CloudViewElement {
- protected LoadingCloudViewElement(CloudViewElement parent, TreeViewer viewer) {
- super(null, parent, viewer);
- }
-
- @Override
- public IPropertySource getPropertySource() {
- // no property source for this element
- return null;
- }
-
- @Override
- public String getName() {
- // TODO: internationalize strings
- return "Loading...";
- }
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingViewElement.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVNumericFoldingElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingViewElement.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingViewElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class NumericFoldingViewElement extends DeltaCloudViewElement {
+
+ public static int FOLDING_SIZE = 50;
+ private Object min;
+ private int max;
+
+ protected NumericFoldingViewElement(int min, int max, DeltaCloudViewElement parent,
TreeViewer viewer) {
+ super(null, parent, viewer);
+ this.min = min;
+ this.max = max;
+ }
+
+ @Override
+ public String getName() {
+ return new StringBuilder()
+ .append("[")
+ .append(min)
+ .append("..")
+ .append(max - 1)
+ .append("]").toString();
+ }
+
+ @Override
+ public Object[] getChildren() {
+ return super.getChildren();
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return true;
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ return null;
+ }
+
+}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootViewElement.java
(from rev 27203,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CVRootElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootViewElement.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootViewElement.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
+import org.jboss.tools.deltacloud.core.DeltaCloudManager;
+import org.jboss.tools.deltacloud.core.ICloudManagerListener;
+import org.jboss.tools.deltacloud.ui.ErrorUtils;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class RootViewElement extends DeltaCloudViewElement implements
ICloudManagerListener {
+
+ protected RootViewElement(TreeViewer viewer) {
+ super(DeltaCloudManager.getDefault(), null, viewer); //$NON-NLS-1$
+ DeltaCloudManager.getDefault().addCloudManagerListener(this);
+ }
+
+ @Override
+ public String getName() {
+ return "root"; //$NON-NLS-1$
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ // no property source for the root element
+ return null;
+ }
+
+ @Override
+ public Object[] getChildren() {
+ if (!initialized.get()) {
+ DeltaCloudManager m = DeltaCloudManager.getDefault();
+ try {
+ addClouds(m.getClouds());
+ } catch (DeltaCloudException e) {
+ // TODO: internationalize strings
+ ErrorUtils.handleError("Error", "Could not get clouds", e,
Display.getDefault().getActiveShell());
+ } finally {
+ initialized.set(true);
+ }
+ }
+ return super.getChildren();
+ }
+
+ private void addClouds(DeltaCloud[] clouds) {
+ for (DeltaCloud cloud : clouds) {
+ addCloud(cloud);
+ }
+ }
+
+ private void addCloud(DeltaCloud cloud) {
+ CloudViewElement e = new CloudViewElement(cloud, this, viewer);
+ children.add(e);
+ }
+
+ private DeltaCloudViewElement getCloudViewElement(DeltaCloud cloudToMatch) {
+ for (DeltaCloudViewElement cloudElement : children) {
+ DeltaCloud cloud = (DeltaCloud) cloudElement.getModel();
+ if (cloudToMatch.equals(cloud)) {
+ return cloudElement;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void dispose() {
+ DeltaCloudManager.getDefault().removeCloudManagerListener(this);
+ }
+
+ public void cloudsChanged(int type, DeltaCloud cloud) {
+ switch (type) {
+ case ICloudManagerListener.ADD_EVENT:
+ addChild(new CloudViewElement(cloud, this, viewer));
+ break;
+ case ICloudManagerListener.REMOVE_EVENT:
+ removeChild(getCloudViewElement(cloud));
+ break;
+ case ICloudManagerListener.RENAME_EVENT:
+ DeltaCloudViewElement cloudViewElement = getCloudViewElement(cloud);
+ viewer.refresh(cloudViewElement);
+ break;
+ }
+ initialized.set(true);
+ }
+}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -21,7 +21,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.deltacloud.ui.views.cloud.CVInstanceElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.InstanceViewElement;
import org.jboss.tools.internal.deltacloud.ui.utils.CloudViewElementUtils;
public class InstancePropertySource implements IPropertySource {
@@ -49,7 +49,7 @@
private DeltaCloudInstance instance;
private DeltaCloud cloud;
- public InstancePropertySource(CVInstanceElement element, Object o) {
+ public InstancePropertySource(InstanceViewElement element, Object o) {
cloud = CloudViewElementUtils.getCloud(element);
instance = (DeltaCloudInstance) o;
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java 2010-12-07
12:16:53 UTC (rev 27209)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java 2010-12-07
12:40:13 UTC (rev 27210)
@@ -11,8 +11,8 @@
package org.jboss.tools.internal.deltacloud.ui.utils;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.ui.views.cloud.CVCloudElement;
import org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
public class CloudViewElementUtils {
@@ -24,14 +24,14 @@
* @return the cloud for the given CloudViewElement
*
* @see DeltaCloud
- * @see CloudViewElement
+ * @see DeltaCloudViewElement
*/
- public static DeltaCloud getCloud(CloudViewElement element) {
- CVCloudElement cvCloud = getCVCloudElement(element);
+ public static DeltaCloud getCloud(DeltaCloudViewElement element) {
+ CloudViewElement cvCloud = getCVCloudElement(element);
if (cvCloud == null) {
return null;
}
- DeltaCloud cloud = (DeltaCloud) cvCloud.getElement();
+ DeltaCloud cloud = (DeltaCloud) cvCloud.getModel();
return cloud;
}
@@ -42,15 +42,15 @@
* the cloud view element to get the CVCloudElement for
* @return the CVCloudElement for the given CloudViewElement
*
+ * @see DeltaCloudViewElement
* @see CloudViewElement
- * @see CVCloudElement
*/
- public static CVCloudElement getCVCloudElement(CloudViewElement element) {
- while (!(element instanceof CVCloudElement)
+ public static CloudViewElement getCVCloudElement(DeltaCloudViewElement element) {
+ while (!(element instanceof CloudViewElement)
&& element != null) {
- element = (CloudViewElement) element.getParent();
+ element = (DeltaCloudViewElement) element.getParent();
}
- return (CVCloudElement) element;
+ return (CloudViewElement) element;
}
}