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 2009/07/23 09:23:25 UTC
svn commit: r796969 [2/2] - in /myfaces/tobago/trunk:
core/src/main/faces-config/
core/src/main/java/org/apache/myfaces/tobago/component/
core/src/main/java/org/apache/myfaces/tobago/renderkit/
core/src/main/java/org/apache/myfaces/tobago/taglib/compon...
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java Thu Jul 23 07:23:23 2009
@@ -24,389 +24,26 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.tobago.component.AbstractUIForm;
-import org.apache.myfaces.tobago.component.AbstractUIGridLayout;
-import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.component.UICell;
import org.apache.myfaces.tobago.component.UIGridLayout;
-import org.apache.myfaces.tobago.component.UILayout;
-import org.apache.myfaces.tobago.config.ThemeConfig;
-import org.apache.myfaces.tobago.layout.FixedLayoutToken;
-import org.apache.myfaces.tobago.layout.HideLayoutToken;
-import org.apache.myfaces.tobago.layout.LayoutToken;
-import org.apache.myfaces.tobago.layout.LayoutTokens;
-import org.apache.myfaces.tobago.layout.MinimumLayoutToken;
-import org.apache.myfaces.tobago.layout.PixelLayoutToken;
-import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
-import org.apache.myfaces.tobago.renderkit.LayoutInformationProvider;
-import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
-import org.apache.myfaces.tobago.renderkit.html.HtmlStyleMap;
-import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtil;
import org.apache.myfaces.tobago.renderkit.util.RenderUtil;
-import org.apache.myfaces.tobago.util.ComponentUtil;
-import org.apache.myfaces.tobago.util.LayoutInfo;
-import org.apache.myfaces.tobago.util.LayoutUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
public class GridLayoutRenderer extends DefaultLayoutRenderer {
private static final Log LOG = LogFactory.getLog(GridLayoutRenderer.class);
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
- int height = calculateLayoutHeight(facesContext, component, false);
-
- LayoutInformationProvider containerRenderer =
- ComponentUtil.getRenderer(facesContext, component);
- height += containerRenderer.getHeaderHeight(facesContext, component);
- height += containerRenderer.getPaddingHeight(facesContext, component);
- return height;
- }
-
- public int getFixedWidth(FacesContext facesContext, UIComponent component) {
- int width = calculateLayoutWidth(facesContext, component, false);
-
- LayoutInformationProvider containerRenderer =
- ComponentUtil.getRenderer(facesContext, component);
- width += containerRenderer.getPaddingWidth(facesContext, component);
- return width;
- }
-
- private int calculateLayoutHeight(
- FacesContext facesContext, UIComponent component, boolean minimum) {
- UIGridLayout layout = (UIGridLayout) UILayout.getLayout(component);
- final List<AbstractUIGridLayout.Row> rows = layout.ensureRows();
-
- LayoutTokens layoutTokens = layout.getRowLayout();
-
- if (layoutTokens == null && !minimum && LOG.isDebugEnabled()) {
- LOG.debug("No rowLayout found using " + (minimum ? "'minimum'" : "'fixed'")
- + " for all " + rows.size() + " rows."
- + " (clientId='" + layout.getClientId(facesContext) + "')");
- }
- if (rows.size() != layoutTokens.getSize()) {
- LOG.warn("Unbalanced layout: rows.size()=" + rows.size()
- + " != layoutTokens.length=" + layoutTokens.getSize()
- + " rowLayout='" + layoutTokens + "'"
- + " (clientId='" + layout.getClientId(facesContext) + "')");
- layoutTokens.ensureSize(rows.size(), new RelativeLayoutToken(1));
- }
- // TODO alternative? rows.size() == 1 ? new RelativeLayoutToken(1) : new FixedLayoutToken()
- //new FixedLayoutToken() );
- //String[] layoutTokens
- // = LayoutInfo.createLayoutTokens(rowLayout, rows.size(),
- // minimum ? "minimum" : "fixed");
-
-
- int size = Math.min(rows.size(), layoutTokens.getSize());
-
- int height = 0;
- height += getMarginAsInt(layout.getMarginTop());
- height += getMarginAsInt(layout.getMarginBottom());
- boolean first = true;
- for (int i = 0; i < size; i++) {
- if (!rowIsRendered(rows.get(i))) {
- continue;
- }
- height += getCellPadding(facesContext, layout, first);
- first = false;
- LayoutToken token = layoutTokens.get(i);
- if (token instanceof PixelLayoutToken) {
- height += ((PixelLayoutToken) token).getPixel();
- } else if (token instanceof FixedLayoutToken) {
- height += getMaxHeight(facesContext, rows.get(i), false);
- } else if (token instanceof MinimumLayoutToken) {
- height += getMaxHeight(facesContext, rows.get(i), true);
- } else {
- if (!minimum && LOG.isWarnEnabled()) {
- if (layout.getRows() != null) {
- // TODO: this is only an error if the token was explicitly set by application
- LOG.warn("Unable to calculate Height for token '" + token
- + "'! using " + (minimum ? "'minimum'" : "'fixed'") + " , component-id="
- + component.getClientId(facesContext) + " is "
- + component.getRendererType());
- }
- }
- height += getMaxHeight(facesContext, rows.get(i), minimum);
- }
- }
-
- return height;
- }
-
-
- public int calculateLayoutWidth(
- FacesContext facesContext, UIComponent component, boolean minimum) {
- UIGridLayout layout = (UIGridLayout) UILayout.getLayout(component);
- final List<AbstractUIGridLayout.Row> rows = layout.ensureRows();
- AbstractUIGridLayout.Row row = rows.get(0);
-
-
- LayoutTokens layoutTokens = layout.getColumnLayout();
-
- if (layoutTokens == null && !minimum && LOG.isDebugEnabled()) {
- LOG.debug("No rowLayout found using " + (minimum ? "'minimum'" : "'fixed'")
- + " for all " + rows.size() + " rows of "
- + layout.getClientId(facesContext) + " !");
- }
-
- if (row.getColumns() != layoutTokens.getSize()) {
- LOG.warn("Unbalanced layout: rows.size()=" + rows.size()
- + " != layoutTokens.length=" + layoutTokens.getSize()
- + " columnLayout='" + layoutTokens + "'"
- + " (clientId='" + layout.getClientId(facesContext) + "')");
- layoutTokens.ensureSize(row.getColumns(), new FixedLayoutToken());
- }
-
- int size = Math.min(rows.size(), layoutTokens.getSize());
-
- int width = 0;
- width += getMarginAsInt(layout.getMarginLeft());
- width += getMarginAsInt(layout.getMarginRight());
- boolean first = true;
- for (int i = 0; i < size; i++) {
- if (!columnIsRendered(rows, i)) {
- continue;
- }
- width += getCellPadding(facesContext, layout, first);
- first = false;
- LayoutToken token = layoutTokens.get(i);
- if (token instanceof PixelLayoutToken) {
- width += ((PixelLayoutToken) token).getPixel();
- } else if (token instanceof FixedLayoutToken) {
- width += getMaxWidth(facesContext, rows, i, false);
- } else if (token instanceof MinimumLayoutToken) {
- width += getMaxWidth(facesContext, rows, i, true);
- } else {
- if (!minimum && LOG.isWarnEnabled()) {
- LOG.warn("Unable to calculate Width for token '" + token
- + "'! using " + (minimum ? "'minimum'" : "'fixed'") + " , component-id="
- + component.getClientId(facesContext) + " is "
- + component.getRendererType());
- }
- width += getMaxWidth(facesContext, rows, i, minimum);
- }
- }
-
- return width;
- }
-
- private boolean columnIsRendered(List<UIGridLayout.Row> rows, int column) {
- for (AbstractUIGridLayout.Row row : rows) {
- Object object = row.getElements().get(column);
- if (object instanceof UIComponent) {
- if (object instanceof UICell) {
- UICell cell = (UICell) object;
- if (cell.getSpanX() > 1) {
- return false;
- }
- }
- UIComponent component = (UIComponent) object;
- if (component.isRendered()) {
- return true;
- }
- // XXX ????
- } else if (UIGridLayout.USED.equals(object)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean rowIsRendered(UIGridLayout.Row row) {
- for (Object element : row.getElements()) {
- if (element instanceof UIComponent) {
- UIComponent component = (UIComponent) element;
- if (component.isRendered()) {
- return true;
- }
- }
- }
- return false;
- }
-
- public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
- super.prepareRender(facesContext, component);
- layoutEnd(facesContext, component);
- layoutMargins((UIGridLayout) component);
-
- }
-
- void prepareDimension(FacesContext facesContext, UIComponent component) {
-
- }
-
- public void encodeChildrenOfComponent(FacesContext facesContext, UIComponent component)
- throws IOException {
- // encode table with component's children
-
- UIGridLayout layout = (UIGridLayout) UILayout.getLayout(component);
- //prepareRender(facesContext, layout);
- //HtmlRendererUtil.prepareRender(facesContext, layout);
-
- //layoutEnd(facesContext, layout);
- //layoutMargins(layout);
-
- final Map attributes = layout.getAttributes();
- List columnWidths = (List) attributes.get(Attributes.WIDTH_LIST);
-
-
- TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
- writer.startElement(HtmlConstants.TABLE, layout);
- writer.writeAttributeFromComponent(HtmlAttributes.BORDER, Attributes.BORDER);
- writer.writeClassAttribute();
- writer.writeStyleAttribute();
- writer.writeAttribute(HtmlAttributes.CELLSPACING, 0);
- writer.writeAttribute(HtmlAttributes.CELLPADDING, 0);
- writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);
-
- boolean first = true;
- if (columnWidths != null) {
- writer.startElement(HtmlConstants.COLGROUP, null);
- for (int i = 0; i < columnWidths.size(); i++) {
- int cellWidth = ((Integer) columnWidths.get(i)).intValue();
- if (cellWidth != LayoutInfo.HIDE) {
- cellWidth += getCellPadding(facesContext, layout, first);
- first = false;
- writer.startElement(HtmlConstants.COL, null);
- writer.writeAttribute(HtmlAttributes.WIDTH, cellWidth);
- writer.endElement(HtmlConstants.COL);
- }
- }
- writer.endElement(HtmlConstants.COLGROUP);
- }
-
-
- List<AbstractUIGridLayout.Row> rows = layout.ensureRows();
- boolean firstRenderedRow = true;
- for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) {
- AbstractUIGridLayout.Row row = rows.get(rowIndex);
- if (!row.isHidden()) {
- writer.startElement(HtmlConstants.TR, null);
-
- List cells = row.getElements();
- boolean firstRenderedColum = true;
- for (int columnIndex = 0; columnIndex < cells.size(); columnIndex++) {
- boolean hide = false;
-
- if (columnWidths != null) {
- Integer columWidth = ((Integer) columnWidths.get(columnIndex));
- hide = columWidth.intValue() == LayoutInfo.HIDE;
- }
- if (!hide) {
-
- Object object = cells.get(columnIndex);
- if (object.toString().equals(UIGridLayout.USED)) {
- firstRenderedColum = false;
- continue; // ignore the markers UIGridLayout.Used
- } else if (object.equals(UIGridLayout.FREE)) {
- if (LOG.isWarnEnabled() && !layout.isIgnoreFree()) {
- LOG.warn("There are free blocks in the layout: id='"
- + layout.getClientId(facesContext)
- + "'");
- }
- firstRenderedColum = false;
- continue;
- }
- UIComponent cell = (UIComponent) object;
-
-
- int spanX = UIGridLayout.getSpanX(cell);
- int spanY = UIGridLayout.getSpanY(cell);
- StyleClasses classes = StyleClasses.ensureStyleClassesCopy(layout);
- if (firstRenderedRow) {
- classes.addClass("gridLayout", "first-row"); // XXX not a standard compliant name
- }
- if (firstRenderedColum) {
- classes.addClass("gridLayout", "first-column"); // XXX not a standard compliant name
- }
-
- int cellWidth = -1;
- if (columnWidths != null) {
- cellWidth = 0;
- for (int i = columnIndex;
- i < columnIndex + spanX && i < columnWidths.size(); i++) {
- cellWidth += ((Integer) columnWidths.get(i)).intValue()
- + getCellPadding(facesContext, layout, firstRenderedColum);
- if (firstRenderedColum) {
- firstRenderedColum = false;
- }
- }
- }
-
-
- int cellHeight = -1;
- try {
- Integer layoutHeight = LayoutUtils.getLayoutHeight(cell);
- if (layoutHeight != null) {
- cellHeight = layoutHeight.intValue();
- }
- } catch (Exception e) {
- // ignore
- } // ignore, use 0
-
- int topPadding = getCellPadding(facesContext, layout, firstRenderedRow);
- //("Cellheight " + cellHeight + " topPadding "+ topPadding + " firstRendered "
- // + firstRenderedRow + " RowIndex " + rowIndex + " Column " + columnIndex);
- String cellStyle =
- (cellWidth != -1 ? "width: " + cellWidth + "px;" : "")
- + (cellHeight != -1 ? " height: " + (cellHeight + topPadding) + "px;" : "");
- cellStyle += getOverflow(cell);
-
-
- writer.startElement(HtmlConstants.TD, null);
- writer.writeClassAttribute("tobago-gridLayout-cell-td");
- writer.writeAttribute(HtmlAttributes.STYLE, cellStyle, false);
- if (spanX > 1) {
- writer.writeAttribute(HtmlAttributes.COLSPAN, spanX);
- }
- if (spanY > 1) {
- writer.writeAttribute(HtmlAttributes.ROWSPAN, spanY);
- }
-
- writer.flush();
-
- if (ComponentUtil.getAttribute(layout, Attributes.CELLSPACING) != null) {
- cellStyle += " padding: " + getCellSpacing(facesContext, layout) + "px;";
- }
-
- writer.startElement(HtmlConstants.DIV, null);
- writer.writeClassAttribute(classes);
- writer.writeAttribute(HtmlAttributes.STYLE, cellStyle, false);
- writer.flush();
- RenderUtil.encode(facesContext, cell);
-
- writer.endElement(HtmlConstants.DIV);
- writer.endElement(HtmlConstants.TD);
-
- firstRenderedColum = false;
- HtmlRendererUtil.removeStyleClasses(cell);
- }
- }
-
- writer.endElement(HtmlConstants.TR);
- firstRenderedRow = false;
- }
- }
- writer.endElement(HtmlConstants.TABLE);
- }
-
@Override
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
UIGridLayout gridLayout = (UIGridLayout) component;
writer.startElement(HtmlConstants.DIV, gridLayout);
writer.writeClassAttribute();
-// writer.writeStyleAttribute();
}
@Override
@@ -419,530 +56,7 @@
public void encodeEnd(FacesContext facesContext,
UIComponent component) throws IOException {
TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
-// UIGridLayout gridLayout = (UIGridLayout)component;
writer.endElement(HtmlConstants.DIV);
-
-// if (component.getParent() instanceof UIPage) {
-// LOG.error("XXXXXXXXXXXXXXXXXXXXXXX never XXXXXXXXXXXXXXXXXXXXXX", new Exception());
-// } else {
-// encodeChildrenOfComponent(facesContext, component.getParent());
-// }
- }
-
- private String getOverflow(UIComponent cell) {
- String overflow = "";
-
- String scrollbars = (String) cell.getAttributes().get(Attributes.SCROLLBARS);
- if (scrollbars != null) {
- if (scrollbars.equals("false")) {
- overflow = " overflow: hidden;";
- } else if (scrollbars.equals("true")) {
- overflow = " overflow: scroll;";
- } else if (scrollbars.equals("auto")) {
- overflow = " overflow: auto;";
- } else {
- if (LOG.isWarnEnabled()) {
- LOG.warn("Illegal value for attribute 'scrollbars' : " + scrollbars);
- }
- }
- }
-
- return overflow;
- }
-
- private int getCellPadding(
- FacesContext facesContext, UIComponent component, boolean first) {
- return first ? 0 : getCellSpacing(facesContext, component);
- }
-
- private int getBorder(UIComponent component) {
- int border = 0;
- String borderWidth
- = (String) component.getAttributes().get(Attributes.BORDER);
- try {
- if (borderWidth != null) {
- border = Integer.parseInt(borderWidth);
- }
- } catch (NumberFormatException e) {
- if (LOG.isWarnEnabled()) {
- LOG.warn("Can't parse border, using 0!");
- }
- }
-
- return border;
- }
-
- private int getSpacingSum(UIComponent component, FacesContext facesContext,
- int count) {
- int space = 0;
- int border = getBorder(component);
- int cellSpacing = getCellSpacing(facesContext, component);
- if (border != 0) {
- space = (border * 2) + count * 2;
- }
- space += (count - 1) * cellSpacing;
- if (LOG.isDebugEnabled()) {
- LOG.debug("extra count =" + count + ", space = " + space);
- }
- return space;
}
- private int getWidthSpacingSum(UIGridLayout component,
- FacesContext facesContext, int renderedColumnCount) {
- int spacingSum = getSpacingSum(component, facesContext, renderedColumnCount);
- spacingSum += getComponentExtraWidth(facesContext, component);
- return spacingSum;
- }
-
- private int getCellSpacing(FacesContext facesContext, UIComponent component) {
- String cellspacing = (String) component.getAttributes().get(Attributes.CELLSPACING);
- if (cellspacing != null) {
- try {
- return Integer.parseInt(cellspacing);
- } catch (NumberFormatException e) {
- if (LOG.isWarnEnabled()) {
- LOG.warn("Illegal value for cellspacing : " + cellspacing
- + " using default");
- }
- // ignore and return defaut value
- }
- }
- return ThemeConfig.getValue(facesContext, component, "cellSpacing");
- }
-
- public void layoutEnd(FacesContext facesContext, UIComponent component) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("doLayout end");
- }
- UIGridLayout layout = (UIGridLayout) component;
- final Map attributes = layout.getParent().getAttributes();
-
-
- boolean needVerticalScroolbar = false;
- Integer innerHeight =
- (Integer) attributes.get(Attributes.INNER_HEIGHT);
- if (innerHeight != null && innerHeight.intValue() > 0) {
- int value = innerHeight.intValue();
- int minimum = calculateLayoutHeight(facesContext, layout.getParent(), true);
- if (minimum > value) {
- value = minimum;
- needVerticalScroolbar = true;
- }
- layoutHeight(Integer.valueOf(value), layout, facesContext);
- }
-
-
- Integer innerWidth =
- (Integer) attributes.get(Attributes.INNER_WIDTH);
- if (innerWidth != null && innerWidth.intValue() != -1) {
- int value = innerWidth.intValue();
- if (needVerticalScroolbar) {
- value -= ThemeConfig.getValue(facesContext, component, "scrollbarWidth");
- HtmlRendererUtil.replaceStyleAttribute(layout, "width", value);
- }
- layoutWidth(Integer.valueOf(value), layout, facesContext);
- }
-
- }
-
- private int getHeightSpacingSum(UIGridLayout layout,
- FacesContext facesContext, int renderedRowCount) {
- int spacingSum = getSpacingSum(layout, facesContext, renderedRowCount);
- spacingSum += getComponentExtraHeight(facesContext, layout);
- return spacingSum;
- }
-
- private void layoutWidth(Integer innerWidth, UIGridLayout layout,
- FacesContext facesContext) {
-
- final List<AbstractUIGridLayout.Row> rows = layout.ensureRows();
- //final int columnCount = layout.getColumnCount();
-
- final LayoutTokens layoutTokens = layout.getColumnLayout();
- //layoutTokens.ensureSize(columnCount, new RelativeLayoutToken(1));
-
- //LayoutInfo.createLayoutTokens((String)
- //layout.getAttributes().get(COLUMNS), columnCount);
-
- int renderedColumnCount = 0;
- if (!rows.isEmpty()) {
- AbstractUIGridLayout.Row row = rows.get(0);
- final List cells = row.getElements();
- renderedColumnCount = cells.size();
- for (int i = 0; i < cells.size(); i++) {
- Object cell = cells.get(i);
- boolean hidden = false;
- if (isHidden(cell)) {
- hidden = true;
- for (int j = 1; j < rows.size(); j++) {
- hidden &= isHidden(rows.get(j).getElements().get(i));
- }
- }
- if (hidden) {
- layoutTokens.set(i, new HideLayoutToken());
- renderedColumnCount--;
- }
- }
- }
-
- innerWidth -= getWidthSpacingSum(layout, facesContext, renderedColumnCount);
- LayoutInfo layoutInfo =
- new LayoutInfo(layoutTokens.getSize(), innerWidth.intValue(), layoutTokens, layout.getClientId(facesContext),
- layout.isIgnoreFree());
-
- parseFixedWidth(layoutInfo, layout, facesContext);
- layoutInfo.parseColumnLayout(innerWidth.doubleValue(),
- getCellSpacing(facesContext, layout));
-
- setColumnWidths(layout, layoutInfo, facesContext);
- layout.getAttributes().put(Attributes.WIDTH_LIST,
- layoutInfo.getSpaceList());
- }
-
- private boolean isHidden(Object cell) {
- return (cell instanceof UIComponent && !((UIComponent) cell).isRendered())
- || (cell instanceof UIGridLayout.Marker
- && !((UIGridLayout.Marker) cell).isRendered());
- }
-
- private void layoutHeight(Integer innerHeight, UIGridLayout layout,
- FacesContext facesContext) {
-
- final List<AbstractUIGridLayout.Row> rows = layout.ensureRows();
- LayoutTokens layoutTokens = layout.getRowLayout();
- layoutTokens.ensureSize(rows.size(), rows.size() == 1 ? new RelativeLayoutToken(1) : new FixedLayoutToken());
- /*LayoutInfo.createLayoutTokens(
- (String) layout.getAttributes().get(ROWS),
- rows.size(), rows.size() == 1 ? "1*" : "fixed");*/
-
- int renderedRowCount = rows.size();
- for (int i = 0; i < rows.size(); i++) {
- boolean hidden = true;
- AbstractUIGridLayout.Row row = rows.get(i);
- List cells = row.getElements();
- for (Object cell : cells) {
- hidden &= isHidden(cell);
- }
- row.setHidden(hidden);
- if (hidden) {
- layoutTokens.set(i, new HideLayoutToken());
- renderedRowCount--;
- }
- }
-
- innerHeight -= getHeightSpacingSum(layout, facesContext, renderedRowCount);
-
- LayoutInfo layoutInfo
- = new LayoutInfo(rows.size(), innerHeight.intValue(), layoutTokens, layout.getClientId(facesContext));
-
- if (!layoutTokens.isEmpty()) {
- parseFixedHeight(layoutInfo, layout, facesContext);
- layoutInfo.parseColumnLayout(innerHeight.doubleValue(),
- getCellSpacing(facesContext, layout));
- }
-
- setColumnHeights(layout, layoutInfo, facesContext);
-
- }
-
- private void parseFixedWidth(LayoutInfo layoutInfo, UIGridLayout layout,
- FacesContext facesContext) {
- parseFixedSpace(layoutInfo, layout, true, facesContext);
- }
- private void parseFixedHeight(LayoutInfo layoutInfo, UIGridLayout layout,
- FacesContext facesContext) {
- parseFixedSpace(layoutInfo, layout, false, facesContext);
- }
-
- public void parseFixedSpace(LayoutInfo layoutInfo, UIGridLayout layout,
- LayoutTokens layoutTokens, boolean width, FacesContext facesContext) {
-
- //String[] tokens = layoutInfo.getLayoutTokens();
- for (int i = 0; i < layoutTokens.getSize(); i++) {
- LayoutToken token = layoutTokens.get(i);
- if (token instanceof FixedLayoutToken) {
- int max = 0;
- final List<AbstractUIGridLayout.Row> rows = layout.ensureRows();
- if (!rows.isEmpty()) {
- if (width) {
- max = getMaxWidth(facesContext, rows, i, false);
- } else {
- if (i < rows.size()) { //
- AbstractUIGridLayout.Row row = rows.get(i);
- max = getMaxHeight(facesContext, row, false);
- } else {
- layoutInfo.update(0, i);
- if (LOG.isWarnEnabled()) {
- LOG.warn("More LayoutTokens found than rows! skipping! tokens = "
- + token + " components = "
- + rows.size());
- }
- }
- }
- layoutInfo.update(max, i);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("set column " + i + " from fixed to with " + max);
- }
- }
- }
- }
- private void parseFixedSpace(LayoutInfo layoutInfo, UIGridLayout layout,
- boolean width, FacesContext facesContext) {
-
- LayoutTokens tokens = layoutInfo.getLayoutTokens();
- for (int i = 0; i < tokens.getSize(); i++) {
- LayoutToken token = tokens.get(i);
- if (token instanceof FixedLayoutToken) {
- int max = 0;
- final List<AbstractUIGridLayout.Row> rows = layout.ensureRows();
- if (!rows.isEmpty()) {
- if (width) {
- max = getMaxWidth(facesContext, rows, i, false);
- } else {
- if (i < rows.size()) { //
- AbstractUIGridLayout.Row row = rows.get(i);
- max = getMaxHeight(facesContext, row, false);
- } else {
- layoutInfo.update(0, i);
- if (LOG.isWarnEnabled()) {
- LOG.warn("More LayoutTokens found than rows! skipping! tokens = "
- + token + " components = "
- + rows.size());
- }
- }
- }
- layoutInfo.update(max, i);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("set column " + i + " from fixed to with " + max);
- }
- }
- }
- }
-
- private int getMaxHeight(FacesContext facesContext, UIGridLayout.Row row, boolean minimum) {
- int maxHeight = 0;
- List cells = row.getElements();
- for (Object cell : cells) {
- if (cell instanceof UIComponent) {
- UIComponent component = (UIComponent) cell;
- int height = -1;
- if (minimum) {
- height = (int) LayoutUtils.getMinimumHeight(facesContext, component);
- } else {
- LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, component);
- if (renderer != null) {
- height = renderer.getFixedHeight(facesContext, component);
- }
- }
- maxHeight = Math.max(maxHeight, height);
- } else if (cell instanceof UIGridLayout.Marker) {
- // ignore
- } else {
- // TODO is this needed?
- LOG.error("Object is not instanceof UIComponent " + cell.getClass().getName());
- }
- }
- return maxHeight;
- }
-
- private int getMaxWidth(FacesContext facesContext, List<UIGridLayout.Row> rows, int column, boolean minimum) {
- int maxWidth = 0;
-
- for (AbstractUIGridLayout.Row row : rows) {
- if (column < row.getElements().size()) {
- Object object = row.getElements().get(column);
-
- if (object instanceof UIComponent) {
- UIComponent component = (UIComponent) object;
- if (component instanceof UICell) {
- if (((UICell) component).getSpanX() > 1) {
- continue;
- }
- }
- int max = -1;
- if (minimum) {
- max = (int) LayoutUtils.getMinimumWidth(facesContext, component);
- } else {
- LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, component);
- if (renderer != null) {
- max = renderer.getFixedWidth(facesContext, component);
- }
- }
- maxWidth = Math.max(maxWidth, max);
- } else if (object instanceof UIGridLayout.Marker) {
- // ignore
- } else {
- // TODO is this needed?
- LOG.error("Object is not instanceof UIComponent " + object.getClass().getName());
- }
- }
- }
- return maxWidth;
- }
-
- private void setColumnWidths(UIGridLayout layout, LayoutInfo layoutInfo,
- FacesContext facesContext) {
- List<AbstractUIGridLayout.Row> rows = layout.ensureRows();
-
- for (Iterator iter = rows.iterator(); iter.hasNext();) {
- AbstractUIGridLayout.Row row = (UIGridLayout.Row) iter.next();
- List cells = row.getElements();
- int columnCount = layout.getColumnCount();
- for (int i = 0; i < columnCount; i++) {
- if (cells.get(i) instanceof UIComponent) {
- UIComponent cell = (UIComponent) cells.get(i);
- int spanX = UIGridLayout.getSpanX(cell);
- int cellWidth = 0;
- for (int j = i; j < i + spanX; j++) {
- cellWidth += layoutInfo.getSpaceForColumn(j);
- }
- if (spanX > 1 && getBorder(layout) > 0) {
- cellWidth += ((spanX - 1) * 2);
- }
- cellWidth += (spanX - 1) * getCellSpacing(facesContext, layout);
- LayoutUtils.maybeSetLayoutAttribute(cell,
- Attributes.LAYOUT_WIDTH, Integer.valueOf(cellWidth));
- }
- }
- }
- }
-
- private void setColumnHeights(UIGridLayout layout, LayoutInfo layoutInfo,
- FacesContext facesContext) {
- List<AbstractUIGridLayout.Row> rows = layout.ensureRows();
-
- for (int i = 0; i < rows.size(); i++) {
- AbstractUIGridLayout.Row row = rows.get(i);
- List cells = row.getElements();
- int columnCount = layout.getColumnCount();
- for (int j = 0; j < columnCount; j++) {
- if (cells.get(j) instanceof UIComponent) {
- UIComponent cell = (UIComponent) cells.get(j);
- int spanY = UIGridLayout.getSpanY(cell);
- int cellHeight = 0;
- for (int k = i; k < i + spanY; k++) {
- cellHeight += layoutInfo.getSpaceForColumn(k);
- }
- if (spanY > 1 && getBorder(layout) > 0) {
- cellHeight += ((spanY - 1) * 2);
- }
- cellHeight += (spanY - 1) * getCellSpacing(facesContext, layout);
- if (LOG.isDebugEnabled()) {
- LOG.debug("set height of " + cellHeight + "px to "
- + cell.getRendererType() + " layoutInfo " + layoutInfo.toString());
- }
- cell.getAttributes().put(Attributes.LAYOUT_HEIGHT, Integer.valueOf(cellHeight));
- cell.getAttributes().remove(Attributes.INNER_HEIGHT);
- if (cell instanceof UICell || cell instanceof AbstractUIForm) {
- List children = LayoutUtils.addChildren(new ArrayList<UIComponent>(), cell);
- for (Iterator childs = children.iterator(); childs.hasNext();) {
- UIComponent component = (UIComponent) childs.next();
- if (LOG.isDebugEnabled()) {
- LOG.debug("set height of " + cellHeight + "px to "
- + component.getRendererType());
- }
- component.getAttributes().put(Attributes.LAYOUT_HEIGHT, Integer.valueOf(cellHeight));
- component.getAttributes().remove(Attributes.INNER_HEIGHT);
-
- }
- }
- }
- }
- }
- }
-
-
- public void layoutBegin(FacesContext facesContext, UIComponent component) {
- if (LOG.isInfoEnabled()) {
- LOG.info("############################## layoutBegin +++++++++++++++++++++++++++++++++++++++++");
- }
- HtmlRendererUtil.layoutSpace(facesContext, component, true);
- HtmlRendererUtil.layoutSpace(facesContext, component, false);
-
- if (component instanceof UIGridLayout) {
- layoutMargins((UIGridLayout) component);
- }
- }
-
- private void layoutMargins(UIGridLayout layout) {
-
- HtmlStyleMap style = (HtmlStyleMap) layout.getAttributes().get(Attributes.STYLE);
-
- if (style != null) {
- int marginTop = getMarginAsInt(layout.getMarginTop());
- int marginRight = getMarginAsInt(layout.getMarginRight());
- int marginBottom = getMarginAsInt(layout.getMarginBottom());
- int marginLeft = getMarginAsInt(layout.getMarginLeft());
- if(marginTop > 0) {
- style.put("margin-top", marginTop);
- }
- if(marginRight > 0) {
- style.put("margin-right", marginRight);
- Integer width = style.getInt("width");
- if (width != null) {
- width -= marginRight;
- style.put("width", width);
- }
- }
- if(marginBottom > 0) {
- style.put("margin-bottom", marginBottom);
- }
- if(marginLeft > 0) {
- style.put("margin-left", marginLeft);
- Integer width = style.getInt("width");
- if (width != null) {
- width -= marginLeft;
- style.put("width", width);
- }
- }
-
- //layout.getAttributes().put(ATTR_LAYOUT_TABLE_STYLE, style);
- }
- }
-
- public int getComponentExtraWidth(FacesContext facesContext,
- UIComponent component) {
- int extra = 0;
- UIGridLayout layout = (UIGridLayout) component;
-
- extra += getMarginAsInt(layout.getMarginRight());
- extra += getMarginAsInt(layout.getMarginLeft());
-
- return extra;
- }
-
- public int getComponentExtraHeight(FacesContext facesContext,
- UIComponent component) {
- int extra = 0;
- UIGridLayout layout = (UIGridLayout) component;
-
- extra += getMarginAsInt(layout.getMarginTop());
- extra += getMarginAsInt(layout.getMarginBottom());
- return extra;
- }
-
- private int getMarginAsInt(String margin) {
- if (margin != null) {
- margin = removePx(margin);
- try {
- return Integer.parseInt(margin);
- } catch (NumberFormatException e) {
- if (LOG.isWarnEnabled()) {
- LOG.warn("Illegal Margin : " + margin
- + " exception : " + e.getMessage(), e);
- }
- }
- }
- return 0;
- }
-
- private String removePx(String margin) {
- if (margin!=null&&margin.endsWith("px")) {
- margin = margin.substring(0, margin.length() - 2);
- }
- return margin;
- }
}
-
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessageRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessageRenderer.java Thu Jul 23 07:23:23 2009
@@ -25,7 +25,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.config.ThemeConfig;
import org.apache.myfaces.tobago.renderkit.MessageRendererBase;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -48,24 +47,6 @@
private static final Log LOG = LogFactory.getLog(MessageRenderer.class);
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("component = '" + component + "'");
- }
- String clientId = null;
- if (component instanceof UIMessage) {
- clientId = ComponentUtil.findClientIdFor(component, facesContext);
- }
- int count = 0;
- for (Iterator i = facesContext.getMessages(clientId); i.hasNext(); i.next()) {
- count++;
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("here are " + count + " messages");
- }
- return count * ThemeConfig.getValue(facesContext, component, "messageHeight");
- }
-
public void encodeEnd(FacesContext facesContext,
UIComponent uiComponent) throws IOException {
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java Thu Jul 23 07:23:23 2009
@@ -37,7 +37,6 @@
import org.apache.myfaces.tobago.component.UIMessages;
import org.apache.myfaces.tobago.component.UIPanel;
import org.apache.myfaces.tobago.component.UIPopup;
-import org.apache.myfaces.tobago.config.ThemeConfig;
import org.apache.myfaces.tobago.context.ResourceManagerUtil;
import org.apache.myfaces.tobago.context.TobagoFacesContext;
import org.apache.myfaces.tobago.layout.PixelMeasure;
@@ -64,21 +63,6 @@
public static final String CLOSE_POPUP = "closePopup";
@Override
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
- int count = 0;
- for (Iterator i = facesContext.getMessages(); i.hasNext(); i.next()) {
- count++;
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("component = '" + component + "'");
- LOG.debug("here are " + count + " messages");
- }
- return (count > 0)
- ? count * ThemeConfig.getValue(facesContext, component, "messageHeight")
- : ThemeConfig.getValue(facesContext, component, "fixedHeight");
- }
-
- @Override
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
UIMessages messages = (UIMessages) component;
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java Thu Jul 23 07:23:23 2009
@@ -26,21 +26,17 @@
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
-import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.component.UIPanel;
import org.apache.myfaces.tobago.component.UIReload;
import org.apache.myfaces.tobago.config.TobagoConfig;
-import org.apache.myfaces.tobago.renderkit.LayoutInformationProvider;
import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtil;
import org.apache.myfaces.tobago.renderkit.util.RenderUtil;
-import org.apache.myfaces.tobago.util.ComponentUtil;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import javax.faces.component.UIComponent;
-import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import java.io.IOException;
@@ -61,66 +57,6 @@
}
@Override
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
- // wenn hoehe gesetzt dann diese,
- // sonst wenn layout vorhanden dieses fragen:
- // -> aus rowLayout berechnen
- // sonst Warnung ausgebenn und addition der children's fixedHeight
-
- int height =
- ComponentUtil.getIntAttribute(component, Attributes.HEIGHT, -1);
-
- if (height == -1) {
- height = getFixedHeightForPanel(component, facesContext);
- }
- return height;
- }
-
- public static int getFixedHeightForPanel(UIComponent component, FacesContext facesContext) {
- int height = -1;
- // first ask layoutManager
- UIComponent layout = component.getFacet(Facets.LAYOUT);
- if (layout != null) {
- LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, layout);
- height = renderer.getFixedHeight(facesContext, component);
- }
- if (height < 0) {
-
- if (component.getChildren().size() == 0) {
- height = 0;
- } else {
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Can't calculate fixedHeight! "
- + "using estimation by contained components. for "
- + component.getClientId(facesContext) + " = "
- + component.getClass().getName() + " "
- + component.getRendererType());
- }
-
- height = 0;
- for (Object o : component.getChildren()) {
- UIComponent child = (UIComponent) o;
- LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, child);
- if (renderer == null
- && child instanceof UINamingContainer
- && child.getChildren().size() > 0) {
- // this is a subview component ??
- renderer = ComponentUtil.getRenderer(facesContext, (UIComponent) child.getChildren().get(0));
- }
- if (renderer != null) {
- int h = renderer.getFixedHeight(facesContext, child);
- if (h > 0) {
- height += h;
- }
- }
- }
- }
- }
- return height;
- }
-
- @Override
public void encodeChildren(FacesContext facesContext, UIComponent uiComponent) throws IOException {
UIPanel component = (UIPanel) uiComponent;
for (Object o : component.getChildren()) {
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java Thu Jul 23 07:23:23 2009
@@ -33,7 +33,6 @@
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtil;
-import org.apache.myfaces.tobago.util.LayoutUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import javax.faces.component.UIComponent;
@@ -69,7 +68,8 @@
/ (model.getMaximum() - model.getMinimum())) + " %";
}
- Integer width = LayoutUtils.getLayoutWidth(component);
+ Integer width = 100; // FIXME: make dynamic (was removed by changing the layouting
+ LOG.error("100; // FIXME: make dynamic (was removed by changing the layouting");
String width1 = value1;
String width2 = value2;
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectManyCheckboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectManyCheckboxRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectManyCheckboxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectManyCheckboxRenderer.java Thu Jul 23 07:23:23 2009
@@ -161,22 +161,4 @@
HtmlRendererUtil.renderFocusId(facesContext, selectMany);
HtmlRendererUtil.checkForCommandFacet(selectMany, clientIds, facesContext, writer);
}
-
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
- if (!(component instanceof UISelectManyCheckbox)) {
- LOG.error("Wrong type: Need " + UISelectManyCheckbox.class.getName() + ", but was "
- + component.getClass().getName());
- return 100;
- }
-
- UISelectManyCheckbox selectMany = (UISelectManyCheckbox) component;
-
- int heightPerRow = super.getFixedHeight(facesContext, selectMany);
- if (ComponentUtil.getBooleanAttribute(selectMany, Attributes.INLINE)) {
- return heightPerRow;
- } else {
- List<SelectItem> items = RenderUtil.getItemsToRender(selectMany);
- return items.size() * heightPerRow;
- }
- }
}
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectManyListboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectManyListboxRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectManyListboxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectManyListboxRenderer.java Thu Jul 23 07:23:23 2009
@@ -26,7 +26,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.UISelectManyListbox;
-import org.apache.myfaces.tobago.config.ThemeConfig;
import org.apache.myfaces.tobago.renderkit.SelectManyRendererBase;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -50,31 +49,6 @@
return true;
}
- public int getComponentExtraWidth(FacesContext facesContext, UIComponent component) {
- return 0;
- }
-
- public int getLabelWidth(FacesContext facesContext, UIComponent component) {
- return ThemeConfig.getValue(facesContext, component, "labelWidth");
- }
-
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
- int fixedHeight = -1;
- String height = (String) component.getAttributes().get(Attributes.HEIGHT);
- if (height != null) {
- try {
- fixedHeight = Integer.parseInt(height.replaceAll("\\D", ""));
- } catch (NumberFormatException e) {
- LOG.warn("Can't parse " + height + " to int");
- }
- }
-
- if (fixedHeight == -1) {
- fixedHeight = super.getFixedHeight(facesContext, component);
- }
- return fixedHeight;
- }
-
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
if (!(component instanceof UISelectManyListbox)) {
LOG.error("Wrong type: Need " + UISelectManyListbox.class.getName() + ", but was "
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneChoiceRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneChoiceRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneChoiceRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneChoiceRenderer.java Thu Jul 23 07:23:23 2009
@@ -96,8 +96,4 @@
HtmlRendererUtil.renderFocusId(facesContext, selectOne);
HtmlRendererUtil.checkForCommandFacet(selectOne, facesContext, writer);
}
-
- public int getComponentExtraWidth(FacesContext facesContext, UIComponent component) {
- return 0;
- }
}
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneListboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneListboxRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneListboxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneListboxRenderer.java Thu Jul 23 07:23:23 2009
@@ -48,27 +48,6 @@
return true;
}
- public int getComponentExtraWidth(FacesContext facesContext, UIComponent component) {
- return 0;
- }
-
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
- int fixedHeight = -1;
- String height = (String) component.getAttributes().get(Attributes.HEIGHT);
- if (height != null) {
- try {
- fixedHeight = Integer.parseInt(height.replaceAll("\\D", ""));
- } catch (NumberFormatException e) {
- LOG.warn("Can't parse " + height + " to int");
- }
- }
-
- if (fixedHeight == -1) {
- fixedHeight = super.getFixedHeight(facesContext, component);
- }
- return fixedHeight;
- }
-
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
if (!(component instanceof UISelectOneListbox)) {
LOG.error("Wrong type: Need " + UISelectOneListbox.class.getName() + ", but was "
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneRadioRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneRadioRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneRadioRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneRadioRenderer.java Thu Jul 23 07:23:23 2009
@@ -189,15 +189,4 @@
HtmlRendererUtil.checkForCommandFacet(selectOne, clientIds, facesContext, writer);
}
-
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
- int heightPerRow = super.getFixedHeight(facesContext, component);
- if (ComponentUtil.getBooleanAttribute(component, Attributes.INLINE)) {
- return heightPerRow;
- } else {
- List<SelectItem> items = RenderUtil.getItemsToRender((UISelectOneRadio) component);
- return items.size() * heightPerRow;
- }
- }
-
}
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Thu Jul 23 07:23:23 2009
@@ -35,7 +35,6 @@
import org.apache.myfaces.tobago.component.UICommand;
import org.apache.myfaces.tobago.component.UIData;
import static org.apache.myfaces.tobago.component.UIData.NONE;
-import org.apache.myfaces.tobago.component.UILayout;
import org.apache.myfaces.tobago.component.UIMenu;
import org.apache.myfaces.tobago.component.UIMenuCommand;
import org.apache.myfaces.tobago.component.UIReload;
@@ -51,7 +50,6 @@
import org.apache.myfaces.tobago.layout.LayoutTokens;
import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
import org.apache.myfaces.tobago.model.SheetState;
-import org.apache.myfaces.tobago.renderkit.LayoutInformationProvider;
import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -62,7 +60,6 @@
import org.apache.myfaces.tobago.renderkit.util.RenderUtil;
import org.apache.myfaces.tobago.util.ComponentUtil;
import org.apache.myfaces.tobago.util.LayoutInfo;
-import org.apache.myfaces.tobago.util.LayoutUtils;
import org.apache.myfaces.tobago.util.StringUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
@@ -648,10 +645,10 @@
if (height != null) {
int first = data.getFirst();
int rows = Math.min(data.getRowCount(), first + data.getRows()) - first;
- int heightNeeded = getHeaderHeight(facesContext, data)
+ LOG.error("20; // FIXME: make dynamic (was removed by changing the layouting");
+ int heightNeeded = 20 // FIXME: make dynamic (was removed by changing the layouting
+ getFooterHeight(facesContext, data)
- + (rows * (getFixedHeight(facesContext, null)
- + getRowPadding(facesContext, data)));
+ + (rows * (20 /* FIXME */ + getRowPadding(facesContext, data)));
return heightNeeded > height;
} else {
@@ -1115,50 +1112,12 @@
renderSheet(facesContext, (UIData) component, (clickAction != null || dblClickAction != null));
}
- @Override
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
-
- // todo: why this will be called?
- if (component == null) {
- return 0;
- }
-
- UIData data = (UIData) component;
-
-// int headerHeight = getConfiguredValue(facesContext, component, "headerHeight");
-// int footerHeight = getConfiguredValue(facesContext, component, "footerHeight");
- int headerHeight = getHeaderHeight(facesContext, component);
- int footerHeight = getFooterHeight(facesContext, component);
-
- int rowHeight = ThemeConfig.getValue(facesContext, component, "rowHeight");
-
- int rows = data.getRows();
-
- if (LOG.isInfoEnabled()) {
- LOG.info(headerHeight + " " + footerHeight + " " + rowHeight + " " + rows);
- }
-
- return headerHeight + rows * rowHeight + footerHeight + 2; // XXX hotfix: + 1
- }
-
public void encodeChildren(FacesContext context,
UIComponent component)
throws IOException {
// DO Nothing
}
- public void layoutBegin(FacesContext context, UIComponent component) throws IOException {
- UILayout.prepareDimension(context, component);
- }
-
- public void layoutEnd(FacesContext context, UIComponent component) throws IOException {
- if (component instanceof UIData) {
- UIData data = (UIData) component;
- ensureColumnWidthList(context, data);
- prepareDimensions(context, data);
- }
- }
-
private void ensureColumnWidthList(FacesContext facesContext, UIData data) {
List<Integer> currentWidthList = null;
List<UIColumn> rendererdColumns = data.getRenderedColumns();
@@ -1208,7 +1167,8 @@
}
- int space = LayoutUtils.getInnerSpace(facesContext, data, true);
+ int space = 100; // FIXME: make dynamic (was removed by changing the layouting
+ LOG.error("100; // FIXME: make dynamic (was removed by changing the layouting");
space -= getContentBorder(facesContext, data);
if (needVerticalScrollbar(facesContext, data)) {
space -= getScrollbarWidth(facesContext, data);
@@ -1241,20 +1201,13 @@
if (i < rendereredColumns.size()) {
UIColumn column = rendereredColumns.get(i);
if (column instanceof UIColumnSelector) {
- LayoutInformationProvider renderer
- = ComponentUtil.getRenderer(facesContext, column);
- if (renderer == null) {
- LOG.warn("can't find renderer for " + column.getClass().getName());
- renderer = ComponentUtil.getRenderer(facesContext,
- org.apache.myfaces.tobago.component.UIPanel.COMPONENT_FAMILY, RendererTypes.OUT);
- }
- width = renderer.getFixedWidth(facesContext, column);
+ width = 100; // FIXME: make dynamic (was removed by changing the layouting
+ LOG.error("100; // FIXME: make dynamic (was removed by changing the layouting");
} else {
for (UIComponent component : (List<UIComponent>) column.getChildren()) {
- LayoutInformationProvider renderer
- = ComponentUtil.getRenderer(facesContext, component);
- width += renderer.getFixedWidth(facesContext, component);
+ width += 100; // FIXME: make dynamic (was removed by changing the layouting
+ LOG.error("100; // FIXME: make dynamic (was removed by changing the layouting");
}
}
layoutInfo.update(width, i);
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java Thu Jul 23 07:23:23 2009
@@ -42,7 +42,6 @@
import org.apache.myfaces.tobago.context.TobagoFacesContext;
import org.apache.myfaces.tobago.event.TabChangeEvent;
import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
-import org.apache.myfaces.tobago.renderkit.LayoutInformationProvider;
import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -107,7 +106,7 @@
HtmlRendererUtil.createHeaderAndBodyStyles(facesContext, component);
- layoutTabs(facesContext, component);
+// layoutTabs(facesContext, component);
int activeIndex = ensureRenderedActiveIndex(facesContext, component);
@@ -537,47 +536,6 @@
ThemeConfig.getValue(context, component, "navigationBarWidth"), currentWidth, tabList);
}
- public int getFixedHeight(FacesContext facesContext, UIComponent uiComponent) {
- UITabGroup component = (UITabGroup) uiComponent;
- int height =
- ComponentUtil.getIntAttribute(component, Attributes.HEIGHT, -1);
-
- int fixedHeight;
- if (height != -1) {
- fixedHeight = height;
- } else {
- fixedHeight = 0;
- for (UIComponent tab : (List<UIComponent>) component.getChildren()) {
- if (tab instanceof UIPanelBase && tab.isRendered()) {
- LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, tab);
- fixedHeight
- = Math.max(fixedHeight, renderer.getFixedHeight(facesContext, tab));
- }
- }
- fixedHeight += ThemeConfig.getValue(facesContext, component, "headerHeight");
- fixedHeight += ThemeConfig.getValue(facesContext, component, "paddingHeight");
- }
- return fixedHeight;
- }
-
- private void layoutTabs(FacesContext facesContext, UITabGroup component) {
- Object layoutWidth =
- component.getAttributes().get(Attributes.LAYOUT_WIDTH);
- Object layoutHeight =
- component.getAttributes().get(Attributes.LAYOUT_HEIGHT);
-
- for (UIComponent tab : (List<UIComponent>) component.getChildren()) {
- if (tab instanceof UIPanelBase && tab.isRendered()) {
- if (layoutWidth != null) {
- HtmlRendererUtil.layoutSpace(facesContext, tab, true);
- }
- if (layoutHeight != null) {
- HtmlRendererUtil.layoutSpace(facesContext, tab, false);
- }
- }
- }
- }
-
private static class TabList {
private List<Integer> widthList = new ArrayList<Integer>();
private int firstIndex;
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabRenderer.java Thu Jul 23 07:23:23 2009
@@ -17,35 +17,12 @@
* limitations under the License.
*/
-/*
- * Created 07.02.2003 16:00:00.
- * $Id$
- */
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.config.ThemeConfig;
import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
-import org.apache.myfaces.tobago.util.ComponentUtil;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
public class TabRenderer extends LayoutableRendererBase {
private static final Log LOG = LogFactory.getLog(TabRenderer.class);
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
-
- int height =
- ComponentUtil.getIntAttribute(component, Attributes.HEIGHT, -1);
-
- if (height == -1) {
- height = PanelRenderer.getFixedHeightForPanel(component, facesContext);
- height += ThemeConfig.getValue(facesContext, component, "paddingHeight");
- }
- return height;
- }
-
}
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java Thu Jul 23 07:23:23 2009
@@ -42,7 +42,6 @@
UIPanel toolbar = (UIPanel) uiComponent;
TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
- setToolBarHeight(facesContext, uiComponent);
writer.startElement(HtmlConstants.DIV, toolbar);
writer.writeIdAttribute(toolbar.getClientId(facesContext));
@@ -63,11 +62,6 @@
writer.endElement(HtmlConstants.DIV);
}
- private void setToolBarHeight(FacesContext facesContext, UIComponent component) {
- final int height = getFixedHeight(facesContext, component);
- HtmlRendererUtil.replaceStyleAttribute(component, "height", height);
- }
-
protected String getHoverClasses(boolean first, boolean last) {
return "tobago-toolBar-button-hover" + (first ? " tobago-toolBar-button-hover-first" : "");
}
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java Thu Jul 23 07:23:23 2009
@@ -30,7 +30,6 @@
import org.apache.myfaces.tobago.component.UISelectBooleanCommand;
import org.apache.myfaces.tobago.component.UISelectOneCommand;
import org.apache.myfaces.tobago.component.UIToolBar;
-import org.apache.myfaces.tobago.config.ThemeConfig;
import org.apache.myfaces.tobago.context.ResourceManager;
import org.apache.myfaces.tobago.context.ResourceManagerFactory;
import org.apache.myfaces.tobago.context.ResourceManagerUtil;
@@ -56,7 +55,6 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
public abstract class ToolBarRendererBase extends LayoutableRendererBase {
@@ -479,14 +477,6 @@
writer.endElement(HtmlConstants.TD);
}
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
- final Map attributes = component.getAttributes();
- final String labelPosition = getLabelPosition(component);
- final String iconSize = getIconSize(component);
- final String key = iconSize + "_" + labelPosition + "_Height";
- return ThemeConfig.getValue(facesContext, component, key);
- }
-
public void encodeChildren(FacesContext facesContext, UIComponent component)
throws IOException {
}
Modified: myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java Thu Jul 23 07:23:23 2009
@@ -58,11 +58,6 @@
}
@Override
- public int getFixedHeight(FacesContext facesContext, UIComponent component) {
- return super.getFixedHeight(facesContext, component);
- }
-
- @Override
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
Modified: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java Thu Jul 23 07:23:23 2009
@@ -22,8 +22,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.component.Facets;
-import org.apache.myfaces.tobago.component.RendererTypes;
import org.apache.myfaces.tobago.component.SupportsMarkup;
import org.apache.myfaces.tobago.component.UICommand;
import org.apache.myfaces.tobago.component.UIData;
@@ -31,16 +29,13 @@
import org.apache.myfaces.tobago.context.ResourceManagerUtil;
import org.apache.myfaces.tobago.context.TobagoFacesContext;
import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
-import org.apache.myfaces.tobago.renderkit.LayoutInformationProvider;
import org.apache.myfaces.tobago.renderkit.LayoutableRenderer;
-import org.apache.myfaces.tobago.renderkit.RendererBaseWrapper;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
import org.apache.myfaces.tobago.renderkit.html.HtmlStyleMap;
import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
import org.apache.myfaces.tobago.renderkit.util.RenderUtil;
import org.apache.myfaces.tobago.util.ComponentUtil;
-import org.apache.myfaces.tobago.util.LayoutUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseJsonWriterImpl;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriterWrapper;
@@ -57,7 +52,6 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.StringTokenizer;
/*
* User: weber
@@ -113,16 +107,6 @@
}
}
- public static void prepareRender(FacesContext facesContext, UIComponent component) {
- // xxx find a better way for this question: isTobago or isLayoutable something like that.
- LayoutableRenderer layoutRenderer = ComponentUtil.getRenderer(facesContext, component);
- if (layoutRenderer != null && !(layoutRenderer instanceof RendererBaseWrapper)) {
- createCssClass(facesContext, component);
- layoutWidth(facesContext, component);
- layoutHeight(facesContext, component);
- }
- }
-
public static HtmlStyleMap prepareInnerStyle(UIComponent component) {
HtmlStyleMap htmlStyleMap = new HtmlStyleMap();
Integer innerSpaceInteger = (Integer)
@@ -229,23 +213,6 @@
return buffer.toString();
}
- public static String getLayoutSpaceStyle(UIComponent component) {
- StringBuilder sb = new StringBuilder();
- Integer space = LayoutUtils.getLayoutSpace(component, Attributes.LAYOUT_WIDTH, Attributes.LAYOUT_WIDTH);
- if (space != null) {
- sb.append(" width: ");
- sb.append(space);
- sb.append("px;");
- }
- space = LayoutUtils.getLayoutSpace(component, Attributes.LAYOUT_HEIGHT, Attributes.LAYOUT_HEIGHT);
- if (space != null) {
- sb.append(" height: ");
- sb.append(space);
- sb.append("px;");
- }
- return sb.toString();
- }
-
public static Integer getStyleAttributeIntValue(HtmlStyleMap style, String name) {
if (style == null) {
return null;
@@ -253,22 +220,6 @@
return style.getInt(name);
}
- public static String getStyleAttributeValue(String style, String name) {
- if (style == null) {
- return null;
- }
- String value = null;
- StringTokenizer st = new StringTokenizer(style, ";");
- while (st.hasMoreTokens()) {
- String attribute = st.nextToken().trim();
- if (attribute.startsWith(name)) {
- value = attribute.substring(attribute.indexOf(':') + 1).trim();
- }
- }
- return value;
- }
-
-
public static void replaceStyleAttribute(UIComponent component, String styleAttribute, String value) {
HtmlStyleMap style = ensureStyleAttributeMap(component);
style.put(styleAttribute, value);
@@ -332,80 +283,12 @@
StyleClasses.ensureStyleClasses(component).addFullQualifiedClass(clazz);
}
- public static void layoutWidth(FacesContext facesContext, UIComponent component) {
- layoutSpace(facesContext, component, true);
- }
-
- public static void layoutHeight(FacesContext facesContext, UIComponent component) {
- layoutSpace(facesContext, component, false);
- }
-
- public static void layoutSpace(FacesContext facesContext, UIComponent component,
- boolean width) {
-
- // prepare html 'style' attribute
- Integer layoutSpace;
- String layoutAttribute;
- String styleAttribute;
- if (width) {
- layoutSpace = LayoutUtils.getLayoutWidth(component);
- layoutAttribute = Attributes.LAYOUT_WIDTH;
- styleAttribute = HtmlAttributes.WIDTH;
- } else {
- layoutSpace = LayoutUtils.getLayoutHeight(component);
- layoutAttribute = Attributes.LAYOUT_HEIGHT;
- styleAttribute = HtmlAttributes.HEIGHT;
- }
- int space = -1;
- if (layoutSpace != null) {
- space = layoutSpace.intValue();
- }
- if (space == -1 && (!RendererTypes.OUT.equals(component.getRendererType()))) {
- UIComponent parent = component.getParent();
- space = LayoutUtils.getInnerSpace(facesContext, parent, width);
- if (space > 0 && !ComponentUtil.isFacetOf(component, parent)) {
- component.getAttributes().put(layoutAttribute, Integer.valueOf(space));
- if (width) {
- component.getAttributes().remove(Attributes.INNER_WIDTH);
- } else {
- component.getAttributes().remove(Attributes.INNER_HEIGHT);
- }
- }
- }
- if (space > 0) {
- LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, component);
- if (layoutSpace != null
- || !ComponentUtil.getBooleanAttribute(component, Attributes.INLINE)) {
- int styleSpace = space;
- if (renderer != null) {
- if (width) {
- styleSpace -= renderer.getComponentExtraWidth(facesContext, component);
- } else {
- styleSpace -= renderer.getComponentExtraHeight(facesContext, component);
- }
- }
-
- replaceStyleAttribute(component, styleAttribute, styleSpace);
-
- }
- UIComponent layout = component.getFacet(Facets.LAYOUT);
- if (layout != null) {
- int layoutSpace2 = LayoutUtils.getInnerSpace(facesContext, component,
- width);
- if (layoutSpace2 > 0) {
- layout.getAttributes().put(layoutAttribute, Integer.valueOf(layoutSpace2));
- }
- }
- }
- }
-
public static void createHeaderAndBodyStyles(FacesContext facesContext, UIComponent component) {
createHeaderAndBodyStyles(facesContext, component, true);
createHeaderAndBodyStyles(facesContext, component, false);
}
public static void createHeaderAndBodyStyles(FacesContext facesContext, UIComponent component, boolean width) {
- LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, component);
HtmlStyleMap style = (HtmlStyleMap) component.getAttributes().get(Attributes.STYLE);
Integer styleSpace = null;
try {
@@ -417,9 +300,8 @@
int bodySpace = 0;
int headerSpace = 0;
if (!width) {
- if (renderer != null) {
- headerSpace = renderer.getHeaderHeight(facesContext, component);
- }
+ headerSpace = 20; // FIXME: make dynamic (was removed by changing the layouting
+ LOG.error("20; // FIXME: make dynamic (was removed by changing the layouting");
bodySpace = styleSpace - headerSpace;
}
HtmlStyleMap headerStyle = ensureStyleAttributeMap(component, Attributes.STYLE_HEADER);
Modified: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java?rev=796969&r1=796968&r2=796969&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java Thu Jul 23 07:23:23 2009
@@ -20,7 +20,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.component.UILayout;
import org.apache.myfaces.tobago.config.ThemeConfig;
import org.apache.myfaces.tobago.context.ResourceManagerUtil;
import org.apache.myfaces.tobago.renderkit.RendererBase;
@@ -66,15 +65,19 @@
UIComponent panel)
throws IOException {
// UIComponent layout = panel.getFacet("layout");
- UILayout layout = UILayout.getLayout(panel);
- if (layout != null) {
- layout.encodeChildrenOfComponent(facesContext, panel);
- } else {
- for (Object o : panel.getChildren()) {
- UIComponent child = (UIComponent) o;
- encode(facesContext, child);
- }
- }
+
+ encodeChildrenWithoutLayout(facesContext, panel);
+ // XXX is the following coded needed?
+
+// UILayout layout = UILayout.getLayout(panel);
+// if (layout != null) {
+// layout.encodeChildrenOfComponent(facesContext, panel);
+// } else {
+// for (Object o : panel.getChildren()) {
+// UIComponent child = (UIComponent) o;
+// encode(facesContext, child);
+// }
+// }
}
public static void encodeChildrenWithoutLayout(FacesContext facesContext, UIComponent container) throws IOException {