@Override
  public void buildTable(
      List<? extends NeedsRefresh> sourceDisplays, List<? extends NeedsRefresh> targetDisplays) {
    showEmptyContentIfNoData(sourceDisplays.size());

    transUnitTable.resizeRows(sourceDisplays.size());
    HTMLTable.CellFormatter cellFormatter = transUnitTable.getCellFormatter();

    for (int i = 0; i < sourceDisplays.size(); i++) {
      NeedsRefresh sourceDisplay = sourceDisplays.get(i);
      NeedsRefresh targetDisplay = targetDisplays.get(i);

      transUnitTable.setWidget(i, 0, sourceDisplay);
      transUnitTable.setWidget(i, 1, targetDisplay);

      cellFormatter.setVerticalAlignment(i, 0, HasVerticalAlignment.ALIGN_TOP);
      cellFormatter.setVerticalAlignment(i, 1, HasVerticalAlignment.ALIGN_TOP);
      cellFormatter.addStyleName(i, 0, "transUnitCol");
      cellFormatter.addStyleName(i, 1, "transUnitCol");

      sourceDisplay.refresh();
      targetDisplay.refresh();
    }
  }
Ejemplo n.º 2
0
 /** Configures the formatting for a particular cell based on its location in the grid. */
 protected void formatCell(HTMLTable.CellFormatter formatter, int row, int col, int limit) {
   formatter.setHorizontalAlignment(row, col, _cellHorizAlign);
   formatter.setVerticalAlignment(row, col, _cellVertAlign);
   formatter.setStyleName(row, col, "Cell");
   if (row == (limit - 1) / _cols) {
     formatter.addStyleName(row, col, "BottomCell");
   } else if (row == 0) {
     formatter.addStyleName(row, col, "TopCell");
   } else {
     formatter.addStyleName(row, col, "MiddleCell");
   }
 }
  /** Inicializa el selector de meses {@link MonthAndYearSelector} */
  @Override
  protected void setup() {
    // Set up backwards.
    backwards = new PushButton();
    backwards.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            addMonths(-1);
          }
        });

    backwards.getUpFace().setHTML("&lsaquo;");
    backwards.setStyleName(BASE_NAME + "PreviousButton");

    forwards = new PushButton();
    forwards.getUpFace().setHTML("&rsaquo;");
    forwards.setStyleName(BASE_NAME + "NextButton");
    forwards.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            addMonths(+1);
          }
        });

    // Set up backwards year
    backwardsYear = new PushButton();
    backwardsYear.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            addMonths(-12);
          }
        });

    backwardsYear.getUpFace().setHTML("&laquo;");
    backwardsYear.setStyleName(BASE_NAME + "PreviousButton");

    forwardsYear = new PushButton();
    forwardsYear.getUpFace().setHTML("&raquo;");
    forwardsYear.setStyleName(BASE_NAME + "NextButton");
    forwardsYear.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            addMonths(+12);
          }
        });

    // Set up grid.
    grid = new Grid(1, 5);
    grid.setWidget(0, previousYearColumn, backwardsYear);
    grid.setWidget(0, previousMonthColumn, backwards);
    grid.setWidget(0, nextMonthColumn, forwards);
    grid.setWidget(0, nextYearColumn, forwardsYear);

    HTMLTable.CellFormatter formatter = grid.getCellFormatter();
    formatter.setStyleName(0, monthColumn, BASE_NAME + "Month");
    formatter.setWidth(0, previousYearColumn, "1");
    formatter.setWidth(0, previousMonthColumn, "1");
    formatter.setWidth(0, monthColumn, "100%");
    formatter.setWidth(0, nextMonthColumn, "1");
    formatter.setWidth(0, nextYearColumn, "1");
    grid.setStyleName(BASE_NAME + "MonthSelector");
    initWidget(grid);
  }