Examples of UIGridLayout


Examples of org.apache.myfaces.tobago.component.UIGridLayout

  private 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(ATTR_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);
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIGridLayout

  }

  public int getComponentExtraWidth(FacesContext facesContext,
      UIComponent component) {
    int extra = 0;
    UIGridLayout layout = (UIGridLayout) component;

    extra += getMarginAsInt(layout.getMarginRight());
    extra += getMarginAsInt(layout.getMarginLeft());

    return extra;
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIGridLayout

  }

  public int getComponentExtraHeight(FacesContext facesContext,
      UIComponent component) {
    int extra = 0;
    UIGridLayout layout = (UIGridLayout) component;

    extra += getMarginAsInt(layout.getMarginTop());
    extra += getMarginAsInt(layout.getMarginBottom());
    return extra;
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIGridLayout

    return false;
  }

  private void addGridLayout(FaceletContext faceletContext, UIComponent panel, UIViewRoot root) {
    Application application = faceletContext.getFacesContext().getApplication();
    UIGridLayout gridLayout = (UIGridLayout) application.createComponent(UIGridLayout.COMPONENT_TYPE);
    gridLayout.setRendererType(TobagoConstants.RENDERER_TYPE_GRID_LAYOUT);
    if (labelWidthAttribute != null) {
      String columns = getColumns(labelWidthAttribute.getValue(faceletContext));
      if (!LayoutUtil.checkTokens(columns)) {
        LOG.warn("Illegal value for columns = \"" + columns + "\" replacing with default: \"" + DEFAULT_COLUMNS + "\"");
        columns = DEFAULT_COLUMNS;
      }
      gridLayout.setColumns(columns);
    } else {
      gridLayout.setColumns(getColumns("fixed"));
    }
    gridLayout.setRows(getRows());

    gridLayout.setId(root.createUniqueId());
    panel.getFacets().put(TobagoConstants.FACET_LAYOUT, gridLayout);
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIGridLayout

     return width;
   }

  private int calculateLayoutHeight(
      FacesContext facesContext, UIComponent component, boolean minimum) {
    UIGridLayout layout = (UIGridLayout) UILayout.getLayout(component);
    final List<UIGridLayout.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 of "
          + 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");

    if (rows.size() != layoutTokens.getSize()) {
      LOG.warn("Unbalanced layout: rows.size()=" + rows.size()
          + " != layoutTokens.length=" + layoutTokens.getSize()
          + " rowLayout='" + layoutTokens + "'");
    }
    int size = Math.min(rows.size(), layoutTokens.getSize());

    int height = 0;
    height += getMarginAsInt(layout.getMarginTop());
    height += getMarginAsInt(layout.getMarginBottom());
    for (int i = 0; i < size; i++) {
      if (!rowIsRendered(rows.get(i))) {
        continue;
      }
      height += getCellPadding(facesContext, layout,  i);
      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:"
                + component.getClientId(facesContext) + " is "
                + component.getRendererType());
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIGridLayout

  }


  public int calculateLayoutWidth(
      FacesContext facesContext, UIComponent component, boolean minimum) {
    UIGridLayout layout = (UIGridLayout) UILayout.getLayout(component);
    final List<UIGridLayout.Row> rows = layout.ensureRows();
    UIGridLayout.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) + " !");
    }
    //String[] layoutTokens
    //    = LayoutInfo.createLayoutTokens(columnLayout, row.getColumns(),
    layoutTokens.ensureSize(row.getColumns(), new FixedLayoutToken());

    if (row.getColumns() != layoutTokens.getSize()) {
      LOG.warn("Unbalanced layout: rows.size()=" + rows.size()
          + " != layoutTokens.length=" + layoutTokens.getSize()
          + " columnLayout='" + layoutTokens + "'");
    }
    int size = Math.min(rows.size(), layoutTokens.getSize());

    int width = 0;
    width += getMarginAsInt(layout.getMarginLeft());
    width += getMarginAsInt(layout.getMarginRight());
    for (int i = 0; i < size; i++) {
      if (!columnIsRendered(rows,  i)) {
        continue;
      }
      width += getCellPadding(facesContext, layout,  i);
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIGridLayout

  public void encodeChildrenOfComponent(FacesContext facesContext, UIComponent component)
      throws IOException {
    // encode table with component's children

    UIGridLayout layout =  (UIGridLayout) UILayout.getLayout(component);
    HtmlRendererUtil.prepareRender(facesContext, layout);

    layoutEnd(facesContext, layout);
    layoutMargins(layout);

    final Map attributes = layout.getAttributes();
    List columnWidths =  (List) attributes.get(ATTR_WIDTH_LIST);


    TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlConstants.TABLE, layout);
    writer.writeAttributeFromComponent(HtmlAttributes.BORDER, ATTR_BORDER);
    writer.writeClassAttribute();
    writer.writeStyleAttribute();
    writer.writeAttribute(HtmlAttributes.CELLSPACING, 0);
    writer.writeAttribute(HtmlAttributes.CELLPADDING, 0);
    writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);

    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, i);
          writer.startElement(HtmlConstants.COL, null);
          writer.writeAttribute(HtmlAttributes.WIDTH, cellWidth);
          writer.endElement(HtmlConstants.COL);
        }
      }
      writer.endElement(HtmlConstants.COLGROUP);
    }


    List<UIGridLayout.Row> rows = layout.ensureRows();
    for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) {
      UIGridLayout.Row row = rows.get(rowIndex);
      if (!row.isHidden()) {
        writer.startElement(HtmlConstants.TR, null);

        List cells = row.getElements();
        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)) {
              continue; // ignore the markers UIGridLayout.Used
            }
            if (object.equals(UIGridLayout.FREE)) {
              if (LOG.isWarnEnabled() && !layout.isIgnoreFree()) {
                LOG.warn("There are free blocks in the layout: id='"
                    + layout.getClientId(facesContext)
                    + "'");
              }
              continue;
            }
            UIComponent cell = (UIComponent) object;
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIGridLayout

  private 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(ATTR_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);
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIGridLayout

  }

  public int getComponentExtraWidth(FacesContext facesContext,
      UIComponent component) {
    int extra = 0;
    UIGridLayout layout = (UIGridLayout) component;

    extra += getMarginAsInt(layout.getMarginRight());
    extra += getMarginAsInt(layout.getMarginLeft());

    return extra;
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIGridLayout

  }

  public int getComponentExtraHeight(FacesContext facesContext,
      UIComponent component) {
    int extra = 0;
    UIGridLayout layout = (UIGridLayout) component;

    extra += getMarginAsInt(layout.getMarginTop());
    extra += getMarginAsInt(layout.getMarginBottom());
    return extra;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.