JBoss Tools SVN: r27087 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-02 07:10:04 -0500 (Thu, 02 Dec 2010)
New Revision: 27087
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
Log:
[JBIDE-7780] synchronized initialisation
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-02 12:09:08 UTC (rev 27086)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-02 12:10:04 UTC (rev 27087)
@@ -1,5 +1,7 @@
2010-12-02 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java (getChildren):
+ [JBIDE-7780] synchronized children initialisation
* 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):
14 years
JBoss Tools SVN: r27086 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-02 07:09:08 -0500 (Thu, 02 Dec 2010)
New Revision: 27086
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java
Log:
[JBIDE-7780] synchronized initialisation
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 11:09:10 UTC (rev 27085)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java 2010-12-02 12:09:08 UTC (rev 27086)
@@ -53,7 +53,7 @@
}
@Override
- public Object[] getChildren() {
+ public synchronized Object[] getChildren() {
if (!initialized) {
DeltaCloud cloud = (DeltaCloud) getElement();
CVCategoryElement c1 = new CVInstancesCategoryElement(cloud, viewer);
14 years
JBoss Tools SVN: r27085 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/deltacloud/ui/views and 1 other directory.
by jbosstools-commits@lists.jboss.org
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;
14 years
JBoss Tools SVN: r27084 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/deltacloud/ui/views and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-02 05:30:51 -0500 (Thu, 02 Dec 2010)
New Revision: 27084
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/AbstractCloudChildrenTableView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ITableContentAndLabelProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/TableViewerColumnComparator.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageComparator.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceComparator.java
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/ImageView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageViewLabelAndContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
Log:
[JBIDE-7693] removed a lot of duplicate code, unified Instance- and ImageView, Image- and InstanceComparator
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-02 10:29:55 UTC (rev 27083)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-02 10:30:51 UTC (rev 27084)
@@ -1,5 +1,12 @@
2010-12-02 André Dietisheim <adietish(a)redhat.com>
+ * 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:
+ * src/org/jboss/tools/deltacloud/ui/views/ImageView.java:
+ * 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
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/AbstractCloudChildrenTableView.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/AbstractCloudChildrenTableView.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/AbstractCloudChildrenTableView.java 2010-12-02 10:30:51 UTC (rev 27084)
@@ -0,0 +1,396 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+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.DeltaCloudManager;
+import org.jboss.tools.deltacloud.core.ICloudManagerListener;
+import org.jboss.tools.deltacloud.core.IInstanceFilter;
+import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.deltacloud.ui.ErrorUtils;
+import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public abstract class AbstractCloudChildrenTableView<T> extends ViewPart implements ICloudManagerListener {
+
+ private final static String CLOUD_SELECTOR_LABEL = "CloudSelector.label"; //$NON-NLS-1$
+
+ private static final String FILTERED_LABEL = "Filtered.label"; //$NON-NLS-1$
+ private static final String FILTERED_TOOLTIP = "FilteredImages.tooltip"; //$NON-NLS-1$
+
+ private Combo cloudSelector;
+ private Label cloudSelectorLabel;
+ private TableViewer viewer;
+
+ private DeltaCloud currCloud;
+
+ private ModifyListener cloudModifyListener = new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ int index = cloudSelector.getSelectionIndex();
+ if (index < 0) {
+ return;
+ }
+
+ removeListener(currCloud);
+
+ final DeltaCloud currentCloud = setCurrentCloud(index);
+ if (currentCloud != null) {
+ storeSelectedCloud(currentCloud);
+ Display.getCurrent().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ setViewerInput(currentCloud);
+ addListener(currentCloud);
+ }
+ });
+ }
+ }
+
+ private void storeSelectedCloud(DeltaCloud cloud) {
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ try {
+ prefs.put(getSelectedCloudPrefsKey(), cloud.getName());
+ } catch (Exception exc) {
+ // do nothing
+ }
+ }
+ };
+
+ private class ColumnListener extends SelectionAdapter {
+
+ private int column;
+
+ public ColumnListener(int column) {
+ this.column = column;
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ TableViewerColumnComparator comparator = (TableViewerColumnComparator) viewer.getComparator();
+ Table t = viewer.getTable();
+ if (comparator.getColumn() == column) {
+ comparator.reverseDirection();
+ }
+ comparator.setColumn(column);
+ TableColumn tc = (TableColumn) e.getSource();
+ t.setSortColumn(tc);
+ t.setSortDirection(SWT.NONE);
+ viewer.refresh();
+ }
+ };
+
+ protected abstract String getSelectedCloudPrefsKey();
+
+ protected abstract void addListener(DeltaCloud cloud);
+
+ protected abstract void removeListener(DeltaCloud cloud);
+
+ @Override
+ public void dispose() {
+ for (DeltaCloud cloud : getClouds()) {
+ removeListener(cloud);
+ }
+ DeltaCloudManager.getDefault().removeCloudManagerListener(this);
+ super.dispose();
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ FormLayout layout = new FormLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ container.setLayout(layout);
+
+ DeltaCloud[] clouds = getClouds();
+
+ createCloudSelector(container);
+ initCloudSelector(getLastSelectedCloud(), cloudSelector, clouds);
+
+ Label filterLabel = new Label(container, SWT.NULL);
+ filterLabel.setText(CVMessages.getString(FILTERED_LABEL));
+ filterLabel.setToolTipText(CVMessages.getString(FILTERED_TOOLTIP));
+
+ Composite tableArea = new Composite(container, SWT.NULL);
+ viewer = createTableViewer(tableArea);
+
+ currCloud = getCurrentCloud(cloudSelector.getSelectionIndex(), clouds);
+
+ addListener(currCloud);
+ setViewerInput(currCloud);
+ setFilterLabelVisible(currCloud, filterLabel);
+
+ Point p1 = cloudSelectorLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Point p2 = cloudSelector.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ int centering = (p2.y - p1.y + 1) / 2;
+
+ FormData f = new FormData();
+ f.top = new FormAttachment(0, 5 + centering);
+ f.left = new FormAttachment(0, 30);
+ cloudSelectorLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(0, 5);
+ f.left = new FormAttachment(cloudSelectorLabel, 5);
+ cloudSelector.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(0, 5 + centering);
+ f.right = new FormAttachment(100, -10);
+ filterLabel.setLayoutData(f);
+
+ f = new FormData();
+ f.top = new FormAttachment(cloudSelector, 8);
+ f.left = new FormAttachment(0, 0);
+ f.right = new FormAttachment(100, 0);
+ f.bottom = new FormAttachment(100, 0);
+ tableArea.setLayoutData(f);
+
+ // Create the help context id for the viewer's control
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.jboss.tools.deltacloud.ui.viewer");
+ hookContextMenu(viewer.getControl());
+ getSite().setSelectionProvider(viewer);
+
+ DeltaCloudManager.getDefault().addCloudManagerListener(this);
+ }
+
+ private TableViewer createTableViewer(Composite tableArea) {
+ TableColumnLayout tableLayout = new TableColumnLayout();
+ tableArea.setLayout(tableLayout);
+
+ TableViewer viewer = new TableViewer(tableArea,
+ SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.MULTI);
+ Table table = viewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ ITableContentAndLabelProvider provider = getContentAndLabelProvider();
+ viewer.setContentProvider(provider);
+ viewer.setLabelProvider(provider);
+ createColumns(tableLayout, table);
+
+ viewer.setComparator(new TableViewerColumnComparator());
+ table.setSortDirection(SWT.NONE);
+
+ return viewer;
+ }
+
+ protected abstract ITableContentAndLabelProvider getContentAndLabelProvider();
+
+ private void setViewerInput(DeltaCloud currentCloud) {
+ if (currentCloud != null) {
+ viewer.setInput(currentCloud);
+ }
+ }
+
+ protected void setViewerInput(T[] input) {
+ viewer.setInput(input);
+ }
+
+ private DeltaCloud[] getClouds() {
+ DeltaCloud[] clouds = new DeltaCloud[] {};
+ try {
+ clouds = DeltaCloudManager.getDefault().getClouds();
+ } catch (DeltaCloudException e) {
+ // TODO: internationalize strings
+ ErrorUtils.handleError(
+ "Error",
+ "Could not get all clouds",
+ e, Display.getDefault().getActiveShell());
+ }
+ return clouds;
+ }
+
+ private DeltaCloud setCurrentCloud(int index) {
+ DeltaCloud[] clouds = getClouds();
+ if (index < 0 || index >= clouds.length) {
+ currCloud = null;
+ } else {
+ currCloud = getClouds()[index];
+ }
+ return currCloud;
+ }
+
+ private void setFilterLabelVisible(DeltaCloud currentCloud, Label filterLabel) {
+ if (currentCloud == null) {
+ filterLabel.setVisible(false);
+ return;
+ }
+
+ IInstanceFilter filter = currentCloud.getInstanceFilter();
+ filterLabel.setVisible(!filter.toString().equals(IInstanceFilter.ALL_STRING));
+ }
+
+ private DeltaCloud getCurrentCloud(int selectedCloudIndex, DeltaCloud[] clouds) {
+ if (selectedCloudIndex < 0) {
+ return null;
+ }
+
+ return clouds[selectedCloudIndex];
+ }
+
+ private String getLastSelectedCloud() {
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ String lastSelectedCloud = prefs.get(IDeltaCloudPreferenceConstants.LAST_CLOUD_INSTANCE_VIEW, "");
+ return lastSelectedCloud;
+ }
+
+ private void createColumns(TableColumnLayout tableLayout, Table table) {
+ for (int i = 0; i < InstanceViewLabelAndContentProvider.Column.getSize(); ++i) {
+ InstanceViewLabelAndContentProvider.Column c =
+ InstanceViewLabelAndContentProvider.Column.getColumn(i);
+ TableColumn tc = new TableColumn(table, SWT.NONE);
+ if (i == 0) {
+ table.setSortColumn(tc);
+ }
+ tc.setText(CVMessages.getString(c.name()));
+ tableLayout.setColumnData(tc, new ColumnWeightData(c.getWeight(), true));
+ tc.addSelectionListener(new ColumnListener(i));
+ }
+ }
+
+ private void createCloudSelector(Composite parent) {
+ this.cloudSelectorLabel = new Label(parent, SWT.NULL);
+ cloudSelectorLabel.setText(CVMessages.getString(CLOUD_SELECTOR_LABEL));
+
+ this.cloudSelector = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
+ cloudSelector.addModifyListener(cloudModifyListener);
+ // Following is a kludge so that on Linux the Combo is read-only but
+ // has a white background.
+ cloudSelector.addVerifyListener(new VerifyListener() {
+ @Override
+ public void verifyText(VerifyEvent e) {
+ e.doit = false;
+ }
+ });
+ }
+
+ private void hookContextMenu(Control control) {
+ IMenuManager contextMenu = UIUtils.createContextMenu(control);
+ UIUtils.registerContributionManager(UIUtils.getContextMenuId(getViewID()), contextMenu, control);
+ }
+
+ protected abstract String getViewID();
+
+ private void initCloudSelector(String cloudToSelect, Combo cloudSelector, DeltaCloud[] clouds) {
+ int selectedIndex = 0;
+ String[] cloudNames = new String[clouds.length];
+ for (int i = 0; i < clouds.length; ++i) {
+ cloudNames[i] = clouds[i].getName();
+ if (cloudNames[i].equals(cloudToSelect))
+ selectedIndex = i;
+ }
+ if (cloudNames.length > 0) {
+ cloudSelector.setItems(cloudNames);
+ cloudSelector.setText(cloudNames[selectedIndex]);
+ }
+ }
+
+ public void cloudsChanged(int type) {
+ String currName = null;
+ int currIndex = 0;
+ if (currCloud != null) {
+ currName = currCloud.getName();
+ currIndex = cloudSelector.getSelectionIndex();
+ }
+ DeltaCloud[] clouds = getClouds();
+ String[] cloudNames = new String[clouds.length];
+ int index = 0;
+ for (int i = 0; i < clouds.length; ++i) {
+ cloudNames[i] = clouds[i].getName();
+ if (cloudNames[i].equals(currName))
+ index = i;
+ }
+ if (type == ICloudManagerListener.RENAME_EVENT) {
+ index = currIndex; // no change in cloud displayed
+ }
+
+ setCloudSelectorItems(cloudNames);
+ setCurrentCloud(index);
+
+ if (cloudNames.length > 0) {
+ cloudSelector.setText(cloudNames[index]);
+ viewer.setInput(currCloud);
+ } else {
+ cloudSelector.setText("");
+ viewer.setInput(new DeltaCloudInstance[0]);
+ }
+ }
+
+ private void setCloudSelectorItems(String[] cloudNames) {
+ cloudSelector.removeModifyListener(cloudModifyListener);
+ cloudSelector.setItems(cloudNames);
+ cloudSelector.addModifyListener(cloudModifyListener);
+ }
+
+ /**
+ * Refresh the states of the commands in the toolbar.
+ */
+ protected abstract void refreshToolbarCommandStates();
+
+ public void listChanged(final DeltaCloud cloud, final T[] cloudChildren) {
+ // Run following under Display thread since this can be
+ // triggered by a non-display thread notifying listeners.
+ if (cloud != null
+ && currCloud != null
+ && cloud.getName().equals(currCloud.getName())) {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ // does not add identical instance twice
+ addListener(cloud);
+ setViewerInput(cloudChildren);
+ refreshToolbarCommandStates();
+ }
+ });
+ }
+ }
+
+ @Override
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/AbstractCloudChildrenTableView.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ITableContentAndLabelProvider.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ITableContentAndLabelProvider.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ITableContentAndLabelProvider.java 2010-12-02 10:30:51 UTC (rev 27084)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+
+/**
+ * @author Andre Dietisheim
+ */
+public interface ITableContentAndLabelProvider extends IStructuredContentProvider, ITableLabelProvider{
+
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ITableContentAndLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageComparator.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageComparator.java 2010-12-02 10:29:55 UTC (rev 27083)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageComparator.java 2010-12-02 10:30:51 UTC (rev 27084)
@@ -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;
-
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.jboss.tools.deltacloud.core.DeltaCloudImage;
-
-public class ImageComparator extends ViewerComparator {
-
- private final static int UP = 1;
-
- private int column;
- private int direction;
-
- public ImageComparator(int column) {
- this.column = column;
- this.direction = UP;
- }
-
- public void setColumn(int newColumn) {
- if (column != newColumn)
- direction = UP;
- column = newColumn;
- }
-
- public int getColumn() {
- return column;
- }
-
- public void reverseDirection() {
- direction *= -1;
- }
-
- @Override
- public int compare(Viewer viewer, Object e1, Object e2) {
- if (!(e1 instanceof DeltaCloudImage) || !(e2 instanceof DeltaCloudImage))
- return 0;
-
- int tmp = compareByColumn(viewer, (DeltaCloudImage)e1, (DeltaCloudImage)e2);
- return tmp * direction;
- }
-
- private int compareByColumn(Viewer viewer, DeltaCloudImage e1, DeltaCloudImage e2) {
- ImageViewLabelAndContentProvider provider = (ImageViewLabelAndContentProvider)((TableViewer)viewer).getContentProvider();
- String s1 = provider.getColumnText(e1, column);
- String s2 = provider.getColumnText(e2, column);
- return s1.compareToIgnoreCase(s2);
- }
-}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageView.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageView.java 2010-12-02 10:29:55 UTC (rev 27083)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageView.java 2010-12-02 10:30:51 UTC (rev 27084)
@@ -10,321 +10,50 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.ui.views;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.layout.TableColumnLayout;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
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.DeltaCloudManager;
-import org.jboss.tools.deltacloud.core.ICloudManagerListener;
-import org.jboss.tools.deltacloud.core.IImageFilter;
import org.jboss.tools.deltacloud.core.IImageListListener;
-import org.jboss.tools.deltacloud.ui.Activator;
-import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
-import org.osgi.service.prefs.Preferences;
-public class ImageView extends ViewPart implements ICloudManagerListener, IImageListListener {
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class ImageView extends AbstractCloudChildrenTableView<DeltaCloudImage> implements IImageListListener {
- public static final String ID = "org.jboss.tools.deltacloud.ui.views.ImageView";
-
- private final static String CLOUD_SELECTOR_LABEL = "CloudSelector.label"; //$NON-NLS-1$
- private static final String FILTERED_LABEL = "Filtered.label"; //$NON-NLS-1$
- private static final String FILTERED_TOOLTIP = "FilteredImages.tooltip"; //$NON-NLS-1$
- private TableViewer viewer;
- private Composite container;
- private Combo cloudSelector;
- private Label filterLabel;
- private DeltaCloud[] clouds;
- private DeltaCloud currCloud;
-
- private ModifyListener cloudModifyListener = new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- if (currCloud != null) {
- currCloud.removeImageListListener(ImageView.this);
- }
- int index = cloudSelector.getSelectionIndex();
- if (index >= 0) {
- currCloud = clouds[index];
- storeSelectedCloud();
-
- Display.getCurrent().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- viewer.setInput(currCloud);
- currCloud.addImageListListener(ImageView.this);
- viewer.refresh();
- }
-
- });
- }
- }
-
- private void storeSelectedCloud() {
- Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
- try {
- prefs.put(IDeltaCloudPreferenceConstants.LAST_CLOUD_IMAGE_VIEW, currCloud.getName());
- } catch (Exception exc) {
- // do nothing
- }
- }
- };
-
- private class ColumnListener extends SelectionAdapter {
-
- private int column;
-
- public ColumnListener(int column, TableViewer viewer) {
- this.column = column;
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- ImageComparator comparator = (ImageComparator) viewer.getComparator();
- Table t = viewer.getTable();
- if (comparator.getColumn() == column) {
- comparator.reverseDirection();
- }
- comparator.setColumn(column);
- TableColumn tc = (TableColumn) e.getSource();
- t.setSortColumn(tc);
- t.setSortDirection(SWT.NONE);
- viewer.refresh();
- }
-
- };
-
@Override
- public void dispose() {
- for (DeltaCloud cloud : clouds) {
- cloud.removeImageListListener(this);
- }
- DeltaCloudManager.getDefault().removeCloudManagerListener(this);
- super.dispose();
+ protected String getSelectedCloudPrefsKey() {
+ return IDeltaCloudPreferenceConstants.LAST_CLOUD_IMAGE_VIEW;
}
@Override
- public void createPartControl(Composite parent) {
- container = new Composite(parent, SWT.NULL);
- FormLayout layout = new FormLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- container.setLayout(layout);
-
- Label cloudSelectorLabel = new Label(container, SWT.NULL);
- cloudSelectorLabel.setText(CVMessages.getString(CLOUD_SELECTOR_LABEL));
-
- cloudSelector = new Combo(container, SWT.BORDER | SWT.READ_ONLY);
- clouds = getClouds();
- initializeCloudSelector(clouds);
- cloudSelector.addModifyListener(cloudModifyListener);
- // Following is a kludge so that on Linux the Combo is read-only but
- // has a white background.
- cloudSelector.addVerifyListener(new VerifyListener() {
- @Override
- public void verifyText(VerifyEvent e) {
- e.doit = false;
- }
- });
-
- filterLabel = new Label(container, SWT.NULL);
- filterLabel.setText(CVMessages.getString(FILTERED_LABEL));
- filterLabel.setToolTipText(CVMessages.getString(FILTERED_TOOLTIP));
-
- Composite tableArea = createTableViewer();
-
- ImageComparator comparator = new ImageComparator(0);
- viewer.setComparator(comparator);
- getSite().setSelectionProvider(viewer);
-
- if (currCloud != null) {
- currCloud.removeImageListListener(this);
- viewer.setInput(currCloud);
- currCloud.addImageListListener(this);
- IImageFilter filter = currCloud.getImageFilter();
- filterLabel.setVisible(!filter.toString().equals(IImageFilter.ALL_STRING));
- }
-
- Point p1 = cloudSelectorLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Point p2 = cloudSelector.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- int centering = (p2.y - p1.y + 1) / 2;
-
- FormData f = new FormData();
- f.top = new FormAttachment(0, 5 + centering);
- f.left = new FormAttachment(0, 30);
- cloudSelectorLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(0, 5);
- f.left = new FormAttachment(cloudSelectorLabel, 5);
- cloudSelector.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(0, 5 + centering);
- f.right = new FormAttachment(100, -10);
- filterLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(cloudSelector, 8);
- f.left = new FormAttachment(0, 0);
- f.right = new FormAttachment(100, 0);
- f.bottom = new FormAttachment(100, 0);
- tableArea.setLayoutData(f);
-
- // Create the help context id for the viewer's control
- PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.jboss.tools.deltacloud.ui.viewer");
- hookContextMenu();
-
- DeltaCloudManager.getDefault().addCloudManagerListener(this);
+ protected String getViewID() {
+ return "org.jboss.tools.deltacloud.ui.views.ImageView";
}
- private Composite createTableViewer() {
- Composite tableArea = new Composite(container, SWT.NULL);
- TableColumnLayout tableLayout = new TableColumnLayout();
- tableArea.setLayout(tableLayout);
-
- viewer = new TableViewer(tableArea, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- Table table = viewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- createColumns(tableLayout, table);
- ImageViewLabelAndContentProvider provider = new ImageViewLabelAndContentProvider();
- viewer.setContentProvider(provider);
- viewer.setLabelProvider(provider);
- return tableArea;
+ @Override
+ protected ITableContentAndLabelProvider getContentAndLabelProvider() {
+ return new ImageViewLabelAndContentProvider();
}
- private void createColumns(TableColumnLayout tableLayout, Table table) {
- for (int i = 0; i < ImageViewLabelAndContentProvider.Column.getSize(); ++i) {
- ImageViewLabelAndContentProvider.Column c =
- ImageViewLabelAndContentProvider.Column.getColumn(i);
- TableColumn tc = new TableColumn(table, SWT.NONE);
- if (i == 0)
- table.setSortColumn(tc);
- tc.setText(CVMessages.getString(c.name()));
- tableLayout.setColumnData(tc, new ColumnWeightData(c.getWeight(), true));
- tc.addSelectionListener(new ColumnListener(i, viewer));
- }
- table.setSortDirection(SWT.NONE);
- }
-
- private void hookContextMenu() {
- IMenuManager contextMenu = UIUtils.createContextMenu(viewer.getTable());
- UIUtils.registerContributionManager(UIUtils.getContextMenuId(ID), contextMenu, viewer.getTable());
- }
-
@Override
- public void setFocus() {
- viewer.getTable().setFocus();
+ protected void refreshToolbarCommandStates() {
+ // do nothing
}
- private void initializeCloudSelector(DeltaCloud[] clouds) {
- int defaultIndex = 0;
- String[] cloudNames = new String[clouds.length];
- // If we have saved the last cloud used from a previous session,
- // default to using that cloud to start unless it no longer exists
- Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
- String lastCloudUsed = prefs.get(IDeltaCloudPreferenceConstants.LAST_CLOUD_IMAGE_VIEW, "");
- for (int i = 0; i < clouds.length; ++i) {
- cloudNames[i] = clouds[i].getName();
- if (cloudNames[i].equals(lastCloudUsed))
- defaultIndex = i;
+ @Override
+ protected void addListener(DeltaCloud currentCloud) {
+ if (currentCloud != null) {
+ currentCloud.removeImageListListener(this);
+ currentCloud.addImageListListener(this);
}
- cloudSelector.setItems(cloudNames);
- if (clouds.length > 0) {
- cloudSelector.setText(cloudNames[defaultIndex]);
- currCloud = clouds[defaultIndex];
- }
}
- public void cloudsChanged(int type) {
- String currName = null;
- int currIndex = 0;
- clouds = getClouds();
- if (currCloud != null) {
- currName = currCloud.getName();
- currIndex = cloudSelector.getSelectionIndex();
+ @Override
+ protected void removeListener(DeltaCloud currentCloud) {
+ if (currentCloud != null) {
+ currentCloud.removeImageListListener(this);
+ currentCloud.addImageListListener(this);
}
- String[] cloudNames = new String[clouds.length];
- int index = 0;
- for (int i = 0; i < clouds.length; ++i) {
- cloudNames[i] = clouds[i].getName();
- if (cloudNames[i].equals(currName))
- index = i;
- }
- if (type == ICloudManagerListener.RENAME_EVENT) {
- index = currIndex; // no change in cloud displayed
- }
- cloudSelector.removeModifyListener(cloudModifyListener);
- cloudSelector.setItems(cloudNames);
- if (cloudNames.length > 0) {
- cloudSelector.setText(cloudNames[index]);
- currCloud = clouds[index];
- viewer.setInput(currCloud);
- } else {
- currCloud = null;
- cloudSelector.setText("");
- viewer.setInput(new DeltaCloudImage[0]);
- }
- cloudSelector.addModifyListener(cloudModifyListener);
}
-
- public void listChanged(DeltaCloud cloud, DeltaCloudImage[] list) {
- final DeltaCloudImage[] finalList = list;
- if (cloud.getName().equals(currCloud.getName())) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- // TODO Auto-generated method stub
- currCloud.removeImageListListener(ImageView.this);
- viewer.setInput(finalList);
- currCloud.addImageListListener(ImageView.this);
- viewer.refresh();
- }
-
- });
- }
- }
-
- private DeltaCloud[] getClouds() {
- DeltaCloud[] clouds = new DeltaCloud[]{};
- try {
- clouds = DeltaCloudManager.getDefault().getClouds();
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- "Could not get all clouds",
- e, Display.getDefault().getActiveShell());
- }
- return clouds;
- }
-
-
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageViewLabelAndContentProvider.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageViewLabelAndContentProvider.java 2010-12-02 10:29:55 UTC (rev 27083)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageViewLabelAndContentProvider.java 2010-12-02 10:30:51 UTC (rev 27084)
@@ -16,8 +16,6 @@
import java.util.Map;
import org.eclipse.jface.viewers.BaseLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
@@ -26,8 +24,10 @@
import org.jboss.tools.deltacloud.core.IImageFilter;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
-public class ImageViewLabelAndContentProvider extends BaseLabelProvider implements IStructuredContentProvider,
- ITableLabelProvider {
+/**
+ * @author Jeff Johnston
+ */
+public class ImageViewLabelAndContentProvider extends BaseLabelProvider implements ITableContentAndLabelProvider {
private DeltaCloud cloud;
private IImageFilter localFilter;
Deleted: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceComparator.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceComparator.java 2010-12-02 10:29:55 UTC (rev 27083)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceComparator.java 2010-12-02 10:30:51 UTC (rev 27084)
@@ -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;
-
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-
-public class InstanceComparator extends ViewerComparator {
-
- private final static int UP = 1;
-
- private int column;
- private int direction;
-
- public InstanceComparator(int column) {
- this.column = column;
- this.direction = UP;
- }
-
- public void setColumn(int newColumn) {
- if (column != newColumn)
- direction = UP;
- column = newColumn;
- }
-
- public int getColumn() {
- return column;
- }
-
- public void reverseDirection() {
- direction *= -1;
- }
-
- @Override
- public int compare(Viewer viewer, Object e1, Object e2) {
- if (!(e1 instanceof DeltaCloudInstance) || !(e2 instanceof DeltaCloudInstance))
- return 0;
-
- int tmp = compareByColumn(viewer, (DeltaCloudInstance)e1, (DeltaCloudInstance)e2);
- return tmp * direction;
- }
-
- private int compareByColumn(Viewer viewer, DeltaCloudInstance e1, DeltaCloudInstance e2) {
- InstanceViewLabelAndContentProvider provider = (InstanceViewLabelAndContentProvider)((TableViewer)viewer).getContentProvider();
- String s1 = provider.getColumnText(e1, column);
- String s2 = provider.getColumnText(e2, column);
- return s1.compareToIgnoreCase(s2);
- }
-}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-12-02 10:29:55 UTC (rev 27083)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-12-02 10:30:51 UTC (rev 27084)
@@ -10,394 +10,55 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.ui.views;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.layout.TableColumnLayout;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.services.IEvaluationService;
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.DeltaCloudManager;
-import org.jboss.tools.deltacloud.core.ICloudManagerListener;
-import org.jboss.tools.deltacloud.core.IInstanceFilter;
import org.jboss.tools.deltacloud.core.IInstanceListListener;
-import org.jboss.tools.deltacloud.ui.Activator;
-import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
-import org.osgi.service.prefs.Preferences;
-public class InstanceView extends ViewPart implements ICloudManagerListener, IInstanceListListener {
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class InstanceView extends AbstractCloudChildrenTableView<DeltaCloudInstance> implements IInstanceListListener {
- public static final String ID = "org.jboss.tools.deltacloud.ui.views.InstanceView";
+ protected String getSelectedCloudPrefsKey() {
+ return IDeltaCloudPreferenceConstants.LAST_CLOUD_INSTANCE_VIEW;
+ }
- private final static String CLOUD_SELECTOR_LABEL = "CloudSelector.label"; //$NON-NLS-1$
-
- private static final String FILTERED_LABEL = "Filtered.label"; //$NON-NLS-1$
- private static final String FILTERED_TOOLTIP = "FilteredImages.tooltip"; //$NON-NLS-1$
-
- private TableViewer viewer;
- private Composite container;
- private Combo cloudSelector;
- private Label filterLabel;
-
- private DeltaCloud currCloud;
-
- private InstanceViewLabelAndContentProvider contentProvider;
-
- private ModifyListener cloudModifyListener = new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- int index = cloudSelector.getSelectionIndex();
- if (index < 0) {
- return;
- }
-
- if (currCloud != null) {
- currCloud.removeInstanceListListener(InstanceView.this);
- }
- DeltaCloud currentCloud = setCurrentCloud(index);
- if (currentCloud != null) {
- storeSelectedCloud(currentCloud);
- Display.getCurrent().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- viewer.setInput(currCloud);
- currCloud.addInstanceListListener(InstanceView.this);
- }
- });
- }
- }
-
- private void storeSelectedCloud(DeltaCloud cloud) {
- Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
- try {
- prefs.put(IDeltaCloudPreferenceConstants.LAST_CLOUD_INSTANCE_VIEW, cloud.getName());
- } catch (Exception exc) {
- // do nothing
- }
- }
- };
-
- private Label cloudSelectorLabel;
-
- private class ColumnListener extends SelectionAdapter {
-
- private int column;
-
- public ColumnListener(int column) {
- this.column = column;
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- InstanceComparator comparator = (InstanceComparator) viewer.getComparator();
- Table t = viewer.getTable();
- if (comparator.getColumn() == column) {
- comparator.reverseDirection();
- }
- comparator.setColumn(column);
- TableColumn tc = (TableColumn) e.getSource();
- t.setSortColumn(tc);
- t.setSortDirection(SWT.NONE);
- viewer.refresh();
- }
-
- };
-
@Override
- public void dispose() {
- for (DeltaCloud cloud : getClouds()) {
- cloud.removeInstanceListListener(this);
- }
- DeltaCloudManager.getDefault().removeCloudManagerListener(this);
- super.dispose();
+ protected String getViewID() {
+ return "org.jboss.tools.deltacloud.ui.views.InstanceView";
}
@Override
- public void createPartControl(Composite parent) {
- container = new Composite(parent, SWT.NULL);
- FormLayout layout = new FormLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- container.setLayout(layout);
-
- DeltaCloud[] clouds = getClouds();
-
- createCloudSelector();
- initCloudSelector(getLastSelectedCloud(), cloudSelector, clouds);
-
- filterLabel = new Label(container, SWT.NULL);
- filterLabel.setText(CVMessages.getString(FILTERED_LABEL));
- filterLabel.setToolTipText(CVMessages.getString(FILTERED_TOOLTIP));
-
- Composite tableArea = new Composite(container, SWT.NULL);
- viewer = createTableViewer(tableArea);
-
- currCloud = getCurrentCloud(cloudSelector.getSelectionIndex(), clouds);
-
- addInstanceListener(currCloud, viewer);
- setViewerInput(currCloud);
- setFilterLabelVisible(currCloud, filterLabel);
-
- Point p1 = cloudSelectorLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Point p2 = cloudSelector.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- int centering = (p2.y - p1.y + 1) / 2;
-
- FormData f = new FormData();
- f.top = new FormAttachment(0, 5 + centering);
- f.left = new FormAttachment(0, 30);
- cloudSelectorLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(0, 5);
- f.left = new FormAttachment(cloudSelectorLabel, 5);
- cloudSelector.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(0, 5 + centering);
- f.right = new FormAttachment(100, -10);
- filterLabel.setLayoutData(f);
-
- f = new FormData();
- f.top = new FormAttachment(cloudSelector, 8);
- f.left = new FormAttachment(0, 0);
- f.right = new FormAttachment(100, 0);
- f.bottom = new FormAttachment(100, 0);
- tableArea.setLayoutData(f);
-
- // Create the help context id for the viewer's control
- PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.jboss.tools.deltacloud.ui.viewer");
- hookContextMenu(viewer.getTable());
- getSite().setSelectionProvider(viewer);
-
- DeltaCloudManager.getDefault().addCloudManagerListener(this);
+ protected ITableContentAndLabelProvider getContentAndLabelProvider() {
+ return new InstanceViewLabelAndContentProvider();
}
-
- private void setViewerInput(DeltaCloud currentCloud) {
- if (currentCloud != null) {
- viewer.setInput(currentCloud);
- }
+
+ @Override
+ protected void refreshToolbarCommandStates() {
+ IEvaluationService evaluationService = (IEvaluationService) PlatformUI.getWorkbench().getService(
+ IEvaluationService.class);
+ evaluationService.requestEvaluation("org.jboss.tools.deltacloud.ui.commands.canStart");
+ evaluationService.requestEvaluation("org.jboss.tools.deltacloud.ui.commands.canStop");
+ evaluationService.requestEvaluation("org.jboss.tools.deltacloud.ui.commands.canReboot");
+ evaluationService.requestEvaluation("org.jboss.tools.deltacloud.ui.commands.canDestroy");
}
- private DeltaCloud[] getClouds() {
- DeltaCloud[] clouds = new DeltaCloud[] {};
- try {
- clouds = DeltaCloudManager.getDefault().getClouds();
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- "Could not get all clouds",
- e, Display.getDefault().getActiveShell());
- }
- return clouds;
- }
- private DeltaCloud setCurrentCloud(int index) {
- DeltaCloud[] clouds = getClouds();
- if (index < 0 || index >= clouds.length) {
- currCloud = null;
- } else {
- currCloud = getClouds()[index];
+ protected void addListener(DeltaCloud currentCloud) {
+ if (currentCloud != null) {
+ currentCloud.removeInstanceListListener(this);
+ currentCloud.addInstanceListListener(this);
}
- return currCloud;
}
- private void setFilterLabelVisible(DeltaCloud currentCloud, Label filterLabel) {
- if (currentCloud == null) {
- filterLabel.setVisible(false);
- return;
- }
-
- IInstanceFilter filter = currentCloud.getInstanceFilter();
- filterLabel.setVisible(!filter.toString().equals(IInstanceFilter.ALL_STRING));
- }
-
- private void addInstanceListener(DeltaCloud currentCloud, Viewer viewer) {
+ protected void removeListener(DeltaCloud currentCloud) {
if (currentCloud != null) {
currentCloud.removeInstanceListListener(this);
currentCloud.addInstanceListListener(this);
}
}
-
- private DeltaCloud getCurrentCloud(int selectedCloudIndex, DeltaCloud[] clouds) {
- if (selectedCloudIndex < 0) {
- return null;
- }
-
- return clouds[selectedCloudIndex];
- }
-
- private String getLastSelectedCloud() {
- Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
- String lastSelectedCloud = prefs.get(IDeltaCloudPreferenceConstants.LAST_CLOUD_INSTANCE_VIEW, "");
- return lastSelectedCloud;
- }
-
- private TableViewer createTableViewer(Composite tableArea) {
- TableColumnLayout tableLayout = new TableColumnLayout();
- tableArea.setLayout(tableLayout);
-
- TableViewer viewer = new TableViewer(tableArea, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER
- | SWT.MULTI);
- Table table = viewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- contentProvider = new InstanceViewLabelAndContentProvider();
- viewer.setContentProvider(contentProvider);
- viewer.setLabelProvider(contentProvider);
- InstanceComparator comparator = new InstanceComparator(0);
- viewer.setComparator(comparator);
- createColumns(tableLayout, table);
- table.setSortDirection(SWT.NONE);
- return viewer;
-
- }
-
- private void createColumns(TableColumnLayout tableLayout, Table table) {
- for (int i = 0; i < InstanceViewLabelAndContentProvider.Column.getSize(); ++i) {
- InstanceViewLabelAndContentProvider.Column c =
- InstanceViewLabelAndContentProvider.Column.getColumn(i);
- TableColumn tc = new TableColumn(table, SWT.NONE);
- if (i == 0) {
- table.setSortColumn(tc);
- }
- tc.setText(CVMessages.getString(c.name()));
- tableLayout.setColumnData(tc, new ColumnWeightData(c.getWeight(), true));
- tc.addSelectionListener(new ColumnListener(i));
- }
- }
-
- private void createCloudSelector() {
- this.cloudSelectorLabel = new Label(container, SWT.NULL);
- cloudSelectorLabel.setText(CVMessages.getString(CLOUD_SELECTOR_LABEL));
-
- this.cloudSelector = new Combo(container, SWT.BORDER | SWT.READ_ONLY);
- cloudSelector.addModifyListener(cloudModifyListener);
- // Following is a kludge so that on Linux the Combo is read-only but
- // has a white background.
- cloudSelector.addVerifyListener(new VerifyListener() {
- @Override
- public void verifyText(VerifyEvent e) {
- e.doit = false;
- }
- });
- }
-
- private void hookContextMenu(Control control) {
- IMenuManager contextMenu = UIUtils.createContextMenu(control);
- UIUtils.registerContributionManager(UIUtils.getContextMenuId(ID), contextMenu, control);
- }
-
- private void initCloudSelector(String cloudToSelect, Combo cloudSelector, DeltaCloud[] clouds) {
- int selectedIndex = 0;
- String[] cloudNames = new String[clouds.length];
- for (int i = 0; i < clouds.length; ++i) {
- cloudNames[i] = clouds[i].getName();
- if (cloudNames[i].equals(cloudToSelect))
- selectedIndex = i;
- }
- if (cloudNames.length > 0) {
- cloudSelector.setItems(cloudNames);
- cloudSelector.setText(cloudNames[selectedIndex]);
- }
- }
-
- public void cloudsChanged(int type) {
- String currName = null;
- int currIndex = 0;
- if (currCloud != null) {
- currName = currCloud.getName();
- currIndex = cloudSelector.getSelectionIndex();
- }
- DeltaCloud[] clouds = getClouds();
- String[] cloudNames = new String[clouds.length];
- int index = 0;
- for (int i = 0; i < clouds.length; ++i) {
- cloudNames[i] = clouds[i].getName();
- if (cloudNames[i].equals(currName))
- index = i;
- }
- if (type == ICloudManagerListener.RENAME_EVENT) {
- index = currIndex; // no change in cloud displayed
- }
-
- setCloudSelectorItems(cloudNames);
- setCurrentCloud(index);
-
- if (cloudNames.length > 0) {
- cloudSelector.setText(cloudNames[index]);
- viewer.setInput(currCloud);
- } else {
- cloudSelector.setText("");
- viewer.setInput(new DeltaCloudInstance[0]);
- }
- }
-
- private void setCloudSelectorItems(String[] cloudNames) {
- cloudSelector.removeModifyListener(cloudModifyListener);
- cloudSelector.setItems(cloudNames);
- cloudSelector.addModifyListener(cloudModifyListener);
- }
-
- public void listChanged(DeltaCloud cloud, final DeltaCloudInstance[] instances) {
- // Run following under Display thread since this can be
- // triggered by a non-display thread notifying listeners.
- if (cloud != null
- && currCloud != null
- && cloud.getName().equals(currCloud.getName())) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- // does not add identical instance twice
- currCloud.addInstanceListListener(InstanceView.this);
- viewer.setInput(instances);
- refreshToolbarCommandStates();
- }
- });
- }
- }
-
- /**
- * Refresh the states of the commands in the toolbar.
- */
- private void refreshToolbarCommandStates() {
- IEvaluationService evaluationService = (IEvaluationService) PlatformUI.getWorkbench().getService(
- IEvaluationService.class);
- evaluationService.requestEvaluation("org.jboss.tools.deltacloud.ui.commands.canStart");
- evaluationService.requestEvaluation("org.jboss.tools.deltacloud.ui.commands.canStop");
- evaluationService.requestEvaluation("org.jboss.tools.deltacloud.ui.commands.canReboot");
- evaluationService.requestEvaluation("org.jboss.tools.deltacloud.ui.commands.canDestroy");
- }
-
- @Override
- public void setFocus() {
- viewer.getControl().setFocus();
- }
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java 2010-12-02 10:29:55 UTC (rev 27083)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceViewLabelAndContentProvider.java 2010-12-02 10:30:51 UTC (rev 27084)
@@ -16,8 +16,6 @@
import java.util.Map;
import org.eclipse.jface.viewers.BaseLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
@@ -29,8 +27,11 @@
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
-public class InstanceViewLabelAndContentProvider extends BaseLabelProvider implements IStructuredContentProvider,
- ITableLabelProvider {
+/**
+ * @author Jeff Jonhston
+ * @author Andre Dietisheim
+ */
+public class InstanceViewLabelAndContentProvider extends BaseLabelProvider implements ITableContentAndLabelProvider {
private DeltaCloud cloud;
private DeltaCloudInstance[] instances = new DeltaCloudInstance[]{};
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/TableViewerColumnComparator.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/TableViewerColumnComparator.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/TableViewerColumnComparator.java 2010-12-02 10:30:51 UTC (rev 27084)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+
+/**
+ * A viewer comparator that compares labels in a column of a table.<br>
+ * This implementation was extracted out of the former Image- and
+ * InstanceComparator which were mostly identical.
+ *
+ * @see ViewerComparator
+ *
+ * @author Jeff Johnston
+ * @author André Dietisheim
+ */
+public class TableViewerColumnComparator extends ViewerComparator {
+
+ private final static int UP = 1;
+
+ private int column;
+ private int direction;
+
+ public TableViewerColumnComparator() {
+ this(0);
+ }
+
+ public TableViewerColumnComparator(int column) {
+ this.column = column;
+ this.direction = UP;
+ }
+
+ public void setColumn(int newColumn) {
+ if (column != newColumn)
+ direction = UP;
+ column = newColumn;
+ }
+
+ public int getColumn() {
+ return column;
+ }
+
+ public void reverseDirection() {
+ direction *= -1;
+ }
+
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ int tmp = compareByColumn(viewer, e1, e2);
+ return tmp * direction;
+ }
+
+ private int compareByColumn(Viewer viewer, Object e1, Object e2) {
+ Assert.isTrue(viewer instanceof TableViewer
+ && ((TableViewer) viewer).getLabelProvider() instanceof ITableLabelProvider);
+
+ ITableLabelProvider provider = (ITableLabelProvider) ((TableViewer) viewer).getLabelProvider();
+ String s1 = provider.getColumnText(e1, column);
+ String s2 = provider.getColumnText(e2, column);
+ return s1.compareToIgnoreCase(s2);
+ }
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/TableViewerColumnComparator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java 2010-12-02 10:29:55 UTC (rev 27083)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImagePage.java 2010-12-02 10:30:51 UTC (rev 27084)
@@ -33,8 +33,8 @@
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.deltacloud.ui.views.ImageComparator;
import org.jboss.tools.deltacloud.ui.views.ImageViewLabelAndContentProvider;
+import org.jboss.tools.deltacloud.ui.views.TableViewerColumnComparator;
public class FindImagePage extends WizardPage {
@@ -83,7 +83,7 @@
}
@Override
public void widgetSelected(SelectionEvent e) {
- ImageComparator comparator = (ImageComparator)viewer.getComparator();
+ TableViewerColumnComparator comparator = (TableViewerColumnComparator)viewer.getComparator();
Table t = viewer.getTable();
if (comparator.getColumn() == column) {
comparator.reverseDirection();
@@ -220,7 +220,7 @@
contentProvider = new ImageViewLabelAndContentProvider();
viewer.setContentProvider(contentProvider);
viewer.setLabelProvider(contentProvider);
- ImageComparator comparator = new ImageComparator(0);
+ TableViewerColumnComparator comparator = new TableViewerColumnComparator();
viewer.setComparator(comparator);
for (int i = 0; i < ImageViewLabelAndContentProvider.Column.getSize(); ++i) {
14 years
JBoss Tools SVN: r27083 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-02 05:29:55 -0500 (Thu, 02 Dec 2010)
New Revision: 27083
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
Log:
added TODO comment
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-02 09:20:03 UTC (rev 27082)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-02 10:29:55 UTC (rev 27083)
@@ -503,6 +503,8 @@
images = new DeltaCloudImagesRepository();
}
images.add(client.listImages(), this);
+ // TODO: remove notification with all instances, replace by
+ // notifying the changed instance
return notifyImageListListeners(images.get());
} catch (DeltaCloudClientException e) {
throw new DeltaCloudException(MessageFormat.format("Could not load images of cloud {0}: {1}",
14 years
JBoss Tools SVN: r27082 - in branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/deltacloud/ui/views and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-02 04:20:03 -0500 (Thu, 02 Dec 2010)
New Revision: 27082
Modified:
branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java
branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
Log:
[JBIDE-7779] changed label for instances in CloudView
Modified: branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-02 09:19:15 UTC (rev 27081)
+++ branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-02 09:20:03 UTC (rev 27082)
@@ -1,3 +1,16 @@
+2010-12-02 adietisheim <adietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java (addInstances):
+ * src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java (getName):
+ [JBIDE-7779] changed label for instances in CloudView
+
+2010-11-24 adietisheim <adietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (.modifyText):
+ [JBIDE-7694] removed refresh(es) of tableViewer (setInput should be enough),
+ moved set of current cloud to central method with null-check,
+ removed clouds collection & replaced by fresh fetch in DeltaCloudManager
+
2010-11-19 André Dietisheim <adietish(a)redhat.com>
* plugin.xml:
Modified: branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java
===================================================================
--- branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java 2010-12-02 09:19:15 UTC (rev 27081)
+++ branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java 2010-12-02 09:20:03 UTC (rev 27082)
@@ -11,13 +11,31 @@
package org.jboss.tools.deltacloud.ui.views;
import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
public class CVInstanceElement extends CloudViewElement {
- public CVInstanceElement(Object element, String name) {
- super(element, name);
+ public CVInstanceElement(Object element) {
+ super(element, getName((DeltaCloudInstance) element));
}
-
+
+ private static String getName(DeltaCloudInstance instance) {
+ StringBuilder sb = new StringBuilder();
+ if (instance != null) {
+ 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());
Modified: branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
===================================================================
--- branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-12-02 09:19:15 UTC (rev 27081)
+++ branches/jbosstools-3.2.0.Beta2/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-12-02 09:20:03 UTC (rev 27082)
@@ -20,6 +20,10 @@
import org.jboss.tools.deltacloud.core.IInstanceListListener;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
public class CVInstancesCategoryElement extends CVCategoryElement implements IInstanceListListener {
public CVInstancesCategoryElement(Object element, String name, TreeViewer viewer) {
@@ -39,7 +43,7 @@
addChild(f);
for (int i = min; i < max; ++i) {
DeltaCloudInstance d = instances[i];
- CVInstanceElement element = new CVInstanceElement(d, d.getName());
+ CVInstanceElement element = new CVInstanceElement(d);
f.addChild(element);
}
min += CVNumericFoldingElement.FOLDING_SIZE;
@@ -52,14 +56,14 @@
addChild(f);
for (int i = min; i < min + length; ++i) {
DeltaCloudInstance d = instances[i];
- CVInstanceElement element = new CVInstanceElement(d, d.getName());
+ CVInstanceElement element = new CVInstanceElement(d);
f.addChild(element);
}
}
} else {
for (int i = 0; i < instances.length; ++i) {
DeltaCloudInstance d = instances[i];
- CVInstanceElement element = new CVInstanceElement(d, d.getName());
+ CVInstanceElement element = new CVInstanceElement(d);
addChild(element);
}
}
14 years
JBoss Tools SVN: r27081 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/deltacloud/ui/views and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-02 04:19:15 -0500 (Thu, 02 Dec 2010)
New Revision: 27081
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/CVInstanceElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
Log:
[JBIDE-7779] changed label for instances in CloudView
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-02 08:59:41 UTC (rev 27080)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-02 09:19:15 UTC (rev 27081)
@@ -1,3 +1,9 @@
+2010-12-02 André Dietisheim <adietish(a)redhat.com>
+
+ * 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>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnectionWizard.java (performFinish):
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 08:59:41 UTC (rev 27080)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java 2010-12-02 09:19:15 UTC (rev 27081)
@@ -24,10 +24,17 @@
}
private static String getName(DeltaCloudInstance instance) {
- return new StringBuilder(
- instance.getName())
- .append("[").append(instance.getId()).append("]")
- .toString();
+ StringBuilder sb = new StringBuilder();
+ if (instance != null) {
+ if (instance.getName() != null) {
+ sb.append(instance.getName());
+ }
+ if (instance.getId() != null) {
+ sb.append(" [").append(instance.getId()).append("] ");
+ }
+ }
+ return sb.toString();
+
}
@Override
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 08:59:41 UTC (rev 27080)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-12-02 09:19:15 UTC (rev 27081)
@@ -21,6 +21,7 @@
import org.jboss.tools.deltacloud.ui.ErrorUtils;
/**
+ * @author Jeff Johnston
* @author Andre Dietisheim
*/
public class CVInstancesCategoryElement extends CVCategoryElement implements IInstanceListListener {
14 years
JBoss Tools SVN: r27080 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-02 03:59:41 -0500 (Thu, 02 Dec 2010)
New Revision: 27080
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/CVInstancesCategoryElement.java
Log:
[JBIDE-7779] changed label for instances in CloudView
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-01 23:37:47 UTC (rev 27079)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java 2010-12-02 08:59:41 UTC (rev 27080)
@@ -11,13 +11,25 @@
package org.jboss.tools.deltacloud.ui.views;
import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
public class CVInstanceElement extends CloudViewElement {
- public CVInstanceElement(Object element, String name) {
- super(element, name);
+ public CVInstanceElement(Object element) {
+ super(element, getName((DeltaCloudInstance) element));
}
-
+
+ private static String getName(DeltaCloudInstance instance) {
+ return new StringBuilder(
+ instance.getName())
+ .append("[").append(instance.getId()).append("]")
+ .toString();
+ }
+
@Override
public IPropertySource getPropertySource() {
return new InstancePropertySource(this, getElement());
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-01 23:37:47 UTC (rev 27079)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-12-02 08:59:41 UTC (rev 27080)
@@ -20,6 +20,9 @@
import org.jboss.tools.deltacloud.core.IInstanceListListener;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
+/**
+ * @author Andre Dietisheim
+ */
public class CVInstancesCategoryElement extends CVCategoryElement implements IInstanceListListener {
public CVInstancesCategoryElement(Object element, String name, TreeViewer viewer) {
@@ -39,7 +42,7 @@
addChild(f);
for (int i = min; i < max; ++i) {
DeltaCloudInstance d = instances[i];
- CVInstanceElement element = new CVInstanceElement(d, d.getName());
+ CVInstanceElement element = new CVInstanceElement(d);
f.addChild(element);
}
min += CVNumericFoldingElement.FOLDING_SIZE;
@@ -52,14 +55,14 @@
addChild(f);
for (int i = min; i < min + length; ++i) {
DeltaCloudInstance d = instances[i];
- CVInstanceElement element = new CVInstanceElement(d, d.getName());
+ CVInstanceElement element = new CVInstanceElement(d);
f.addChild(element);
}
}
} else {
for (int i = 0; i < instances.length; ++i) {
DeltaCloudInstance d = instances[i];
- CVInstanceElement element = new CVInstanceElement(d, d.getName());
+ CVInstanceElement element = new CVInstanceElement(d);
addChild(element);
}
}
14 years
JBoss Tools SVN: r27079 - branches/jbosstools-3.2.0.Beta2/vpe/plugins/org.jboss.tools.vpe.base.test/META-INF.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2010-12-01 18:37:47 -0500 (Wed, 01 Dec 2010)
New Revision: 27079
Modified:
branches/jbosstools-3.2.0.Beta2/vpe/plugins/org.jboss.tools.vpe.base.test/META-INF/MANIFEST.MF
Log:
https://jira.jboss.org/browse/JBIDE-7778 relax range of valild org.eclipse.core.resources (and other 3.6) plugins on which this depends
Modified: branches/jbosstools-3.2.0.Beta2/vpe/plugins/org.jboss.tools.vpe.base.test/META-INF/MANIFEST.MF
===================================================================
--- branches/jbosstools-3.2.0.Beta2/vpe/plugins/org.jboss.tools.vpe.base.test/META-INF/MANIFEST.MF 2010-12-01 23:36:20 UTC (rev 27078)
+++ branches/jbosstools-3.2.0.Beta2/vpe/plugins/org.jboss.tools.vpe.base.test/META-INF/MANIFEST.MF 2010-12-01 23:37:47 UTC (rev 27079)
@@ -5,17 +5,17 @@
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: JBoss by RedHat
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Require-Bundle: org.eclipse.ui;bundle-version="3.6.0",
+Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)",
org.junit,
org.eclipse.core.runtime;bundle-version="3.6.0",
org.jboss.tools.common;bundle-version="3.2.0",
- org.eclipse.core.resources;bundle-version="3.6.0",
+ org.eclipse.core.resources;bundle-version="[3.6.0,4.0.0)",
org.jboss.tools.tests;bundle-version="3.1.0",
- org.eclipse.jface.text;bundle-version="3.6.0",
+ org.eclipse.jface.text;bundle-version="[3.6.0,4.0.0)",
org.eclipse.wst.sse.core;bundle-version="1.1.500",
org.eclipse.wst.sse.ui;bundle-version="1.2.0",
org.jboss.tools.vpe;bundle-version="3.2.0",
- org.eclipse.ui.ide;bundle-version="3.6.0",
+ org.eclipse.ui.ide;bundle-version="[3.6.0,4.0.0)",
org.jboss.tools.jst.jsp;bundle-version="3.2.0",
org.eclipse.wst.xml.xpath.core;bundle-version="1.1.1",
org.mozilla.xpcom;bundle-version="1.9.1",
14 years
JBoss Tools SVN: r27078 - trunk/vpe/plugins/org.jboss.tools.vpe.base.test/META-INF.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2010-12-01 18:36:20 -0500 (Wed, 01 Dec 2010)
New Revision: 27078
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.base.test/META-INF/MANIFEST.MF
Log:
https://jira.jboss.org/browse/JBIDE-7778 relax range of valild org.eclipse.core.resources (and other 3.6) plugins on which this depends
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.base.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.base.test/META-INF/MANIFEST.MF 2010-12-01 18:55:00 UTC (rev 27077)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.base.test/META-INF/MANIFEST.MF 2010-12-01 23:36:20 UTC (rev 27078)
@@ -5,17 +5,17 @@
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: JBoss by RedHat
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Require-Bundle: org.eclipse.ui;bundle-version="3.6.0",
+Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)",
org.junit,
org.eclipse.core.runtime;bundle-version="3.6.0",
org.jboss.tools.common;bundle-version="3.2.0",
- org.eclipse.core.resources;bundle-version="3.6.0",
+ org.eclipse.core.resources;bundle-version="[3.6.0,4.0.0)",
org.jboss.tools.tests;bundle-version="3.1.0",
- org.eclipse.jface.text;bundle-version="3.6.0",
+ org.eclipse.jface.text;bundle-version="[3.6.0,4.0.0)",
org.eclipse.wst.sse.core;bundle-version="1.1.500",
org.eclipse.wst.sse.ui;bundle-version="1.2.0",
org.jboss.tools.vpe;bundle-version="3.2.0",
- org.eclipse.ui.ide;bundle-version="3.6.0",
+ org.eclipse.ui.ide;bundle-version="[3.6.0,4.0.0)",
org.jboss.tools.jst.jsp;bundle-version="3.2.0",
org.eclipse.wst.xml.xpath.core;bundle-version="1.1.1",
org.mozilla.xpcom;bundle-version="1.9.1",
14 years