Example #1
0
  /** Render the events for every cells. */
  public void drawEvents() {
    final int rows = displayMode.getRows() + displayHeaders;
    final int columns = displayMode.getColumns() + (displayWeekNumber ? 1 : 0);

    Date date = displayMode.getStartDate(startDate, firstDayOfWeek);

    for (int y = displayHeaders; y < rows; y++) {
      for (int x = displayWeekNumber ? 1 : 0; x < columns; x++) {
        drawEvents(y, x, date);
        date.setDate(date.getDate() + 1);
      }
    }
  }
Example #2
0
  /** Render the whole calendar but do not render the events. */
  public void drawEmptyCells() {
    final FlexTable grid = (FlexTable) getWidget();

    final int rows = displayMode.getRows() + displayHeaders;
    final int columns = displayMode.getColumns() + (displayWeekNumber ? 1 : 0);

    Date date = displayMode.getStartDate(startDate, firstDayOfWeek);

    // Column headers
    if (displayHeaders != NO_HEADERS) {
      if (displayHeaders == ALL_HEADERS) {
        // Header of the calendar
        final Label calendarHeader = new Label(getHeading());
        calendarHeader.addStyleName("calendar-header");
        grid.setWidget(0, 0, calendarHeader);
        grid.getFlexCellFormatter().setColSpan(0, 0, columns + (displayWeekNumber ? 1 : 0));
      }

      final Date currentHeader = new Date(date.getTime());
      for (int x = displayWeekNumber ? 1 : 0; x < columns; x++) {
        final Label columnHeader = new Label(headerFormatter.format(currentHeader));
        columnHeader.addStyleName("calendar-column-header");
        grid.setWidget(displayHeaders == ALL_HEADERS ? 1 : 0, x, columnHeader);

        currentHeader.setDate(currentHeader.getDate() + 1);
      }
    }

    int currentMonth = startDate.getMonth();
    for (int y = displayHeaders; y < rows; y++) {
      if (displayWeekNumber) {
        grid.getCellFormatter().addStyleName(y, 0, "calendar-row-header");
        grid.setText(y, 0, Integer.toString(getWeekNumber(date, firstDayOfWeek)));
      }

      for (int x = displayWeekNumber ? 1 : 0; x < columns; x++) {
        drawCell(y, x, date, currentMonth);
        date.setDate(date.getDate() + 1);
      }
    }
  }