Author: adietish
Date: 2010-12-02 06:09:10 -0500 (Thu, 02 Dec 2010)
New Revision: 27085
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCategoryElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVImageElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVImagesCategoryElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVNumericFoldingElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVRootElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewElement.java
Log:
[JBIDE-7780] removed "name" parameter from constructor, implemented #getName on
each CloudViewElement
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-02 10:30:51
UTC (rev 27084)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-02 11:09:10
UTC (rev 27085)
@@ -1,5 +1,14 @@
2010-12-02 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/ui/views/CloudViewElement.java (getName):
+ * src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java (getName):
+ * src/org/jboss/tools/deltacloud/ui/views/CVImageElement.java (getName):
+ * src/org/jboss/tools/deltacloud/ui/views/CVImagesCategoryElement.java (getName):
+ * src/org/jboss/tools/deltacloud/ui/views/CVNumericFoldingElement.java (getName):
+ * src/org/jboss/tools/deltacloud/ui/views/CVRootElement.java (getName):
+ * src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java (getName):
+ * src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java (getName):
+ [JBIDE-7780] removed "name" parameter from constructor, implemented #getName
on each CloudViewElement
* src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java (createControl):
* src/org/jboss/tools/deltacloud/ui/views/InstanceView.java:
* src/org/jboss/tools/deltacloud/ui/views/ImageViewLabelAndContentProvider.java:
@@ -7,9 +16,11 @@
* src/org/jboss/tools/deltacloud/ui/views/AbstractCloudChildrenTableView.java:
* src/org/jboss/tools/deltacloud/ui/views/TableViewerColumnComparator.java:
[JBIDE-7693] removed a lot of duplicate code, unified Instance- and ImageView, Image-
and InstanceComparator
- * src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java (getName):
+
+
* src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
(addInstances):
[JBIDE-7779] changed label for instances in CloudView
+
2010-12-01 André Dietisheim <adietish(a)redhat.com>
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCategoryElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCategoryElement.java 2010-12-02
10:30:51 UTC (rev 27084)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCategoryElement.java 2010-12-02
11:09:10 UTC (rev 27085)
@@ -27,13 +27,17 @@
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
public abstract class CVCategoryElement extends CloudViewElement {
protected boolean initialized;
private TreeViewer viewer;
- public CVCategoryElement(Object element, String name, TreeViewer viewer) {
- super(element, name);
+ public CVCategoryElement(Object element, TreeViewer viewer) {
+ super(element);
this.viewer = viewer;
viewer.getControl().addDisposeListener(onDispose());
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java 2010-12-02
10:30:51 UTC (rev 27084)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java 2010-12-02
11:09:10 UTC (rev 27085)
@@ -20,19 +20,29 @@
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.ui.Activator;
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
public class CVCloudElement extends CloudViewElement {
- private static final String INSTANCE_CATEGORY_NAME = "InstanceCategoryName";
//$NON-NLS-1$
- private static final String IMAGE_CATEGORY_NAME = "ImageCategoryName";
//$NON-NLS-1$
-
private TreeViewer viewer;
private boolean initialized;
-
+
public CVCloudElement(Object element, String name, TreeViewer viewer) {
- super(element, name);
+ super(element);
this.viewer = viewer;
}
+ public String getName() {
+ Object element = getElement();
+ if (element instanceof DeltaCloud) {
+ return ((DeltaCloud) element).getName();
+ } else {
+ return "";
+ }
+ }
+
public Viewer getViewer() {
return viewer;
}
@@ -41,29 +51,27 @@
public boolean hasChildren() {
return true;
}
-
+
@Override
public Object[] getChildren() {
if (!initialized) {
- DeltaCloud cloud = (DeltaCloud)getElement();
- CVCategoryElement c1 = new CVInstancesCategoryElement(cloud,
CVMessages.getString(INSTANCE_CATEGORY_NAME),
- viewer);
- CVCategoryElement c2 = new CVImagesCategoryElement(cloud,
CVMessages.getString(IMAGE_CATEGORY_NAME),
- viewer);
+ DeltaCloud cloud = (DeltaCloud) getElement();
+ CVCategoryElement c1 = new CVInstancesCategoryElement(cloud, viewer);
+ CVCategoryElement c2 = new CVImagesCategoryElement(cloud, viewer);
addChild(c1);
addChild(c2);
}
initialized = true;
return super.getChildren();
}
-
+
@Override
public IPropertySource getPropertySource() {
return new CloudPropertySource(getElement());
}
public void loadChildren() {
- DeltaCloud cloud = (DeltaCloud)getElement();
+ DeltaCloud cloud = (DeltaCloud) getElement();
try {
cloud.loadChildren();
} catch (Exception e) {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVImageElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVImageElement.java 2010-12-02
10:30:51 UTC (rev 27084)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVImageElement.java 2010-12-02
11:09:10 UTC (rev 27085)
@@ -11,13 +11,27 @@
package org.jboss.tools.deltacloud.ui.views;
import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloudImage;
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
public class CVImageElement extends CloudViewElement {
- public CVImageElement(Object element, String name) {
- super(element, name);
+ public CVImageElement(Object element) {
+ super(element);
}
-
+
+ public String getName() {
+ Object element = getElement();
+ if (element instanceof DeltaCloudImage) {
+ return ((DeltaCloudImage) element).getName();
+ } else {
+ return "";
+ }
+ }
+
@Override
public IPropertySource getPropertySource() {
return new ImagePropertySource(getElement());
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVImagesCategoryElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVImagesCategoryElement.java 2010-12-02
10:30:51 UTC (rev 27084)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVImagesCategoryElement.java 2010-12-02
11:09:10 UTC (rev 27085)
@@ -19,26 +19,36 @@
import org.jboss.tools.deltacloud.core.IImageListListener;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
public class CVImagesCategoryElement extends CVCategoryElement implements
IImageListListener {
- public CVImagesCategoryElement(Object element, String name, TreeViewer viewer) {
- super(element, name, viewer);
- DeltaCloud cloud = (DeltaCloud)getElement();
+ private static final String IMAGE_CATEGORY_NAME = "ImageCategoryName";
//$NON-NLS-1$
+
+ public CVImagesCategoryElement(Object element, TreeViewer viewer) {
+ super(element, viewer);
+ DeltaCloud cloud = (DeltaCloud) getElement();
cloud.addImageListListener(this);
}
-
+
+ public String getName() {
+ return CVMessages.getString(IMAGE_CATEGORY_NAME);
+ }
+
private void addImages(DeltaCloudImage[] images) {
if (images.length > CVNumericFoldingElement.FOLDING_SIZE) {
int min = 0;
int max = CVNumericFoldingElement.FOLDING_SIZE;
int length = images.length;
while (length > CVNumericFoldingElement.FOLDING_SIZE) {
- CVNumericFoldingElement f = new CVNumericFoldingElement(null,
- "[" + min + ".." + (max - 1) + "]"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
+ CVNumericFoldingElement f =
+ new CVNumericFoldingElement(null, "[" + min + ".." + (max - 1)
+ "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
addChild(f);
- for (int i = min; i < max; ++i) {
+ for (int i = min; i < max; ++i) {
DeltaCloudImage d = images[i];
- CVImageElement element = new CVImageElement(d, d.getName());
+ CVImageElement element = new CVImageElement(d);
f.addChild(element);
}
min += CVNumericFoldingElement.FOLDING_SIZE;
@@ -46,28 +56,28 @@
length -= CVNumericFoldingElement.FOLDING_SIZE;
}
if (length > 0) {
- CVNumericFoldingElement f = new CVNumericFoldingElement(null,
+ CVNumericFoldingElement f = new CVNumericFoldingElement(null,
"[" + min + ".." + (max - 1) + "]"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
addChild(f);
for (int i = min; i < min + length; ++i) {
DeltaCloudImage d = images[i];
- CVImageElement element = new CVImageElement(d, d.getName());
+ CVImageElement element = new CVImageElement(d);
f.addChild(element);
}
}
} else {
for (int i = 0; i < images.length; ++i) {
DeltaCloudImage d = images[i];
- CVImageElement element = new CVImageElement(d, d.getName());
+ CVImageElement element = new CVImageElement(d);
addChild(element);
}
}
}
-
+
@Override
public Object[] getChildren() {
if (!initialized) {
- DeltaCloud cloud = (DeltaCloud)getElement();
+ DeltaCloud cloud = (DeltaCloud) getElement();
try {
DeltaCloudImage[] images = filter(cloud.getImages());
cloud.removeImageListListener(this);
@@ -90,12 +100,12 @@
DeltaCloudImage[] images = filter(newImages);
addImages(images);
initialized = true;
- refresh();
+ // refresh();
}
-
+
public DeltaCloudImage[] filter(DeltaCloudImage[] input) {
ArrayList<DeltaCloudImage> array = new ArrayList<DeltaCloudImage>();
- DeltaCloud cloud = (DeltaCloud)getElement();
+ DeltaCloud cloud = (DeltaCloud) getElement();
IImageFilter f = cloud.getImageFilter();
for (int i = 0; i < input.length; ++i) {
DeltaCloudImage image = input[i];
@@ -105,9 +115,9 @@
return array.toArray(new DeltaCloudImage[array.size()]);
}
-
+
protected void dispose() {
- DeltaCloud cloud = (DeltaCloud)getElement();
+ DeltaCloud cloud = (DeltaCloud) getElement();
cloud.removeImageListListener(this);
}
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java 2010-12-02
10:30:51 UTC (rev 27084)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java 2010-12-02
11:09:10 UTC (rev 27085)
@@ -20,12 +20,14 @@
public class CVInstanceElement extends CloudViewElement {
public CVInstanceElement(Object element) {
- super(element, getName((DeltaCloudInstance) element));
+ super(element);
}
- private static String getName(DeltaCloudInstance instance) {
+ public String getName() {
+ Object element = getElement();
StringBuilder sb = new StringBuilder();
- if (instance != null) {
+ if (element instanceof DeltaCloudInstance) {
+ DeltaCloudInstance instance = (DeltaCloudInstance) element;
if (instance.getName() != null) {
sb.append(instance.getName());
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-12-02
10:30:51 UTC (rev 27084)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-12-02
11:09:10 UTC (rev 27085)
@@ -26,12 +26,18 @@
*/
public class CVInstancesCategoryElement extends CVCategoryElement implements
IInstanceListListener {
- public CVInstancesCategoryElement(Object element, String name, TreeViewer viewer) {
- super(element, name, viewer);
+ private static final String INSTANCE_CATEGORY_NAME = "InstanceCategoryName";
//$NON-NLS-1$
+
+ public CVInstancesCategoryElement(Object element, TreeViewer viewer) {
+ super(element, viewer);
DeltaCloud cloud = (DeltaCloud) getElement();
cloud.addInstanceListListener(this);
}
+ public String getName() {
+ return CVMessages.getString(INSTANCE_CATEGORY_NAME);
+ }
+
private void addInstances(DeltaCloudInstance[] instances) {
if (instances.length > CVNumericFoldingElement.FOLDING_SIZE) {
int min = 0;
@@ -96,7 +102,7 @@
final DeltaCloudInstance[] instances = filter(newInstances);
addInstances(instances);
initialized = true;
- refresh();
+// refresh();
}
private DeltaCloudInstance[] filter(DeltaCloudInstance[] input) {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVNumericFoldingElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVNumericFoldingElement.java 2010-12-02
10:30:51 UTC (rev 27084)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVNumericFoldingElement.java 2010-12-02
11:09:10 UTC (rev 27085)
@@ -12,15 +12,26 @@
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 String name;
public CVNumericFoldingElement(Object element, String name) {
- super(element, name);
+ super(element);
+ this.name = name;
}
@Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
public Object[] getChildren() {
return super.getChildren();
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVRootElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVRootElement.java 2010-12-02
10:30:51 UTC (rev 27084)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVRootElement.java 2010-12-02
11:09:10 UTC (rev 27085)
@@ -19,17 +19,26 @@
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 {
private boolean initialized;
private TreeViewer viewer;
public CVRootElement(TreeViewer viewer) {
- super(DeltaCloudManager.getDefault(), "root"); //$NON-NLS-1$
+ super(DeltaCloudManager.getDefault()); //$NON-NLS-1$
this.viewer = viewer;
}
@Override
+ public String getName() {
+ return "root";
+ }
+
+ @Override
public IPropertySource getPropertySource() {
// no property source for the root element
return null;
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewElement.java 2010-12-02
10:30:51 UTC (rev 27084)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewElement.java 2010-12-02
11:09:10 UTC (rev 27085)
@@ -15,13 +15,16 @@
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.views.properties.IPropertySource;
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
public abstract class CloudViewElement implements IAdaptable {
private Object element;
private CloudViewElement parent;
private ArrayList<CloudViewElement> children;
- private String name;
-
+
public abstract IPropertySource getPropertySource();
public Object[] getChildren() {
@@ -49,15 +52,12 @@
parent = e;
}
- public CloudViewElement(Object element, String name) {
+ public CloudViewElement(Object element) {
this.element = element;
- this.name = name;
children = new ArrayList<CloudViewElement>();
}
- public String getName() {
- return name;
- }
+ public abstract String getName();
public Object getElement() {
return element;