Author: adietish
Date: 2010-12-02 09:21:09 -0500 (Thu, 02 Dec 2010)
New Revision: 27097
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/CloudViewElement.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/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
14:20:04 UTC (rev 27096)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCategoryElement.java 2010-12-02
14:21:09 UTC (rev 27097)
@@ -52,6 +52,35 @@
return true;
}
+ protected void addChildren(Object[] modelElements) {
+ if (modelElements.length > CVNumericFoldingElement.FOLDING_SIZE) {
+ addFoldedChildren(modelElements);
+ } else {
+ addChildren(getElements(modelElements, 0, modelElements.length));
+ }
+ }
+
+ protected void addFoldedChildren(Object[] modelElements) {
+ int min = 0;
+ int max = CVNumericFoldingElement.FOLDING_SIZE;
+ int length = modelElements.length;
+ while (length > CVNumericFoldingElement.FOLDING_SIZE) {
+ CVNumericFoldingElement f = new CVNumericFoldingElement(min, max);
+ addChild(f);
+ f.addChildren(getElements(modelElements, min, max));
+ min += CVNumericFoldingElement.FOLDING_SIZE;
+ max += CVNumericFoldingElement.FOLDING_SIZE;
+ length -= CVNumericFoldingElement.FOLDING_SIZE;
+ }
+ if (length > 0) {
+ CVNumericFoldingElement f = new CVNumericFoldingElement(min, max);
+ addChild(f);
+ f.addChildren(getElements(modelElements, min, min + length));
+ }
+ }
+
+ protected abstract CloudViewElement[] getElements(Object[] modelElements, int
startIndex, int stopIndex);
+
@Override
public IPropertySource getPropertySource() {
// no property source for cathegories
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
14:20:04 UTC (rev 27096)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewElement.java 2010-12-02
14:21:09 UTC (rev 27097)
@@ -11,6 +11,7 @@
package org.jboss.tools.deltacloud.ui.views;
import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.views.properties.IPropertySource;
@@ -23,7 +24,7 @@
private Object element;
private CloudViewElement parent;
- private ArrayList<CloudViewElement> children;
+ private List<CloudViewElement> children;
public abstract IPropertySource getPropertySource();
@@ -48,6 +49,12 @@
e.setParent(this);
}
+ public void addChildren(CloudViewElement[] elements) {
+ for(CloudViewElement element : elements) {
+ addChild(element);
+ }
+ }
+
public void setParent(CloudViewElement e) {
parent = e;
}
Show replies by date