Author: jjohnstn
Date: 2010-10-25 18:24:34 -0400 (Mon, 25 Oct 2010)
New Revision: 26043
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVNumericFoldingElement.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/CVImagesCategoryElement.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/CloudViewLabelProvider.java
Log:
2010-10-25 Jeff Johnston <jjohnstn(a)redhat.com>
[JBIDE-7408]
* src/org/jboss/tools/deltacloud/ui/views/CVNumericFoldingElement.java: New file.
* src/org/jboss/tools/deltacloud/ui/views/CloudViewLabelProvider.java (getImage): Add
check for CVNumericFoldingElement.
* src/org/jboss/tools/deltacloud/ui/views/CVImagesCategoryElement.java (addImages): New
method which adds intermediate CVNumericFoldingElement folders if necessary.
(getChildren): Use addImages method to add children.
(listChanged): Ditto.
* src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java (addInstances):
New
method which adds intermediate CVNumericFoldingElement folders if necessary.
(getChildren): Use addInstances method to add children.
(listChanged): Ditto.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-10-25 20:41:13
UTC (rev 26042)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-10-25 22:24:34
UTC (rev 26043)
@@ -1,5 +1,20 @@
2010-10-25 Jeff Johnston <jjohnstn(a)redhat.com>
+ [JBIDE-7408]
+ * src/org/jboss/tools/deltacloud/ui/views/CVNumericFoldingElement.java: New file.
+ * src/org/jboss/tools/deltacloud/ui/views/CloudViewLabelProvider.java (getImage): Add
+ check for CVNumericFoldingElement.
+ * src/org/jboss/tools/deltacloud/ui/views/CVImagesCategoryElement.java (addImages): New
+ method which adds intermediate CVNumericFoldingElement folders if necessary.
+ (getChildren): Use addImages method to add children.
+ (listChanged): Ditto.
+ * src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
(addInstances): New
+ method which adds intermediate CVNumericFoldingElement folders if necessary.
+ (getChildren): Use addInstances method to add children.
+ (listChanged): Ditto.
+
+2010-10-25 Jeff Johnston <jjohnstn(a)redhat.com>
+
* src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java
(getPropertyValue): Use
DeltaCloud as source of cloud type constants.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java (validate):
Ditto.
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-10-25
20:41:13 UTC (rev 26042)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVImagesCategoryElement.java 2010-10-25
22:24:34 UTC (rev 26043)
@@ -39,17 +39,50 @@
super.finalize();
}
+ 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$
+ addChild(f);
+ for (int i = min; i < max; ++i) {
+ DeltaCloudImage d = images[i];
+ CVImageElement element = new CVImageElement(d, d.getName());
+ f.addChild(element);
+ }
+ min += CVNumericFoldingElement.FOLDING_SIZE;
+ max += CVNumericFoldingElement.FOLDING_SIZE;
+ length -= CVNumericFoldingElement.FOLDING_SIZE;
+ }
+ if (length > 0) {
+ 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());
+ f.addChild(element);
+ }
+ }
+ } else {
+ for (int i = 0; i < images.length; ++i) {
+ DeltaCloudImage d = images[i];
+ CVImageElement element = new CVImageElement(d, d.getName());
+ addChild(element);
+ }
+ }
+ }
+
@Override
public Object[] getChildren() {
if (!initialized) {
DeltaCloud cloud = (DeltaCloud)getElement();
cloud.removeImageListListener(this);
DeltaCloudImage[] images = filter(cloud.getCurrImages());
- for (int i = 0; i < images.length; ++i) {
- DeltaCloudImage d = images[i];
- CVImageElement element = new CVImageElement(d, d.getName());
- addChild(element);
- }
+ addImages(images);
initialized = true;
cloud.addImageListListener(this);
}
@@ -60,11 +93,7 @@
public void listChanged(DeltaCloud cloud, DeltaCloudImage[] newImages) {
clearChildren();
DeltaCloudImage[] images = filter(newImages);
- for (int i = 0; i < images.length; ++i) {
- DeltaCloudImage d = images[i];
- CVImageElement element = new CVImageElement(d, d.getName());
- addChild(element);
- }
+ addImages(images);
initialized = true;
Display.getDefault().asyncExec(new Runnable() {
@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-10-25
20:41:13 UTC (rev 26042)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-10-25
22:24:34 UTC (rev 26043)
@@ -39,17 +39,50 @@
super.finalize();
}
+ private void addInstances(DeltaCloudInstance[] instances) {
+ if (instances.length > CVNumericFoldingElement.FOLDING_SIZE) {
+ int min = 0;
+ int max = CVNumericFoldingElement.FOLDING_SIZE;
+ int length = instances.length;
+ while (length > CVNumericFoldingElement.FOLDING_SIZE) {
+ 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) {
+ DeltaCloudInstance d = instances[i];
+ CVInstanceElement element = new CVInstanceElement(d, d.getName());
+ f.addChild(element);
+ }
+ min += CVNumericFoldingElement.FOLDING_SIZE;
+ max += CVNumericFoldingElement.FOLDING_SIZE;
+ length -= CVNumericFoldingElement.FOLDING_SIZE;
+ }
+ if (length > 0) {
+ 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) {
+ DeltaCloudInstance d = instances[i];
+ CVInstanceElement element = new CVInstanceElement(d, d.getName());
+ f.addChild(element);
+ }
+ }
+ } else {
+ for (int i = 0; i < instances.length; ++i) {
+ DeltaCloudInstance d = instances[i];
+ CVInstanceElement element = new CVInstanceElement(d, d.getName());
+ addChild(element);
+ }
+ }
+ }
+
@Override
public Object[] getChildren() {
if (!initialized) {
DeltaCloud cloud = (DeltaCloud)getElement();
cloud.removeInstanceListListener(this);
DeltaCloudInstance[] instances = filter(cloud.getCurrInstances());
- for (int i = 0; i < instances.length; ++i) {
- DeltaCloudInstance d = instances[i];
- CVInstanceElement element = new CVInstanceElement(d, d.getName());
- addChild(element);
- }
+ addInstances(instances);
initialized = true;
cloud.addInstanceListListener(this);
}
@@ -60,11 +93,7 @@
public void listChanged(DeltaCloud cloud, DeltaCloudInstance[] newInstances) {
clearChildren();
DeltaCloudInstance[] instances = filter(newInstances);
- for (int i = 0; i < instances.length; ++i) {
- DeltaCloudInstance d = instances[i];
- CVInstanceElement element = new CVInstanceElement(d, d.getName());
- addChild(element);
- }
+ addInstances(instances);
initialized = true;
Display.getDefault().asyncExec(new Runnable() {
@Override
Added:
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
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVNumericFoldingElement.java 2010-10-25
22:24:34 UTC (rev 26043)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.ui.views.properties.IPropertySource;
+
+public class CVNumericFoldingElement extends CloudViewElement {
+
+ public static int FOLDING_SIZE = 50;
+
+ public CVNumericFoldingElement(Object element, String name) {
+ super(element, name);
+ }
+
+ @Override
+ public Object[] getChildren() {
+ return super.getChildren();
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return true;
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ return null;
+ }
+
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVNumericFoldingElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewLabelProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewLabelProvider.java 2010-10-25
20:41:13 UTC (rev 26042)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewLabelProvider.java 2010-10-25
22:24:34 UTC (rev 26043)
@@ -20,7 +20,8 @@
public Image getImage(Object element) {
if (element instanceof CVCloudElement) {
return SWTImagesFactory.get(SWTImagesFactory.IMG_CLOUD);
- } else if (element instanceof CVCategoryElement) {
+ } else if (element instanceof CVCategoryElement ||
+ element instanceof CVNumericFoldingElement) {
return SWTImagesFactory.get(SWTImagesFactory.IMG_FOLDER);
} else if (element instanceof CVInstanceElement) {
return SWTImagesFactory.get(SWTImagesFactory.IMG_INSTANCE);