Package org.apache.myfaces.tobago.internal.layout

Examples of org.apache.myfaces.tobago.internal.layout.Grid


    for (AbstractUIColumn ignored : renderedColumns) {
      columns.addToken(RelativeLayoutToken.DEFAULT_INSTANCE);
    }
    final LayoutTokens rows = new LayoutTokens();
    rows.addToken(AutoLayoutToken.INSTANCE);
    final Grid grid = new Grid(columns, rows);

    for(UIComponent child : header.getChildren()) {
      if (child instanceof LayoutComponent) {
        if (child.isRendered()) {
          final LayoutComponent c = (LayoutComponent) child;
          grid.add(new OriginCell(c), c.getColumnSpan(), c.getRowSpan());
        }
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Found unknown component in header.");
        }
View Full Code Here


  }

  @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(""
        + "┌─┬─┬─┬─┬─┐\n"
        + "│◌│◌│◌│◌│◌│\n"
        + "├─┼─┼─┼─┼─┤\n"
        + "│◌│◌│◌│◌│◌│\n"
        + "├─┼─┼─┼─┼─┤\n"
        + "│◌│◌│◌│◌│◌│\n"
        + "├─┼─┼─┼─┼─┤\n"
        + "│◌│◌│◌│◌│◌│\n"
        + "├─┼─┼─┼─┼─┤\n"
        + "│◌│◌│◌│◌│◌│\n"
        + "└─┴─┴─┴─┴─┘\n", grid.gridAsString());

    grid.add(new OriginCell(null), 1, 2);
    grid.add(new OriginCell(null), 1, 3);
    grid.add(new OriginCell(null), 1, 1);
    grid.add(new OriginCell(null), 2, 1);
    grid.add(new OriginCell(null), 3, 1);
    grid.add(new OriginCell(null), 1, 1);
    grid.add(new OriginCell(null), 1, 1);
    grid.add(new OriginCell(null), 1, 3);
    grid.add(new OriginCell(null), 1, 1);
    grid.add(new OriginCell(null), 3, 1);
    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(""
        + "┏━┳━┳━┳━┯━┓\n"
        + "┃█┃█┃█┃█│➞┃\n"
        + "┠─╂─╊━╇━┿━┫\n"
        + "┃⬇┃⬇┃█│➞│➞┃\n"
        + "┣━╉─╊━╈━╈━┫\n"
        + "┃█┃⬇┃█┃█┃█┃\n"
        + "┣━╇━╇━╉─╊━┫\n"
        + "┃█│➞│➞┃⬇┃█┃\n"
        + "┣━┿━╈━╉─╂─┨\n"
        + "┃█│➞┃█┃⬇┃⬇┃\n"
        + "┗━┷━┻━┻━┻━┛\n", grid.gridAsString());
  }
View Full Code Here

    if (!getLayoutContainer().isLayoutChildren()) {
      return;
    }

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

public class GridUnitTest {

  @Test
  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(""
        + "┌─┐\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(""
        + "┏━┓\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(""
        + "┏━┓\n"
        + "┃█┃\n"
        + "┣━┫\n"
        + "┃█┃\n"
        + "┗━┛\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(""
        + "┏━┓\n"
        + "┃█┃\n"
        + "┣━┫\n"
        + "┃█┃\n"
        + "┣━┫\n"
        + "┃█┃\n"
        + "┠─┨\n"
        + "┃⬇┃\n"
        + "┗━┛\n", grid.gridAsString());

    // 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(""
        + "┏━┓\n"
        + "┃█┃\n"
        + "┣━┫\n"
        + "┃█┃\n"
        + "┣━┫\n"
        + "┃█┃\n"
        + "┠─┨\n"
        + "┃⬇┃\n"
        + "┣━┫\n"
        + "┃✖┃\n"
        + "┗━┛\n", grid.gridAsString());
  }
View Full Code Here

  }

  @Test
  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(""
        + "┌─┬─┐\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(""
        + "┏━┱─┐\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(""
        + "┏━┳━┓\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(""
        + "┏━┳━┓\n"
        + "┃█┃█┃\n"
        + "┣━╇━┫\n"
        + "┃█│➞┃\n"
        + "┠─┼─┨\n"
        + "┃⬇│⬇┃\n"
        + "┗━┷━┛\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(""
        + "┏━┳━┓\n"
        + "┃█┃█┃\n"
        + "┣━╇━┫\n"
        + "┃█│➞┃\n"
        + "┠─┼─┨\n"
        + "┃⬇│⬇┃\n"
        + "┣━╈━┩\n"
        + "┃█┃◌│\n"
        + "┠─╂─┤\n"
        + "┃⬇┃◌│\n"
        + "┗━┹─┘\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(""
        + "┏━┳━┓\n"
        + "┃█┃█┃\n"
        + "┣━╇━┫\n"
        + "┃█│➞┃\n"
        + "┠─┼─┨\n"
        + "┃⬇│⬇┃\n"
        + "┣━╈━┫\n"
        + "┃█┃█┃\n"
        + "┠─╊━┩\n"
        + "┃⬇┃◌│\n"
        + "┗━┹─┘\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(""
        + "┏━┳━┓\n"
        + "┃█┃█┃\n"
        + "┣━╇━┫\n"
        + "┃█│➞┃\n"
        + "┠─┼─┨\n"
        + "┃⬇│⬇┃\n"
        + "┣━╈━┫\n"
        + "┃█┃█┃\n"
        + "┠─╊━┫\n"
        + "┃⬇┃█┃\n"
        + "┡━╉─┨\n"
        + "│◌┃⬇┃\n"
        + "└─┺━┛\n", grid.gridAsString());

    grid.add(new OriginCell(null), 2, 1);
    // fehler
    Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(6, grid.getBankHeads(Orientation.VERTICAL).length);
  }
