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 2015/06/25 11:49:02 UTC
svn commit: r1687462 - in /myfaces/tobago/branches/tobago-3.0.x:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/
tobago-core/src/main/java/org/apache/myfaces/t...
Author: lofwyr
Date: Thu Jun 25 09:49:01 2015
New Revision: 1687462
URL: http://svn.apache.org/r1687462
Log:
TOBAGO-1434: Move Layout-Manager-Logic from Server to Client
- simplify/cleanup grid definition on server side
Modified:
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFlexLayout.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPage.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPanel.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java
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-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Cell.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Grid.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/LayoutUtils.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/OriginCell.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/SpanCell.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasMargins.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContainer.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/layout/GridUnitTest.java
myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISplitLayout.java
myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SplitLayoutRenderer.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/GridLayoutRenderer.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
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFlexLayout.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/AbstractUIFlexLayout.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFlexLayout.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFlexLayout.java Thu Jun 25 09:49:01 2015
@@ -26,7 +26,8 @@ import org.apache.myfaces.tobago.layout.
* TODO
* @since 3.0.0
*/
-public abstract class AbstractUIFlexLayout extends AbstractUILayoutBase implements LayoutManager, SupportsMarkup {
+public abstract class AbstractUIFlexLayout
+ extends AbstractUILayoutBase implements LayoutManager, SupportsMarkup {
public static final String COMPONENT_FAMILY = "org.apache.myfaces.tobago.FlexLayout";
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.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/AbstractUIGridLayout.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIGridLayout.java Thu Jun 25 09:49:01 2015
@@ -19,9 +19,10 @@
package org.apache.myfaces.tobago.internal.component;
+import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.SupportsMarkup;
-import org.apache.myfaces.tobago.internal.layout.BankHead;
import org.apache.myfaces.tobago.internal.layout.Grid;
+import org.apache.myfaces.tobago.internal.layout.LayoutUtils;
import org.apache.myfaces.tobago.internal.layout.OriginCell;
import org.apache.myfaces.tobago.internal.util.StringUtils;
import org.apache.myfaces.tobago.layout.LayoutComponent;
@@ -29,11 +30,11 @@ import org.apache.myfaces.tobago.layout.
import org.apache.myfaces.tobago.layout.LayoutManager;
import org.apache.myfaces.tobago.layout.LayoutTokens;
import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.Orientation;
import org.apache.myfaces.tobago.util.ComponentUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import java.util.List;
@@ -56,393 +57,25 @@ public abstract class AbstractUIGridLayo
grid = new Grid(LayoutTokens.parse(getColumns()), LayoutTokens.parse(getRows()));
- final List<LayoutComponent> components = getLayoutContainer().getComponents();
- for (final LayoutComponent component : components) {
- component.setCurrentHeight(null);
- component.setCurrentWidth(null);
- grid.add(new OriginCell(component), component.getColumnSpan(), component.getRowSpan());
+ final List<UIComponent> components = LayoutUtils.findLayoutChildren(getLayoutContainer());
+ for (final UIComponent component : components) {
+ if (component instanceof LayoutComponent) {
+ ((LayoutComponent)component).setCurrentHeight(null);
+ ((LayoutComponent)component).setCurrentWidth(null);
+ }
+ final int columnSpan = ComponentUtils.getIntAttribute(component, Attributes.COLUMN_SPAN, 1);
+ final int rowSpan = ComponentUtils.getIntAttribute(component, Attributes.ROW_SPAN, 1);
+ grid.add(new OriginCell(component), columnSpan, rowSpan);
if (LOG.isDebugEnabled()) {
LOG.debug("\n" + grid);
}
-/*
- if (component instanceof LayoutContainer && (component.isRendered() || isRigid())) {
- ((LayoutContainer) component).getLayoutManager().init();
- }
-*/
- }
-
- grid.setColumnOverflow(isColumnOverflow());
- grid.setRowOverflow(isRowOverflow());
- }
-
-/*
- public void fixRelativeInsideAuto(final Orientation orientation, final boolean auto) {
-
- if (!getLayoutContainer().isLayoutChildren()) {
- return;
- }
-
- final BankHead[] heads = grid.getBankHeads(orientation);
- final BankHead[] heads2 = grid.getBankHeads(orientation.other());
-
- if (auto) {
- for (int i = 0; i < heads.length; i++) {
- if (heads[i].getToken() instanceof RelativeLayoutToken) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Fixing layout token from * to auto, because a * in not allowed inside of a auto. "
- + "Token * at index=" + i + ", orientation=" + orientation + ", grid=\n" + grid);
- }
- heads[i].setToken(AutoLayoutToken.INSTANCE);
- }
- }
- }
-
- for (int i = 0; i < heads.length; i++) {
- boolean neitherRendered = true;
- for (int j = 0; j < heads2.length; j++) {
- final Cell cell = grid.getCell(i, j, orientation);
- // check rendered = false
- if (cell != null && cell.getComponent().isRendered()) {
- neitherRendered = false;
- }
- // recursion
- if (cell instanceof OriginCell) {
- final OriginCell origin = (OriginCell) cell;
- final LayoutComponent component = cell.getComponent();
- if (component instanceof LayoutContainer && component.isRendered()) {
- final LayoutManager layoutManager = ((LayoutContainer) component).getLayoutManager();
- // TODO: may be improved
- final boolean childAuto
- = origin.getSpan(orientation) == 1 && heads[i].getToken() instanceof AutoLayoutToken;
- layoutManager.fixRelativeInsideAuto(orientation, childAuto);
- }
- }
- }
- if (neitherRendered && !isRigid()) {
- heads[i].setRendered(false);
- }
- }
- }
-*/
-
-/*
- public void preProcessing(final Orientation orientation) {
-
- if (!getLayoutContainer().isLayoutChildren()) {
- return;
- }
-
- final BankHead[] heads = grid.getBankHeads(orientation);
- final BankHead[] heads2 = grid.getBankHeads(orientation.other());
-
- // process auto tokens
- int i = 0;
-
- for (final BankHead head : heads) {
- final LayoutToken token = head.getToken();
-
- if (token instanceof PixelLayoutToken) {
- if (head.isRendered() || isRigid()) {
- heads[i].setCurrent(((PixelLayoutToken) token).getMeasure());
- } else {
- heads[i].setCurrent(Measure.ZERO);
- }
- }
-
- final IntervalList intervalList = new IntervalList();
- for (int j = 0; j < heads2.length; j++) {
- final Cell cell = grid.getCell(i, j, orientation);
- if (cell instanceof OriginCell) {
- final OriginCell origin = (OriginCell) cell;
- final LayoutComponent component = cell.getComponent();
-
- if (component instanceof LayoutContainer && (component.isRendered() || isRigid())) {
- ((LayoutContainer) component).getLayoutManager().preProcessing(orientation);
- }
-
- if (token instanceof AutoLayoutToken || token instanceof RelativeLayoutToken) {
- if ((component.isRendered() || isRigid())) {
- if (origin.getSpan(orientation) == 1) {
- intervalList.add(new Interval(component, orientation));
- } else {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Components with span > 1 will be ignored in 'auto' layout rows/columns.");
- }
- }
- }
- }
- }
- }
-
- intervalList.evaluate();
- if (token instanceof AutoLayoutToken || token instanceof RelativeLayoutToken) {
- heads[i].setIntervalList(intervalList);
- }
- if (token instanceof AutoLayoutToken) {
- if (heads[i].isRendered()) {
- if (intervalList.size() > 0) {
- heads[i].setCurrent(intervalList.getCurrent());
- } else {
- heads[i].setCurrent(Measure.valueOf(100));
- LOG.warn("Found an 'auto' token in {} definition, but there is no component inside with span = 1! "
- + "So the value for 'auto' can't be evaluated (clientId={}). Using 100px.",
- orientation == Orientation.HORIZONTAL ? "columns" : "rows",
- getClientId(getFacesContext()));
- }
- } else {
- heads[i].setCurrent(Measure.ZERO);
- }
- }
- i++;
- }
-
-*/
-/*
- IntervalList relatives = new IntervalList();
- for (BankHead head : heads) {
- LayoutToken token = head.getToken();
- if (token instanceof RelativeLayoutToken) {
- final int factor = ((RelativeLayoutToken) token).getFactor();
- for (Interval interval : head.getIntervalList()) {
- relatives.add(new Interval(interval, factor));
- }
- }
- }
- relatives.evaluate();
-*//*
-
-
- // set the size if all sizes of the grid are set
- Measure sum = Measure.ZERO;
- for (final BankHead head : heads) {
- Measure size = null;
- final LayoutToken token = head.getToken();
- if (token instanceof RelativeLayoutToken) {
-// final int factor = ((RelativeLayoutToken) token).getFactor();
-// size = relatives.getCurrent().multiply(factor);
- } else {
- size = head.getCurrent();
- }
- if (size == null) {
- sum = null; // set to invalid
- break;
-// LOG.error("TODO: Should not happen!");
- }
- sum = sum.add(size);
- }
- if (sum != null) {
- // adding the space between the cells
- sum = sum.add(LayoutUtils.getBorderBegin(orientation, getLayoutContainer()));
- sum = sum.add(LayoutUtils.getPaddingBegin(orientation, getLayoutContainer()));
- sum = sum.add(getMarginBegin(orientation));
- sum = sum.add(computeSpacing(orientation, 0, heads.length));
- sum = sum.add(getMarginEnd(orientation));
- sum = sum.add(LayoutUtils.getPaddingEnd(orientation, getLayoutContainer()));
- sum = sum.add(LayoutUtils.getBorderEnd(orientation, getLayoutContainer()));
- LayoutUtils.setCurrentSize(orientation, getLayoutContainer(), sum);
}
}
-*/
-
-/*
- public void mainProcessing(final Orientation orientation) {
-
- if (!getLayoutContainer().isLayoutChildren()) {
- return;
- }
-
- final BankHead[] heads = grid.getBankHeads(orientation);
- final BankHead[] heads2 = grid.getBankHeads(orientation.other());
-
- // find *
- final FactorList factorList = new FactorList();
- for (final BankHead head : heads) {
- if (head.getToken() instanceof RelativeLayoutToken && head.isRendered()) {
- factorList.add(((RelativeLayoutToken) head.getToken()).getFactor());
- }
- }
- if (!factorList.isEmpty()) {
- // find rest
- final LayoutContainer container = getLayoutContainer();
- Measure available = LayoutUtils.getCurrentSize(orientation, container);
- if (available != null) {
- for (final BankHead head : heads) {
- available = available.subtractNotNegative(head.getCurrent());
- }
- available = available.subtractNotNegative(LayoutUtils.getBorderBegin(orientation, container));
- available = available.subtractNotNegative(LayoutUtils.getPaddingBegin(orientation, container));
- available = available.subtractNotNegative(getMarginBegin(orientation));
- available = available.subtractNotNegative(computeSpacing(orientation, 0, heads.length));
- available = available.subtractNotNegative(getMarginEnd(orientation));
- available = available.subtractNotNegative(LayoutUtils.getPaddingEnd(orientation, container));
- available = available.subtractNotNegative(LayoutUtils.getBorderEnd(orientation, container));
-
- if (grid.isOverflow(orientation.other())) {
- final ClientProperties client = ClientProperties.getInstance(FacesContext.getCurrentInstance());
- final Measure scrollbar = orientation
- == Orientation.HORIZONTAL ? client.getVerticalScrollbarWeight() : client.getHorizontalScrollbarWeight();
- available = available.subtractNotNegative(scrollbar);
- }
-
- final List<Measure> partition = factorList.partition(available);
-
- // write values back into the header
- int i = 0; // index of head
- int j = 0; // index of partition
- for (final BankHead head : heads) {
- if (head.getToken() instanceof RelativeLayoutToken && head.isRendered()) {
- // respect the minimum
- heads[i].setCurrent(Measure.max(partition.get(j), heads[i].getIntervalList().getMinimum()));
- j++;
- }
- i++;
- }
- } else {
- LOG.warn("No width/height set but needed for *!"); // todo: more information
- }
- }
-
- // call manage sizes for all sub-layout-managers
- for (int i = 0; i < heads.length; i++) {
- for (int j = 0; j < heads2.length; j++) {
- final Cell cell = grid.getCell(i, j, orientation);
- if (cell instanceof OriginCell) {
- final LayoutComponent component = cell.getComponent();
-
- final Integer span = ((OriginCell) cell).getSpan(orientation);
-
- // compute the size of the cell
- Measure size = Measure.ZERO;
- for (int k = 0; k < span; k++) {
- size = size.add(heads[i + k].getCurrent());
- }
- size = size.add(computeSpacing(orientation, i, span));
- final Measure current = LayoutUtils.getCurrentSize(orientation, component);
- if (current == null) {
- LayoutUtils.setCurrentSize(orientation, component, size);
- }
-
- // call sub layout manager
- if (component instanceof LayoutContainer && (component.isRendered() || isRigid())) {
- ((LayoutContainer) component).getLayoutManager().mainProcessing(orientation);
- }
- }
- }
- }
-
- Measure size = Measure.ZERO;
- size = size.add(LayoutUtils.getPaddingBegin(orientation, getLayoutContainer()));
- size = size.add(getMarginBegin(orientation));
- size = size.add(computeSpacing(orientation, 0, heads.length));
- for (final BankHead head : heads) {
- size = size.add(head.getCurrent());
- }
- size = size.add(getMarginEnd(orientation));
- size = size.add(LayoutUtils.getPaddingEnd(orientation, getLayoutContainer()));
- if (size.greaterThan(LayoutUtils.getCurrentSize(orientation, getLayoutContainer()))) {
- grid.setOverflow(true, orientation);
- }
- }
-*/
-
-/*
- public void postProcessing(final Orientation orientation) {
-
- if (!getLayoutContainer().isLayoutChildren()) {
- return;
- }
-
- final BankHead[] heads = grid.getBankHeads(orientation);
- final BankHead[] heads2 = grid.getBankHeads(orientation.other());
-
- // call manage sizes for all sub-layout-managers
- for (int i = 0; i < heads.length; i++) {
- for (int j = 0; j < heads2.length; j++) {
- final Cell cell = grid.getCell(i, j, orientation);
- if (cell instanceof OriginCell) {
- final LayoutComponent component = cell.getComponent();
-
- // compute the position of the cell
- Measure position = Measure.ZERO;
- position = position.add(LayoutUtils.getPaddingBegin(orientation, getLayoutContainer()));
- position = position.add(getMarginBegin(orientation));
- for (int k = 0; k < i; k++) {
- if (heads[k] != null
- && heads[k].getCurrent() != null
- && heads[k].isRendered()
- && heads[k].getCurrent().greaterThan(Measure.ZERO)) {
- position = position.add(heads[k].getCurrent());
- position = position.add(getSpacing(orientation));
- }
- }
- if (orientation == Orientation.HORIZONTAL) {
- component.setLeft(position);
- } else {
- component.setTop(position);
- }
-
- // call sub layout manager
- if (component instanceof LayoutContainer && (component.isRendered() || isRigid())) {
- ((LayoutContainer) component).getLayoutManager().postProcessing(orientation);
- }
-
- // set scrolling type
- final boolean scroll = grid.isOverflow(orientation);
- if (orientation == Orientation.HORIZONTAL) {
- getLayoutContainer().setOverflowX(scroll);
- } else {
- getLayoutContainer().setOverflowY(scroll);
- }
-
- // todo: optimize: the AutoLayoutTokens with columnSpan=1 are already called
- }
- }
- }
- }
-*/
public LayoutContainer getLayoutContainer() {
return ComponentUtils.findAncestor(getParent(), LayoutContainer.class);
}
- public Measure getSpacing(final Orientation orientation) {
- return orientation == Orientation.HORIZONTAL ? getColumnSpacing() : getRowSpacing();
- }
-
-/*
- public Measure getMarginBegin(final Orientation orientation) {
- return orientation == Orientation.HORIZONTAL ? getMarginLeft() : getMarginTop();
- }
-
- public Measure getMarginEnd(final Orientation orientation) {
- return orientation == Orientation.HORIZONTAL ? getMarginRight() : getMarginBottom();
- }
-*/
-
- /**
- * Compute the sum of the space between the cells.
- * There is one "space" less than cells that are not void.
- */
-/*
- private Measure computeSpacing(final Orientation orientation, final int startIndex, final int length) {
-
- final BankHead[] heads = grid.getBankHeads(orientation);
-
- int count = 0;
- for (int i = startIndex; i < startIndex + length; i++) {
- if ((heads[i].isRendered())
- && (heads[i].getCurrent() == null || heads[i].getCurrent().greaterThan(Measure.ZERO))) {
- count++;
- }
- }
- if (count > 0) {
- return getSpacing(orientation).multiply(count - 1);
- } else {
- return Measure.ZERO;
- }
- }
-*/
-
public abstract String getRows();
public abstract void setRows(String rows);
@@ -466,10 +99,6 @@ public abstract class AbstractUIGridLayo
public abstract Measure getMarginBottom();
- public abstract boolean isColumnOverflow();
-
- public abstract boolean isRowOverflow();
-
public abstract boolean isRigid();
public Grid getGrid() {
@@ -492,27 +121,26 @@ public abstract class AbstractUIGridLayo
if (grid != null) {
builder.append(StringUtils.repeat(" ", 4));
builder.append("horiz.: ");
- BankHead[] heads = grid.getBankHeads(Orientation.HORIZONTAL);
- for (int i = 0; i < heads.length; i++) {
+ final LayoutTokens rows = grid.getRows();
+ for (int i = 0; i < rows.getSize(); i++) {
if (i != 0) {
builder.append(StringUtils.repeat(" ", 4 + 4));
}
- builder.append(heads[i]);
+ builder.append(rows.get(i));
builder.append("\n");
}
builder.append(StringUtils.repeat(" ", 4));
builder.append("verti.: ");
- heads = grid.getBankHeads(Orientation.VERTICAL);
- for (int i = 0; i < heads.length; i++) {
+ final LayoutTokens columns = grid.getColumns();
+ for (int i = 0; i < columns.getSize(); i++) {
if (i != 0) {
builder.append(StringUtils.repeat(" ", 4 + 4));
}
- builder.append(heads[i]);
+ builder.append(columns.get(i));
builder.append("\n");
}
}
builder.setLength(builder.length() - 1);
return builder.toString();
}
-
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPage.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/AbstractUIPage.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPage.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPage.java Thu Jun 25 09:49:01 2015
@@ -25,11 +25,9 @@ import org.apache.myfaces.tobago.compone
import org.apache.myfaces.tobago.component.OnComponentPopulated;
import org.apache.myfaces.tobago.internal.ajax.AjaxInternalUtils;
import org.apache.myfaces.tobago.internal.ajax.AjaxResponseRenderer;
-import org.apache.myfaces.tobago.internal.layout.LayoutUtils;
import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
import org.apache.myfaces.tobago.internal.webapp.TobagoMultipartFormdataRequest;
import org.apache.myfaces.tobago.layout.Box;
-import org.apache.myfaces.tobago.layout.LayoutComponent;
import org.apache.myfaces.tobago.layout.LayoutContainer;
import org.apache.myfaces.tobago.layout.LayoutManager;
import org.apache.myfaces.tobago.layout.Measure;
@@ -52,7 +50,6 @@ import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.IOException;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
public abstract class AbstractUIPage extends AbstractUIForm
@@ -334,10 +331,6 @@ public abstract class AbstractUIPage ext
*/
}
- public List<LayoutComponent> getComponents() {
- return LayoutUtils.findLayoutChildren(this);
- }
-
public LayoutManager getLayoutManager() {
final UIComponent facet = getFacet(Facets.LAYOUT);
if (facet == null) {
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPanel.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/AbstractUIPanel.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPanel.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPanel.java Thu Jun 25 09:49:01 2015
@@ -21,7 +21,6 @@ package org.apache.myfaces.tobago.intern
import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.component.OnComponentPopulated;
-import org.apache.myfaces.tobago.internal.layout.LayoutUtils;
import org.apache.myfaces.tobago.layout.LayoutComponent;
import org.apache.myfaces.tobago.layout.LayoutContainer;
import org.apache.myfaces.tobago.layout.LayoutManager;
@@ -30,7 +29,6 @@ import org.apache.myfaces.tobago.util.Co
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import java.io.IOException;
-import java.util.List;
public abstract class AbstractUIPanel extends javax.faces.component.UIPanel
implements OnComponentPopulated, LayoutContainer, LayoutComponent {
@@ -71,10 +69,6 @@ public abstract class AbstractUIPanel ex
public void onComponentPopulated(final FacesContext facesContext, final UIComponent parent) {
}
- public List<LayoutComponent> getComponents() {
- return LayoutUtils.findLayoutChildren(this);
- }
-
public LayoutManager getLayoutManager() {
final UIComponent base;
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.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/AbstractUIPopup.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java Thu Jun 25 09:49:01 2015
@@ -25,9 +25,7 @@ import org.apache.myfaces.tobago.compone
import org.apache.myfaces.tobago.component.OnComponentCreated;
import org.apache.myfaces.tobago.component.OnComponentPopulated;
import org.apache.myfaces.tobago.component.Position;
-import org.apache.myfaces.tobago.internal.layout.LayoutUtils;
import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
-import org.apache.myfaces.tobago.layout.LayoutComponent;
import org.apache.myfaces.tobago.layout.LayoutContainer;
import org.apache.myfaces.tobago.layout.LayoutManager;
import org.apache.myfaces.tobago.layout.Measure;
@@ -42,7 +40,6 @@ import javax.faces.component.UINamingCon
import javax.faces.context.FacesContext;
import java.io.IOException;
import java.util.Iterator;
-import java.util.List;
public abstract class AbstractUIPopup extends AbstractUIPanel
implements OnComponentCreated, OnComponentPopulated, NamingContainer,
@@ -75,10 +72,6 @@ public abstract class AbstractUIPopup ex
*/
}
- public List<LayoutComponent> getComponents() {
- return LayoutUtils.findLayoutChildren(this);
- }
-
public void setActivated(final boolean activated) {
this.activated = activated;
}
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=1687462&r1=1687461&r2=1687462&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 Thu Jun 25 09:49:01 2015
@@ -453,7 +453,7 @@ public abstract class AbstractUISheet ex
if (child instanceof LayoutComponent) {
if (child.isRendered()) {
final LayoutComponent c = (LayoutComponent) child;
- grid.add(new OriginCell(c), c.getColumnSpan(), c.getRowSpan());
+ grid.add(new OriginCell(child), c.getColumnSpan(), c.getRowSpan());
}
} else {
if (LOG.isDebugEnabled()) {
@@ -600,11 +600,6 @@ public abstract class AbstractUISheet ex
getState().setFirst(first);
}
- @Override
- public List<LayoutComponent> getComponents() {
- throw new IllegalStateException();
- }
-
public void onComponentPopulated(final FacesContext facesContext, final UIComponent parent) {
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.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/AbstractUITabGroup.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java Thu Jun 25 09:49:01 2015
@@ -314,10 +314,6 @@ public abstract class AbstractUITabGroup
removeFacesListener(listener);
}
- public List<LayoutComponent> getComponents() {
- throw new IllegalStateException();
- }
-
public void onComponentPopulated(final FacesContext facesContext, final UIComponent parent) {
super.onComponentPopulated(facesContext, parent);
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Cell.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Cell.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Cell.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Cell.java Thu Jun 25 09:49:01 2015
@@ -19,15 +19,15 @@
package org.apache.myfaces.tobago.internal.layout;
-import org.apache.myfaces.tobago.layout.LayoutComponent;
+import javax.faces.component.UIComponent;
/**
- * To support horizontal and vertical spans, at each position will be a cell as a represantive.
+ * To support horizontal and vertical spans, at each position will be a cell as a representative.
* Either a "origin cell" for the first position or a "span cell" for spanned other positions.
*/
public interface Cell {
- LayoutComponent getComponent();
+ UIComponent getComponent();
OriginCell getOrigin();
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Grid.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Grid.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Grid.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/Grid.java Thu Jun 25 09:49:01 2015
@@ -19,14 +19,13 @@
package org.apache.myfaces.tobago.internal.layout;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.myfaces.tobago.layout.LayoutTokens;
import org.apache.myfaces.tobago.layout.Orientation;
import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
public class Grid {
@@ -39,8 +38,8 @@ public class Grid {
*/
private List<Cell> cells;
- private BankHead[] columnHeads;
- private BankHead[] rowHeads;
+ private LayoutTokens columns;
+ private LayoutTokens rows;
private int columnCount;
private int rowCount;
@@ -48,26 +47,18 @@ public class Grid {
private int columnCursor;
private int rowCursor;
- private boolean columnOverflow;
- private boolean rowOverflow;
-
private List<Integer> errorIndexes;
public Grid(final LayoutTokens columns, final LayoutTokens rows) {
assert columns.getSize() > 0;
assert rows.getSize() > 0;
- this.columnCount = columns.getSize();
- this.rowCount = rows.getSize();
-
- this.columnHeads = new BankHead[columnCount];
- for (int i = 0; i < columnCount; i++) {
- columnHeads[i] = new BankHead(columns.get(i));
- }
- this.rowHeads = new BankHead[rowCount];
- for (int i = 0; i < rowCount; i++) {
- rowHeads[i] = new BankHead(rows.get(i));
- }
+ this.columnCount = columns.getSize();
+ this.rowCount = rows.getSize();
+
+ this.columns = columns;
+ this.rows = rows;
+
final int size = columnCount * rowCount;
this.cells = new ArrayList<Cell>(size);
for (int i = 0; i < size; i++) {
@@ -153,10 +144,14 @@ public class Grid {
}
}
- public BankHead[] getBankHeads(final Orientation orientation) {
- return orientation == Orientation.HORIZONTAL ? columnHeads : rowHeads;
+ public LayoutTokens getColumns() {
+ return columns;
+ }
+
+ public LayoutTokens getRows() {
+ return rows;
}
-
+
private void enlarge(final int newRows) {
// process cells
@@ -167,46 +162,13 @@ public class Grid {
}
// process heads
- final BankHead[] newRowHeads = new BankHead[rowCount + newRows];
- System.arraycopy(rowHeads, 0, newRowHeads, 0, rowHeads.length);
- rowHeads = newRowHeads;
- // todo: shorter in jdk 1.6: rowHeads = Arrays.copyOf(rowHeads, rowHeads.length + newRows);
-
for (int i = rowCount; i < rowCount + newRows; i++) {
- rowHeads[i] = new BankHead(RelativeLayoutToken.DEFAULT_INSTANCE);
+ rows.addToken(RelativeLayoutToken.DEFAULT_INSTANCE);
}
rowCount += newRows;
}
- public boolean isOverflow(final Orientation orientation) {
- return orientation == Orientation.HORIZONTAL ? columnOverflow : rowOverflow;
- }
-
- public void setOverflow(final boolean overflow, final Orientation orientation) {
- if (orientation == Orientation.HORIZONTAL) {
- this.columnOverflow = overflow;
- } else {
- this.rowOverflow = overflow;
- }
- }
-
- public boolean isOverflow() {
- return columnOverflow;
- }
-
- public void setColumnOverflow(final boolean columnOverflow) {
- this.columnOverflow = columnOverflow;
- }
-
- public boolean isRowOverflow() {
- return rowOverflow;
- }
-
- public void setRowOverflow(final boolean rowOverflow) {
- this.rowOverflow = rowOverflow;
- }
-
public void addError(final int i, final int j) {
if (errorIndexes == null) {
errorIndexes = new ArrayList<Integer>();
@@ -475,15 +437,7 @@ public class Grid {
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append(gridAsString());
- builder.append("columnHeads=");
- builder.append(Arrays.toString(columnHeads));
- builder.append("\n");
- builder.append("rowHeads=");
- builder.append(Arrays.toString(rowHeads));
- builder.append("\n");
- return builder.toString();
+ return gridAsString() + "columns=" + columns + '\n' + "rows=" + rows + "\n";
}
private boolean connected(final Cell a, final Cell b) {
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/LayoutUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/LayoutUtils.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/LayoutUtils.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/LayoutUtils.java Thu Jun 25 09:49:01 2015
@@ -19,6 +19,8 @@
package org.apache.myfaces.tobago.internal.layout;
+import org.apache.myfaces.tobago.internal.component.AbstractUIFlexLayout;
+import org.apache.myfaces.tobago.internal.component.AbstractUIFlowLayout;
import org.apache.myfaces.tobago.layout.LayoutBase;
import org.apache.myfaces.tobago.layout.LayoutBox;
import org.apache.myfaces.tobago.layout.LayoutComponent;
@@ -55,16 +57,17 @@ public final class LayoutUtils {
return true;
}
- public static List<LayoutComponent> findLayoutChildren(final LayoutContainer container) {
- final List<LayoutComponent> result = new ArrayList<LayoutComponent>();
+ public static List<UIComponent> findLayoutChildren(final LayoutContainer container) {
+ final List<UIComponent> result = new ArrayList<UIComponent>();
addLayoutChildren((UIComponent) container, result);
return result;
}
- private static void addLayoutChildren(final UIComponent component, final List<LayoutComponent> result) {
+ private static void addLayoutChildren(final UIComponent component, final List<UIComponent> result) {
for (final UIComponent child : component.getChildren()) {
- if (child instanceof LayoutComponent) {
- result.add((LayoutComponent) child);
+ if (child instanceof LayoutComponent
+ || child instanceof AbstractUIFlowLayout || child instanceof AbstractUIFlexLayout) {
+ result.add(child);
} else {
// Child seems to be transparent for layout, like UIForm.
// So we try to add the inner components.
@@ -73,8 +76,9 @@ public final class LayoutUtils {
}
final UIComponent child = component.getFacet(UIComponent.COMPOSITE_FACET_NAME);
- if (child instanceof LayoutComponent) {
- result.add((LayoutComponent) child);
+ if (child instanceof LayoutComponent
+ || child instanceof AbstractUIFlowLayout || child instanceof AbstractUIFlexLayout) {
+ result.add(child);
} else if (child != null) {
// Child seems to be transparent for layout, like UIForm.
// So we try to add the inner components.
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/OriginCell.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/OriginCell.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/OriginCell.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/OriginCell.java Thu Jun 25 09:49:01 2015
@@ -19,20 +19,21 @@
package org.apache.myfaces.tobago.internal.layout;
-import org.apache.myfaces.tobago.layout.LayoutComponent;
import org.apache.myfaces.tobago.layout.Orientation;
+import javax.faces.component.UIComponent;
+
public class OriginCell implements Cell {
- private LayoutComponent component;
+ private UIComponent component;
private int columnSpan;
private int rowSpan;
- public OriginCell(final LayoutComponent component) {
+ public OriginCell(final UIComponent component) {
this.component = component;
}
- public LayoutComponent getComponent() {
+ public UIComponent getComponent() {
return component;
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/SpanCell.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/SpanCell.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/SpanCell.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/layout/SpanCell.java Thu Jun 25 09:49:01 2015
@@ -19,7 +19,7 @@
package org.apache.myfaces.tobago.internal.layout;
-import org.apache.myfaces.tobago.layout.LayoutComponent;
+import javax.faces.component.UIComponent;
public class SpanCell implements Cell {
@@ -33,7 +33,7 @@ public class SpanCell implements Cell {
this.verticalFirst = verticalFirst;
}
- public LayoutComponent getComponent() {
+ public UIComponent getComponent() {
return origin.getComponent();
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/GridLayoutTagDeclaration.java Thu Jun 25 09:49:01 2015
@@ -105,24 +105,6 @@ public interface GridLayoutTagDeclaratio
HasMargins, HasColumnLayout, HasRowLayout, HasBinding, HasMarkup, HasCurrentMarkup {
/**
- * This attribute is a hint for the layout manager. Should not be used in most cases.
- *
- * @param columnOverflow Does the component need a horizontal scrollbar?
- */
- @TagAttribute
- @UIComponentTagAttribute(type = "boolean")
- void setColumnOverflow(String columnOverflow);
-
- /**
- * This attribute is a hint for the layout manager. Should not be used in most cases.
- *
- * @param rowOverflow Does the component need a vertical scrollbar?
- */
- @TagAttribute
- @UIComponentTagAttribute(type = "boolean")
- void setRowOverflow(String rowOverflow);
-
- /**
* This attribute advises the layout manager, to not use space that comes from non rendered components.
*/
@TagAttribute
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasMargins.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasMargins.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasMargins.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasMargins.java Thu Jun 25 09:49:01 2015
@@ -30,9 +30,7 @@ public interface HasMargins {
@TagAttribute
@UIComponentTagAttribute(
type = "org.apache.myfaces.tobago.layout.Measure",
- defaultCode = "getMargin() != null\n"
- + " ? getMargin()\n : getRendererType() != null"
- + " ? ((MarginValues)getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this) : Measure.ZERO")
+ defaultCode = "getMargin() != null ? getMargin() : Measure.ZERO")
void setMarginLeft(String margin);
/**
@@ -41,9 +39,7 @@ public interface HasMargins {
@TagAttribute
@UIComponentTagAttribute(
type = "org.apache.myfaces.tobago.layout.Measure",
- defaultCode = "getMargin() != null\n"
- + " ? getMargin()\n : getRendererType() != null"
- + " ? ((MarginValues)getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this) : Measure.ZERO")
+ defaultCode = "getMargin() != null ? getMargin() : Measure.ZERO")
void setMarginRight(String margin);
/**
@@ -52,9 +48,7 @@ public interface HasMargins {
@TagAttribute
@UIComponentTagAttribute(
type = "org.apache.myfaces.tobago.layout.Measure",
- defaultCode = "getMargin() != null\n"
- + " ? getMargin()\n : getRendererType() != null"
- + " ? ((MarginValues)getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this) : Measure.ZERO")
+ defaultCode = "getMargin() != null ? getMargin() : Measure.ZERO")
void setMarginTop(String margin);
/**
@@ -63,9 +57,7 @@ public interface HasMargins {
@TagAttribute
@UIComponentTagAttribute(
type = "org.apache.myfaces.tobago.layout.Measure",
- defaultCode = "getMargin() != null\n"
- + " ? getMargin()\n : getRendererType() != null"
- + " ? ((MarginValues)getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this) : Measure.ZERO")
+ defaultCode = "getMargin() != null ? getMargin() : Measure.ZERO")
void setMarginBottom(String margin);
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContainer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContainer.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContainer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContainer.java Thu Jun 25 09:49:01 2015
@@ -19,12 +19,8 @@
package org.apache.myfaces.tobago.layout;
-import java.util.List;
-
public interface LayoutContainer extends LayoutBox, LayoutBase {
- List<LayoutComponent> getComponents();
-
LayoutManager getLayoutManager();
void setLayoutManager(LayoutManager layoutManager);
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/layout/GridUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/layout/GridUnitTest.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/layout/GridUnitTest.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/layout/GridUnitTest.java Thu Jun 25 09:49:01 2015
@@ -20,7 +20,6 @@
package org.apache.myfaces.tobago.internal.layout;
import org.apache.myfaces.tobago.layout.LayoutTokens;
-import org.apache.myfaces.tobago.layout.Orientation;
import org.junit.Assert;
import org.junit.Test;
@@ -30,24 +29,24 @@ public class GridUnitTest {
public void test1x1() {
final Grid grid = new Grid(LayoutTokens.parse("*"), LayoutTokens.parse("*"));
- Assert.assertEquals(1, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(1, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(1, grid.getColumns().getSize());
+ Assert.assertEquals(1, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ\n"
+ "âââ\n"
+ "âââ\n", grid.gridAsString());
grid.add(new OriginCell(null), 1, 1);
- Assert.assertEquals(1, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(1, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(1, grid.getColumns().getSize());
+ Assert.assertEquals(1, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ\n"
+ "âââ\n"
+ "âââ\n", grid.gridAsString());
grid.add(new OriginCell(null), 1, 1);
- Assert.assertEquals(1, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(2, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(1, grid.getColumns().getSize());
+ Assert.assertEquals(2, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ\n"
+ "âââ\n"
@@ -56,8 +55,8 @@ public class GridUnitTest {
+ "âââ\n", grid.gridAsString());
grid.add(new OriginCell(null), 1, 2);
- Assert.assertEquals(1, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(4, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(1, grid.getColumns().getSize());
+ Assert.assertEquals(4, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ\n"
+ "âââ\n"
@@ -71,8 +70,8 @@ public class GridUnitTest {
// with warning
grid.add(new OriginCell(null), 2, 1);
- Assert.assertEquals(1, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(5, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(1, grid.getColumns().getSize());
+ Assert.assertEquals(5, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ\n"
+ "âââ\n"
@@ -91,32 +90,32 @@ public class GridUnitTest {
public void test2x1() {
final Grid grid = new Grid(LayoutTokens.parse("*;*"), LayoutTokens.parse("*"));
- Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(1, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(2, grid.getColumns().getSize());
+ Assert.assertEquals(1, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ¬ââ\n"
+ "âââââ\n"
+ "âââ´ââ\n", grid.gridAsString());
grid.add(new OriginCell(null), 1, 1);
- Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(1, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(2, grid.getColumns().getSize());
+ Assert.assertEquals(1, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ±ââ\n"
+ "âââââ\n"
+ "âââ¹ââ\n", grid.gridAsString());
grid.add(new OriginCell(null), 1, 1);
- Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(1, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(2, grid.getColumns().getSize());
+ Assert.assertEquals(1, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ³ââ\n"
+ "âââââ\n"
+ "âââ»ââ\n", grid.gridAsString());
grid.add(new OriginCell(null), 2, 2);
- Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(3, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(2, grid.getColumns().getSize());
+ Assert.assertEquals(3, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ³ââ\n"
+ "âââââ\n"
@@ -127,8 +126,8 @@ public class GridUnitTest {
+ "âââ·ââ\n", grid.gridAsString());
grid.add(new OriginCell(null), 1, 2);
- Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(5, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(2, grid.getColumns().getSize());
+ Assert.assertEquals(5, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ³ââ\n"
+ "âââââ\n"
@@ -143,8 +142,8 @@ public class GridUnitTest {
+ "âââ¹ââ\n", grid.gridAsString());
grid.add(new OriginCell(null), 1, 1);
- Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(5, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(2, grid.getColumns().getSize());
+ Assert.assertEquals(5, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ³ââ\n"
+ "âââââ\n"
@@ -159,8 +158,8 @@ public class GridUnitTest {
+ "âââ¹ââ\n", grid.gridAsString());
grid.add(new OriginCell(null), 1, 2);
- Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(6, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(2, grid.getColumns().getSize());
+ Assert.assertEquals(6, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ³ââ\n"
+ "âââââ\n"
@@ -178,16 +177,16 @@ public class GridUnitTest {
grid.add(new OriginCell(null), 2, 1);
// fehler
- Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(6, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(2, grid.getColumns().getSize());
+ Assert.assertEquals(6, grid.getRows().getSize());
}
@Test
public void test5x5() {
final Grid grid = new Grid(LayoutTokens.parse("*;*;*;*;*"), LayoutTokens.parse("*;*;*;*;*"));
- Assert.assertEquals(5, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(5, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(5, grid.getColumns().getSize());
+ Assert.assertEquals(5, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ¬ââ¬ââ¬ââ¬ââ\n"
+ "âââââââââââ\n"
@@ -214,8 +213,8 @@ public class GridUnitTest {
grid.add(new OriginCell(null), 1, 2);
grid.add(new OriginCell(null), 2, 1);
grid.add(new OriginCell(null), 1, 1);
- Assert.assertEquals(5, grid.getBankHeads(Orientation.HORIZONTAL).length);
- Assert.assertEquals(5, grid.getBankHeads(Orientation.VERTICAL).length);
+ Assert.assertEquals(5, grid.getColumns().getSize());
+ Assert.assertEquals(5, grid.getRows().getSize());
Assert.assertEquals(""
+ "âââ³ââ³ââ³ââ¯ââ\n"
+ "âââââââââââ\n"
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISplitLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISplitLayout.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISplitLayout.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISplitLayout.java Thu Jun 25 09:49:01 2015
@@ -19,6 +19,7 @@
package org.apache.myfaces.tobago.internal.component;
+import org.apache.myfaces.tobago.internal.layout.LayoutUtils;
import org.apache.myfaces.tobago.layout.LayoutComponent;
import org.apache.myfaces.tobago.layout.LayoutContainer;
import org.apache.myfaces.tobago.layout.Measure;
@@ -26,7 +27,9 @@ import org.apache.myfaces.tobago.layout.
import javax.el.ELContext;
import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import java.util.List;
public abstract class AbstractUISplitLayout extends AbstractUIGridLayout {
@@ -37,8 +40,9 @@ public abstract class AbstractUISplitLay
public void updateLayout(final int position) {
final LayoutContainer container = (LayoutContainer) getParent();
- final LayoutComponent firstComponent = container.getComponents().get(0);
- final LayoutComponent secondComponent = container.getComponents().get(1);
+ final List<UIComponent> components = LayoutUtils.findLayoutChildren(container);
+ final LayoutComponent firstComponent = (LayoutComponent) components.get(0);
+ final LayoutComponent secondComponent = (LayoutComponent) components.get(1);
final int oldPosition;
final int currentSize1;
@@ -58,10 +62,7 @@ public abstract class AbstractUISplitLay
final int newSize2 = currentSize2 - offset;
final int ggt = gcd(newSize1, newSize2);
- submittedLayout = new StringBuilder()
- .append(Integer.toString(newSize1 / ggt)).append("*;")
- .append(Integer.toString(newSize2 / ggt)).append("*")
- .toString();
+ submittedLayout = Integer.toString(newSize1 / ggt) + "*;" + Integer.toString(newSize2 / ggt) + "*";
}
// TODO: MathUtils
@@ -98,10 +99,6 @@ public abstract class AbstractUISplitLay
}
}
- public Measure getSpacing(final Orientation orientation) {
- return orientation == Orientation.HORIZONTAL ? getColumnSpacing() : getRowSpacing();
- }
-
@Override
public void setColumns(final String columns) {
}
@@ -128,16 +125,6 @@ public abstract class AbstractUISplitLay
return submittedLayout != null ? submittedLayout : getLayout();
}
- @Override
- public boolean isRowOverflow() {
- return false;
- }
-
- @Override
- public boolean isColumnOverflow() {
- return false;
- }
-
public abstract String getLayout();
public abstract String getOrientation();
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SplitLayoutRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SplitLayoutRenderer.java?rev=1687462&r1=1687461&r2=1687462&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SplitLayoutRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SplitLayoutRenderer.java Thu Jun 25 09:49:01 2015
@@ -19,6 +19,7 @@
package org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag;
+import org.apache.myfaces.tobago.internal.layout.LayoutUtils;
import org.apache.myfaces.tobago.renderkit.html.standard.standard.tag.GridLayoutRenderer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,17 +64,15 @@ public class SplitLayoutRenderer extends
@Override
public void encodeChildren(final FacesContext facesContext, final UIComponent component) throws IOException {
- final LayoutContainer container = (LayoutContainer) ((AbstractUISplitLayout) component).getParent();
- if (!((LayoutContainer) container).isLayoutChildren()) {
- return;
- } else {
- final List<LayoutComponent> components = container.getComponents();
+ final LayoutContainer container = (LayoutContainer) component.getParent();
+ if (container.isLayoutChildren()) {
+ final List<UIComponent> components = LayoutUtils.findLayoutChildren(container);
if (components.size() != 2) {
LOG.warn("Illegal component count in splitLayout: {}", components.size());
}
- RenderUtils.encode(facesContext, (UIComponent) components.get(0));
- RenderUtils.encode(facesContext, (UIComponent) components.get(1));
- if (((UIComponent) components.get(0)).isRendered() && ((UIComponent) components.get(1)).isRendered()) {
+ RenderUtils.encode(facesContext, components.get(0));
+ RenderUtils.encode(facesContext, components.get(1));
+ if (components.get(0).isRendered() && components.get(1).isRendered()) {
// only when both components are rendered
encodeHandle(facesContext, (AbstractUISplitLayout) component);
}
@@ -111,9 +110,10 @@ public class SplitLayoutRenderer extends
}
private String createDraggableContainment(final AbstractUISplitLayout layout) {
- final LayoutContainer container = (LayoutContainer) ((AbstractUISplitLayout) layout).getParent();
- final LayoutComponent firstComponent = container.getComponents().get(0);
- final LayoutComponent secondComponent = container.getComponents().get(1);
+ final LayoutContainer container = (LayoutContainer) layout.getParent();
+ final List<UIComponent> components = LayoutUtils.findLayoutChildren(container);
+ final LayoutComponent firstComponent = (LayoutComponent) components.get(0);
+ final LayoutComponent secondComponent = (LayoutComponent) components.get(1);
Measure minimum;
if (AbstractUISplitLayout.HORIZONTAL.equals(layout.getOrientation())) {
@@ -122,22 +122,20 @@ public class SplitLayoutRenderer extends
minimum = secondComponent.getMinimumWidth();
final int minimumSize2 = minimum != null ? minimum.getPixel() : 0;
final int totalSize = container.getCurrentWidth().getPixel();
- return new StringBuilder("[").append(minimumSize1).append(", 0, ").append(totalSize-minimumSize2).append(", 0]")
- .toString();
+ return "[" + minimumSize1 + ", 0, " + (totalSize - minimumSize2) + ", 0]";
} else {
minimum = firstComponent.getMinimumHeight();
final int minimumSize1 = minimum != null ? minimum.getPixel() : 0;
minimum = secondComponent.getMinimumHeight();
final int minimumSize2 = minimum != null ? minimum.getPixel() : 0;
final int totalSize = container.getCurrentHeight().getPixel();
- return new StringBuilder("[0, ").append(minimumSize1).append(", 0, ").append(totalSize-minimumSize2).append("]")
- .toString();
+ return "[0, " + minimumSize1 + ", 0, " + (totalSize - minimumSize2) + "]";
}
}
private Style calculateHandleStyle(final AbstractUISplitLayout layout) {
- final LayoutContainer container = (LayoutContainer) ((AbstractUISplitLayout) layout).getParent();
- final LayoutComponent secondComponent = container.getComponents().get(1);
+ final LayoutContainer container = (LayoutContainer) layout.getParent();
+ final LayoutComponent secondComponent = (LayoutComponent) LayoutUtils.findLayoutChildren(container).get(1);
final Style style = new Style();
if (AbstractUISplitLayout.HORIZONTAL.equals(layout.getOrientation())) {
style.setWidth(Measure.valueOf(5));
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/GridLayoutRenderer.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/GridLayoutRenderer.java?rev=1687462&r1=1687461&r2=1687462&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/GridLayoutRenderer.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/GridLayoutRenderer.java Thu Jun 25 09:49:01 2015
@@ -22,15 +22,13 @@ package org.apache.myfaces.tobago.render
import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.config.Configurable;
import org.apache.myfaces.tobago.internal.component.AbstractUIGridLayout;
-import org.apache.myfaces.tobago.internal.layout.BankHead;
import org.apache.myfaces.tobago.internal.layout.Cell;
import org.apache.myfaces.tobago.internal.layout.Grid;
import org.apache.myfaces.tobago.internal.layout.OriginCell;
import org.apache.myfaces.tobago.layout.AutoLayoutToken;
-import org.apache.myfaces.tobago.layout.LayoutComponent;
import org.apache.myfaces.tobago.layout.LayoutToken;
+import org.apache.myfaces.tobago.layout.LayoutTokens;
import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.Orientation;
import org.apache.myfaces.tobago.layout.PixelLayoutToken;
import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
import org.apache.myfaces.tobago.renderkit.MarginValues;
@@ -70,47 +68,42 @@ public class GridLayoutRenderer extends
final StringBuilder builder = new StringBuilder();
builder.append("{\"columns\":");
- jsonLayout(gridLayout.getGrid().getBankHeads(Orientation.HORIZONTAL), builder);
+ jsonLayout(gridLayout.getGrid().getColumns(), builder);
builder.append(",");
builder.append("\"rows\":");
- jsonLayout(gridLayout.getGrid().getBankHeads(Orientation.VERTICAL), builder);
+ jsonLayout(gridLayout.getGrid().getRows(), builder);
builder.append("}");
writer.writeAttribute("data-tobago-layout", builder.toString(), true);
writer.startElement(HtmlElements.COLGROUP, gridLayout);
- final BankHead[] horizontalBankHeads = gridLayout.getGrid().getBankHeads(Orientation.HORIZONTAL);
- for (BankHead horizontalBankHead : horizontalBankHeads) {
- if (horizontalBankHead.isRendered()) {
+ final LayoutTokens columns = gridLayout.getGrid().getColumns();
+ for (LayoutToken column : columns.getTokens()) {
writer.startElement(HtmlElements.COL, gridLayout);
writer.endElement(HtmlElements.COL);
- }
}
writer.endElement(HtmlElements.COLGROUP);
writer.startElement(HtmlElements.TBODY, gridLayout);
}
- private void jsonLayout(final BankHead[] bankHeads, final StringBuilder builder) {
+ private void jsonLayout(final LayoutTokens bankHeads, final StringBuilder builder) {
builder.append("[");
- for (int i = 0; i < bankHeads.length; i++) {
- if (bankHeads[i].isRendered()) {
- final LayoutToken token = bankHeads[i].getToken();
- if (token instanceof RelativeLayoutToken) {
- final int factor = ((RelativeLayoutToken) token).getFactor();
- builder.append(factor);
- } else if (token instanceof AutoLayoutToken) {
- builder.append("\"auto\"");
- } else if (token instanceof PixelLayoutToken) {
- builder.append("{\"pixel\":");
- builder.append(((PixelLayoutToken) token).getPixel());
- builder.append("}");
- } else {
- LOG.warn("Not supported: " + token);
- }
- builder.append(',');
+ for (final LayoutToken token : bankHeads.getTokens()) {
+ if (token instanceof RelativeLayoutToken) {
+ final int factor = ((RelativeLayoutToken) token).getFactor();
+ builder.append(factor);
+ } else if (token instanceof AutoLayoutToken) {
+ builder.append("\"auto\"");
+ } else if (token instanceof PixelLayoutToken) {
+ builder.append("{\"pixel\":");
+ builder.append(((PixelLayoutToken) token).getPixel());
+ builder.append("}");
+ } else {
+ LOG.warn("Not supported: " + token);
}
+ builder.append(',');
}
if (builder.charAt(builder.length() - 1) == ',') {
builder.deleteCharAt(builder.length() - 1);
@@ -131,64 +124,58 @@ public class GridLayoutRenderer extends
final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
final Grid grid = gridLayout.getGrid();
- final BankHead[] horizontalBankHeads = grid.getBankHeads(Orientation.HORIZONTAL);
- final BankHead[] verticalBankHeads = grid.getBankHeads(Orientation.VERTICAL);
+ final int columns = grid.getColumnCount();
+ final int rows = grid.getRowCount();
- for (int i = 0; i < verticalBankHeads.length; i++) {
- if (verticalBankHeads[i].isRendered()) {
- writer.startElement(HtmlElements.TR, gridLayout);
- for (int j = 0; j < horizontalBankHeads.length; j++) {
- if (horizontalBankHeads[j].isRendered()) {
- final Cell cell = grid.getCell(j, i);
- if (cell instanceof OriginCell) {
- writer.startElement(HtmlElements.TD, gridLayout);
- final int columnSpan = cell.getColumnSpan();
- if (columnSpan > 1) {
- writer.writeAttribute(HtmlAttributes.COLSPAN, columnSpan);
- }
- final int rowSpan = cell.getRowSpan();
- if (rowSpan > 1) {
- writer.writeAttribute(HtmlAttributes.ROWSPAN, rowSpan);
- }
-
-
- final LayoutComponent element = cell.getComponent();
- StringBuilder builder = new StringBuilder();
- builder.append("{");
- final Measure width = element.getWidth();
- if (width != null) {
- builder.append("\"width\":");
- builder.append("{\"pixel\":");
- builder.append(width.getPixel());
- builder.append("}");
- builder.append(",");
- }
- final Measure height = element.getHeight();
- if (height != null) {
- builder.append("\"height\":");
- builder.append("{\"pixel\":");
- builder.append(height.getPixel());
- builder.append("}");
- builder.append(",");
- }
- if (builder.length() > 1) {
- builder.deleteCharAt(builder.length() - 1);
- }
- // todo: add more attributes
- builder.append("}");
-
- final UIComponent child = (UIComponent) element;
- if (builder.length() > 2) { // empty is not need to render
- ComponentUtils.putDataAttribute(child, "tobago-layout", builder.toString());
- }
- RenderUtils.encode(facesContext, child);
+ for (int i = 0; i < rows; i++) {
+ writer.startElement(HtmlElements.TR, gridLayout);
+ for (int j = 0; j < columns; j++) {
+ final Cell cell = grid.getCell(j, i);
+ if (cell instanceof OriginCell) {
+ writer.startElement(HtmlElements.TD, gridLayout);
+ final int columnSpan = cell.getColumnSpan();
+ if (columnSpan > 1) {
+ writer.writeAttribute(HtmlAttributes.COLSPAN, columnSpan);
+ }
+ final int rowSpan = cell.getRowSpan();
+ if (rowSpan > 1) {
+ writer.writeAttribute(HtmlAttributes.ROWSPAN, rowSpan);
+ }
- writer.endElement(HtmlElements.TD);
- }
+ final UIComponent element = cell.getComponent();
+ StringBuilder builder = new StringBuilder();
+ builder.append("{");
+ final Measure width = (Measure) element.getAttributes().get(Attributes.WIDTH);
+ if (width != null) {
+ builder.append("\"width\":");
+ builder.append("{\"pixel\":");
+ builder.append(width.getPixel());
+ builder.append("}");
+ builder.append(",");
+ }
+ final Measure height = (Measure) element.getAttributes().get(Attributes.HEIGHT);
+ if (height != null) {
+ builder.append("\"height\":");
+ builder.append("{\"pixel\":");
+ builder.append(height.getPixel());
+ builder.append("}");
+ builder.append(",");
}
+ if (builder.length() > 1) {
+ builder.deleteCharAt(builder.length() - 1);
+ }
+ // todo: add more attributes
+ builder.append("}");
+
+ if (builder.length() > 2) { // empty is not need to render
+ ComponentUtils.putDataAttribute(element, "tobago-layout", builder.toString());
+ }
+ RenderUtils.encode(facesContext, element);
+
+ writer.endElement(HtmlElements.TD);
}
- writer.endElement(HtmlElements.TR);
}
+ writer.endElement(HtmlElements.TR);
}
}
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=1687462&r1=1687461&r2=1687462&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 Thu Jun 25 09:49:01 2015
@@ -793,7 +793,7 @@ public class SheetRenderer extends Layou
writer.writeAttribute(HtmlAttributes.ROWSPAN, cell.getRowSpan());
}
- final UIComponent cellComponent = (UIComponent) cell.getComponent();
+ final UIComponent cellComponent = cell.getComponent();
final boolean pure = !(cellComponent instanceof UIOut);
writer.startElement(HtmlElements.DIV, null);