Example #1
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("‹");
    backwards.setStyleName(BASE_NAME + "PreviousButton");

    forwards = new PushButton();
    forwards.getUpFace().setHTML("›");
    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("«");
    backwardsYear.setStyleName(BASE_NAME + "PreviousButton");

    forwardsYear = new PushButton();
    forwardsYear.getUpFace().setHTML("»");
    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);
  }