View Full Code Here

    for (final AbstractUIColumn ignored : renderedColumns) {
      columns.addToken(RelativeLayoutToken.DEFAULT_INSTANCE);
    }
    final LayoutTokens rows = new LayoutTokens();
    rows.addToken(AutoLayoutToken.INSTANCE);
    final Grid grid = new Grid(columns, rows);

    for(final UIComponent child : header.getChildren()) {
      if (child instanceof LayoutComponent) {
        if (child.isRendered()) {
          final LayoutComponent c = (LayoutComponent) child;
          grid.add(new OriginCell(c), c.getColumnSpan(), c.getRowSpan());
        }
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Found unknown component in header.");
        }
View Full Code Here

      final ResourceManager resourceManager,
      final String contextPath, final String sheetId, final List<AbstractUIColumn> renderedColumnList,
      final Measure headerWidth)
      throws IOException {

    final Grid grid = sheet.getHeaderGrid();
    if (grid == null) {
      LOG.warn("Can't render column headers, because grid == null. One reason can be, the you use nested sheets. "
          + "The inner sheet ensureHeader() will be called outside the iterating over the rows. "
          + "Nesting sheet is currently not supported.");
      return;
    }
    final List<Integer> columnWidths = sheet.getWidthList();

    if (LOG.isDebugEnabled()) {
      LOG.debug("*****************************************************");
      LOG.debug("" + grid);
      LOG.debug("*****************************************************");
    }

    final boolean needVerticalScrollbar = needVerticalScrollbar(facesContext, sheet);
    int verticalScrollbarWidth = 0;

    writer.startElement(HtmlElements.DIV, sheet);
    writer.writeClassAttribute(Classes.create(sheet, "headerDiv"));
    writer.startElement(HtmlElements.TABLE, sheet);
    writer.writeAttribute(HtmlAttributes.CELLSPACING, "0", false);
    writer.writeAttribute(HtmlAttributes.CELLPADDING, "0", false);
    writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);
    writer.writeClassAttribute(Classes.create(sheet, "headerTable"));
    if (needVerticalScrollbar) {
      verticalScrollbarWidth = getVerticalScrollbarWeight(facesContext, sheet).getPixel();
      writer.writeAttribute("data-tobago-sheet-verticalscrollbarwidth", String.valueOf(verticalScrollbarWidth), false);
    }

    if (columnWidths != null) {
      writer.startElement(HtmlElements.COLGROUP, null);
      for (int i = 0; i < columnWidths.size(); i++) {
        writer.startElement(HtmlElements.COL, null);
        if (i == columnWidths.size() - 2 && needVerticalScrollbar) {
          // if scrollbar is needed the coll for column in header must have own width + scrollbarWidth
          writer.writeAttribute(
              HtmlAttributes.WIDTH, columnWidths.get(i) + verticalScrollbarWidth);
        } else {
          writer.writeAttribute(HtmlAttributes.WIDTH, columnWidths.get(i));
        }
        writer.endElement(HtmlElements.COL);
      }
      writer.endElement(HtmlElements.COLGROUP);
    }

    writer.startElement(HtmlElements.TBODY, sheet);
    for (int i = 0; i < grid.getRowCount(); i++) {
      writer.startElement(HtmlElements.TR, null);
      for (int j = 0; j < grid.getColumnCount(); j++) {
        final Cell cell = grid.getCell(j, i);
        if (cell instanceof OriginCell) {
          writer.startElement(HtmlElements.TD, null);
          if (cell.getColumnSpan() > 1) {
            writer.writeAttribute(HtmlAttributes.COLSPAN, cell.getColumnSpan());
          }
View Full Code Here

    if (!getLayoutContainer().isLayoutChildren()) {
      return;
    }

    grid = new Grid(LayoutTokens.parse(getColumns()), LayoutTokens.parse(getRows()));

    List<LayoutComponent> components = getLayoutContainer().getComponents();
    for (LayoutComponent component : components) {
      component.setCurrentHeight(null);
      component.setCurrentWidth(null);
View Full Code Here

    if (!getLayoutContainer().isLayoutChildren()) {
      return;
    }

    grid = new Grid(LayoutTokens.parse(getColumns()), LayoutTokens.parse(getRows()));

    List<LayoutComponent> components = getLayoutContainer().getComponents();
    for (LayoutComponent component : components) {
      component.setCurrentHeight(null);
      component.setCurrentWidth(null);
View Full Code Here

    if (!getLayoutContainer().isLayoutChildren()) {
      return;
    }

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

TOP

Related Classes of org.apache.myfaces.tobago.internal.layout.Grid

Copyright © 2018 www.massapicom. 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.