You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2014/03/12 14:32:01 UTC

svn commit: r1576734 - in /myfaces/tobago/branches/tobago-3.0.x: ./ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/ tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/ tobago-example/tobago-e...

Author: lofwyr
Date: Wed Mar 12 13:32:00 2014
New Revision: 1576734

URL: http://svn.apache.org/r1576734
Log:
Merged from trunk
TOBAGO-1359: NPE when rendering sheet
 - working a little bit on nested sheets (not officially supported): no pretty output, but readable [from revision 1576730]

Added:
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/Element.java
      - copied unchanged from r1576730, myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/Element.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/x-sheet-nested.xhtml   (props changed)
      - copied unchanged from r1576730, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/x-sheet-nested.xhtml
Modified:
    myfaces/tobago/branches/tobago-3.0.x/   (props changed)
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java

Propchange: myfaces/tobago/branches/tobago-3.0.x/
------------------------------------------------------------------------------
  Merged /myfaces/tobago/trunk:r1576730

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java?rev=1576734&r1=1576733&r2=1576734&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java Wed Mar 12 13:32:00 2014
@@ -370,21 +370,29 @@ public abstract class AbstractUISheet ex
   }
 
   public List<AbstractUIColumn> getAllColumns() {
-    final List<AbstractUIColumn> columns = new ArrayList<AbstractUIColumn>();
-    for (final AbstractUIColumn kid : ComponentUtils.findDescendantList(this, AbstractUIColumn.class)) {
-      columns.add(kid);
-    }
-    return columns;
+    ArrayList<AbstractUIColumn> result = new ArrayList<AbstractUIColumn>();
+    findColumns(this, result, true);
+    return result;
   }
 
   public List<AbstractUIColumn> getRenderedColumns() {
-    final List<AbstractUIColumn> columns = new ArrayList<AbstractUIColumn>();
-    for (final AbstractUIColumn kid : ComponentUtils.findDescendantList(this, AbstractUIColumn.class)) {
-      if (kid.isRendered()) {
-        columns.add(kid);
+    ArrayList<AbstractUIColumn> result = new ArrayList<AbstractUIColumn>();
+    findColumns(this, result, false);
+    return result;
+  }
+
+  private void findColumns(final UIComponent component, final List<AbstractUIColumn> result, final boolean all) {
+    for (final UIComponent child : component.getChildren()) {
+      if (all || child.isRendered()) {
+        if (child instanceof AbstractUIColumn) {
+          result.add((AbstractUIColumn) child);
+        } else if (child instanceof AbstractUIData){
+          // ignore nested sheets
+        } else {
+          findColumns(child, result, all);
+        }
       }
     }
-    return columns;
   }
 
 /*  public MethodBinding getSortActionListener() {

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java?rev=1576734&r1=1576733&r2=1576734&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java Wed Mar 12 13:32:00 2014
@@ -21,6 +21,8 @@ package org.apache.myfaces.tobago.exampl
 
 import javax.swing.tree.DefaultMutableTreeNode;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -47,6 +49,8 @@ public class SolarObject {
 
   private String population;
 
+  private List<Element> chemicalComposition;
+
   public SolarObject(
       final String name, final String number, final String orbit, final Integer distance, final Double period,
       final Double incl, final Double eccen, final String discoverer, final Integer discoverYear) {
@@ -154,6 +158,14 @@ public class SolarObject {
     this.population = population;
   }
 
+  public List<Element> getChemicalComposition() {
+    return chemicalComposition != null ? chemicalComposition : Collections.<Element>emptyList();
+  }
+
+  public void setChemicalComposition(final List<Element> chemicalComposition) {
+    this.chemicalComposition = chemicalComposition;
+  }
+
   public boolean isSelectionDisabled() {
     return number.equals("II");
   }
@@ -165,9 +177,7 @@ public class SolarObject {
   public static List<SolarObject> getList() {
     final SolarObject[] array = getArray();
     final List<SolarObject> list = new ArrayList<SolarObject>(array.length);
-    for (final SolarObject object : array) {
-      list.add(object);
-    }
+    Collections.addAll(list, array);
     return list;
   }
 
@@ -198,18 +208,22 @@ public class SolarObject {
     return collect;
   }
 
+  public static final SolarObject SUN = new SolarObject("Sun", "-", "-", 0, 0.0, 0.0, 0.0, "-", null);
+  public static final SolarObject EARTH =new SolarObject("Earth", "III", "Sun", 149600, 365.26, 0.00, 0.02, "-", null);
+  public static final SolarObject MOON = new SolarObject("Moon", "I", "Earth", 384, 27.32, 5.14, 0.05, "-", null);
+
   public static final SolarObject[] DATA = {
-      new SolarObject("Sun", "-", "-", 0, 0.0, 0.0, 0.0, "-", null),
+      SUN,
       new SolarObject("Mercury", "I", "Sun", 57910, 87.97, 7.00, 0.21, "-", null),
       new SolarObject("Venus", "II", "Sun", 108200, 224.70, 3.39, 0.01, "-", null),
-      new SolarObject("Earth", "III", "Sun", 149600, 365.26, 0.00, 0.02, "-", null),
+      EARTH,
       new SolarObject("Mars", "IV", "Sun", 227940, 686.98, 1.85, 0.09, "-", null),
       new SolarObject("Jupiter", "V", "Sun", 778330, 4332.71, 1.31, 0.05, "-", null),
       new SolarObject("Saturn", "VI", "Sun", 1429400, 10759.50, 2.49, 0.06, "-", null),
       new SolarObject("Uranus", "VII", "Sun", 2870990, 30685.0, 0.77, 0.05, "Herschel", 1781),
       new SolarObject("Neptune", "VIII", "Sun", 4504300, 60190.0, 1.77, 0.01, "Adams", 1846),
       new SolarObject("Pluto", "IX", "Sun", 5913520, 90800.0, 17.15, 0.25, "Tombaugh", 1930),
-      new SolarObject("Moon", "I", "Earth", 384, 27.32, 5.14, 0.05, "-", null),
+      MOON,
       new SolarObject("Phobos", "I", "Mars", 9, 0.32, 1.00, 0.02, "Hall", 1877),
       new SolarObject("Deimos", "II", "Mars", 23, 1.26, 1.80, 0.00, "Hall", 1877),
       new SolarObject("Metis", "XVI", "Jupiter", 128, 0.29, 0.00, 0.00, "Synnott", 1979),
@@ -289,4 +303,25 @@ public class SolarObject {
       new SolarObject("Charon", "I", "Pluto", 20, 6.39, 98.80, 0.00, "Christy", 1978)
   };
 
+  static {
+    List<Element> sun = Arrays.asList(
+        new Element("Hydrogen", 0.74),
+        new Element("Helium", 0.25)
+    );
+    SUN.setChemicalComposition(sun);
+    List<Element> earth = Arrays.asList(
+        new Element("Silica", 0.60),
+        new Element("Alimina", 0.15),
+        new Element("Lime", 0.05)
+    );
+    EARTH.setChemicalComposition(earth);
+    List<Element> moon = Arrays.asList(
+        new Element("Silica", 0.45),
+        new Element("Alimina", 0.24),
+        new Element("Lime", 0.16)
+    );
+    MOON.setChemicalComposition(moon);
+  }
+
+
 }

Propchange: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/x-sheet-nested.xhtml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/x-sheet-nested.xhtml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/x-sheet-nested.xhtml
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Mar 12 13:32:00 2014
@@ -0,0 +1 @@
+/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/x-sheet-nested.xhtml:1576730

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java?rev=1576734&r1=1576733&r2=1576734&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java Wed Mar 12 13:32:00 2014
@@ -112,7 +112,7 @@ public class SheetRenderer extends Layou
     if (header == null) {
       header = CreateComponentUtils.createComponent(facesContext, ComponentTypes.PANEL, null, "_header");
       header.setTransient(true);
-      final List<AbstractUIColumn> columns = ComponentUtils.findDescendantList(sheet, AbstractUIColumn.class);
+      final List<AbstractUIColumn> columns = sheet.getAllColumns();
       int i = 0;
       for (final AbstractUIColumn column : columns) {
         final AbstractUIOut out = (AbstractUIOut) CreateComponentUtils.createComponent(
@@ -739,7 +739,7 @@ public class SheetRenderer extends Layou
     writer.endElement(HtmlElements.IMG);
   }
 
-  // TODO sheet.getColumnLayout() liefert ggf. eine falsche Anzahl von Spalten
+  // TODO sheet.getColumnLayout() may return the wrong number of column...
   // TODO
   // TODO
 
@@ -751,6 +751,12 @@ public class SheetRenderer extends Layou
       throws IOException {
 
     final Grid grid = sheet.getHeaderGrid();
+    if (grid == null) {
+      LOG.warn("Can't render column headers, because grid == null. One reason can be, the you use nested sheets. " +
+          "The inner sheet ensureHeader() will be called outside the iterating over the rows. " +
+          "Nesting sheet is currently not supported.");
+      return;
+    }
     final List<Integer> columnWidths = sheet.getWidthList();
 
     if (LOG.isDebugEnabled()) {