コード例 #1
0
  /**
   * Uses column parameter to determine which column needs sorting. Then it sorts the list.
   *
   * @param column
   */
  public void setSort(int column) {
    if (column == columnIndices.COURSE_NAME.ordinal()) {
      switch (mCurrentSort) {
        case COURSE_NAME_ASC:
          mCurrentSort = sortBy.COURSE_NAME_DESC;
          break;
        case COURSE_NAME_DESC:
          mCurrentSort = sortBy.NONE;
          break;
        default:
          mCurrentSort = sortBy.COURSE_NAME_ASC;
      }
    } else if (column == columnIndices.SECTION_NUMBER.ordinal()) {
      switch (mCurrentSort) {
        case SECTION_NUMBER_ASC:
          mCurrentSort = sortBy.SECTION_NUMBER_DESC;
          break;
        case SECTION_NUMBER_DESC:
          mCurrentSort = sortBy.NONE;
          break;
        default:
          mCurrentSort = sortBy.SECTION_NUMBER_ASC;
      }
    } else if (column == columnIndices.INSTRUCTOR.ordinal()) {
      switch (mCurrentSort) {
        case INSTRUCTOR_ASC:
          mCurrentSort = sortBy.INSTRUCTOR_DESC;
          break;
        case INSTRUCTOR_DESC:
          mCurrentSort = sortBy.NONE;
          break;
        default:
          mCurrentSort = sortBy.INSTRUCTOR_ASC;
      }
    } else if (column == columnIndices.DAYS.ordinal()) {
      switch (mCurrentSort) {
        case DAYS_ASC:
          mCurrentSort = sortBy.DAYS_DESC;
          break;
        case DAYS_DESC:
          mCurrentSort = sortBy.NONE;
          break;
        default:
          mCurrentSort = sortBy.DAYS_ASC;
      }
    } else if (column == columnIndices.START_TIME.ordinal()) {
      switch (mCurrentSort) {
        case START_TIME_ASC:
          mCurrentSort = sortBy.START_TIME_DESC;
          break;
        case START_TIME_DESC:
          mCurrentSort = sortBy.NONE;
          break;
        default:
          mCurrentSort = sortBy.START_TIME_ASC;
      }
    } else if (column == columnIndices.END_TIME.ordinal()) {
      switch (mCurrentSort) {
        case END_TIME_ASC:
          mCurrentSort = sortBy.END_TIME_DESC;
          break;
        case END_TIME_DESC:
          mCurrentSort = sortBy.NONE;
          break;
        default:
          mCurrentSort = sortBy.END_TIME_ASC;
      }
    }

    sort();
    drawList();
  }
コード例 #2
0
  /** Clears the current view and draws the list using the current set of schedule items. */
  public void drawList() {
    clear();

    final StringBuilder builder = new StringBuilder();
    builder.append("<div id=\"ListTableContainer\" onscroll=\"tableContainerScroll()\">");
    builder.append("<table id=\"ListTable\"><tr id=\"headerRow\">");

    // Add column header
    builder.append("<td class=\"columnHeader\" id='h'");
    builder
        .append("onclick=\"calendarListSort(")
        .append(columnIndices.COURSE_NAME.ordinal())
        .append(")\"");
    builder.append(">Course");
    if (mCurrentSort == sortBy.COURSE_NAME_ASC) builder.append(" &#9660;");
    else if (mCurrentSort == sortBy.COURSE_NAME_DESC) builder.append(" &#9650;");
    builder.append("</td>");

    builder.append("<td class=\"columnHeader\" id='h'");
    builder
        .append("onclick=\"calendarListSort(")
        .append(columnIndices.SECTION_NUMBER.ordinal())
        .append(")\"");
    builder.append(">Section Number");
    if (mCurrentSort == sortBy.SECTION_NUMBER_ASC) builder.append(" &#9660;");
    else if (mCurrentSort == sortBy.SECTION_NUMBER_DESC) builder.append(" &#9650;");
    builder.append("</td>");

    builder.append("<td class=\"columnHeader\" id='h'>Type</td>");

    builder.append("<td class=\"columnHeader\" id='h'>SCU</td>");

    builder.append("<td class=\"columnHeader\" id='h'>WTU</td>");

    builder.append("<td class=\"columnHeader\" id='h'");
    builder
        .append("onclick=\"calendarListSort(")
        .append(columnIndices.INSTRUCTOR.ordinal())
        .append(")\"");
    builder.append(">Instructor");
    if (mCurrentSort == sortBy.INSTRUCTOR_ASC) builder.append(" &#9660;");
    else if (mCurrentSort == sortBy.INSTRUCTOR_DESC) builder.append(" &#9650;");
    builder.append("</td>");

    builder.append("<td class=\"columnHeader\" id='h'>Location</td>");

    builder.append("<td class=\"columnHeader\" id='h'");
    builder
        .append("onclick=\"calendarListSort(")
        .append(columnIndices.DAYS.ordinal())
        .append(")\"");
    builder.append(">Days");
    if (mCurrentSort == sortBy.DAYS_ASC) builder.append(" &#9660;");
    else if (mCurrentSort == sortBy.DAYS_DESC) builder.append(" &#9650;");
    builder.append("</td>");

    builder.append("<td class=\"columnHeader\" id='h'");
    builder
        .append("onclick=\"calendarListSort(")
        .append(columnIndices.START_TIME.ordinal())
        .append(")\"");
    builder.append(">Start Time");
    if (mCurrentSort == sortBy.START_TIME_ASC) builder.append(" &#9660;");
    else if (mCurrentSort == sortBy.START_TIME_DESC) builder.append(" &#9650;");
    builder.append("</td>");

    builder.append("<td class=\"columnHeader\" id='h'");
    builder
        .append("onclick=\"calendarListSort(")
        .append(columnIndices.END_TIME.ordinal())
        .append(")\"");
    builder.append(">End Time");
    if (mCurrentSort == sortBy.END_TIME_ASC) builder.append(" &#9660;");
    else if (mCurrentSort == sortBy.END_TIME_DESC) builder.append(" &#9650;");
    builder.append("</td>");

    builder.append("<td class=\"columnHeader\" id='h'>Capacity</td>");

    builder.append("</tr>");

    int tableRow = 0;
    for (ScheduleItemGWT item : mScheduleItems) {
      int tableCol = 0;

      if (item.isConflicted()) {
        builder.append("<tr class=\"conflictedItem\">");
      } else {
        builder.append("<tr>");
      }

      builder.append(
          "<td "
              + "class=\"item\" id=\"x"
              + tableCol
              + "y"
              + tableRow
              + "\" "
              + "ondblclick=\"calendarListDoubleClick("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmousedown=\"calendarListMouseDown("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmouseup=\"calendarListMouseUp("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "tabindex=\"0\" "
              + "onkeydown=\"calendarListKeyDown("
              + tableRow
              + ",event.which)\" "
              + "onselectstart=\"return false\" "
              + ">"
              + mScheduleController.getCourseString(item.getCourseID())
              + "</td>");
      tableCol++;
      builder.append(
          "<td "
              + "class=\"item\" id=\"x"
              + tableCol
              + "y"
              + tableRow
              + "\" "
              + "ondblclick=\"calendarListDoubleClick("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmousedown=\"calendarListMouseDown("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmouseup=\"calendarListMouseUp("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "tabindex=\"0\" "
              + "onkeydown=\"calendarListKeyDown("
              + tableRow
              + ",event.which)\" "
              + "onselectstart=\"return false\" "
              + ">"
              + item.getSection()
              + "</td>");
      tableCol++;

      builder.append(
          "<td "
              + "class=\"item\" id=\"x"
              + tableCol
              + "y"
              + tableRow
              + "\" "
              + "ondblclick=\"calendarListDoubleClick("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmousedown=\"calendarListMouseDown("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmouseup=\"calendarListMouseUp("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "tabindex=\"0\" "
              + "onkeydown=\"calendarListKeyDown("
              + tableRow
              + ",event.which)\" "
              + "onselectstart=\"return false\" "
              + ">"
              + mScheduleController.getCourse(item.getCourseID()).getType()
              + "</td>");
      tableCol++;

      builder.append(
          "<td "
              + "class=\"item\" id=\"x"
              + tableCol
              + "y"
              + tableRow
              + "\" "
              + "ondblclick=\"calendarListDoubleClick("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmousedown=\"calendarListMouseDown("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmouseup=\"calendarListMouseUp("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "tabindex=\"0\" "
              + "onkeydown=\"calendarListKeyDown("
              + tableRow
              + ",event.which)\" "
              + "onselectstart=\"return false\" "
              + ">"
              + mScheduleController.getCourse(item.getCourseID()).getScu()
              + "</td>");
      tableCol++;

      builder.append(
          "<td "
              + "class=\"item\" id=\"x"
              + tableCol
              + "y"
              + tableRow
              + "\" "
              + "ondblclick=\"calendarListDoubleClick("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmousedown=\"calendarListMouseDown("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmouseup=\"calendarListMouseUp("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "tabindex=\"0\" "
              + "onkeydown=\"calendarListKeyDown("
              + tableRow
              + ",event.which)\" "
              + "onselectstart=\"return false\" "
              + ">"
              + mScheduleController.getCourse(item.getCourseID()).getWtu()
              + "</td>");
      tableCol++;

      builder.append(
          "<td "
              + "class=\"item\" id=\"x"
              + tableCol
              + "y"
              + tableRow
              + "\" "
              + "ondblclick=\"calendarListDoubleClick("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmousedown=\"calendarListMouseDown("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmouseup=\"calendarListMouseUp("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "tabindex=\"0\" "
              + "onkeydown=\"calendarListKeyDown("
              + tableRow
              + ",event.which)\" "
              + "onselectstart=\"return false\" "
              + ">");

      if (mScheduleController.getInstructor(item.getInstructorID()) != null) {
        builder.append(mScheduleController.getInstructor(item.getInstructorID()).getLastName());
        builder.append(", ");
        builder.append(mScheduleController.getInstructor(item.getInstructorID()).getFirstName());
      } else {
        builder.append("STAFF");
      }

      builder.append("</td>");
      tableCol++;

      builder.append(
          "<td "
              + "class=\"item\" id=\"x"
              + tableCol
              + "y"
              + tableRow
              + "\" "
              + "ondblclick=\"calendarListDoubleClick("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmousedown=\"calendarListMouseDown("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmouseup=\"calendarListMouseUp("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "tabindex=\"0\" "
              + "onkeydown=\"calendarListKeyDown("
              + tableRow
              + ",event.which)\" "
              + "onselectstart=\"return false\" "
              + ">");

      if (mScheduleController.getLocation(item.getLocationID()) != null) {
        builder.append(mScheduleController.getLocation(item.getLocationID()).getRoom());
      } else {
        builder.append("TBA");
      }

      builder.append("</td>");
      tableCol++;

      builder.append(
          "<td "
              + "class=\"item\" id=\"x"
              + tableCol
              + "y"
              + tableRow
              + "\" "
              + "ondblclick=\"calendarListDoubleClick("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmousedown=\"calendarListMouseDown("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmouseup=\"calendarListMouseUp("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "tabindex=\"0\" "
              + "onkeydown=\"calendarListKeyDown("
              + tableRow
              + ",event.which)\" "
              + "onselectstart=\"return false\" "
              + ">"
              + getDaysString(item.getDays())
              + "</td>");
      tableCol++;

      builder.append(
          "<td "
              + "class=\"item\" id=\"x"
              + tableCol
              + "y"
              + tableRow
              + "\" "
              + "ondblclick=\"calendarListDoubleClick("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmousedown=\"calendarListMouseDown("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmouseup=\"calendarListMouseUp("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "tabindex=\"0\" "
              + "onkeydown=\"calendarListKeyDown("
              + tableRow
              + ",event.which)\" "
              + "onselectstart=\"return false\" "
              + ">");

      int startRow = CalendarTableView.getStartRow(item);
      if (startRow >= 0 && startRow < ScheduleEditWidget.START_TIMES.length)
        builder.append(ScheduleEditWidget.START_TIMES[startRow]);

      builder.append("</td>");

      tableCol++;

      builder.append(
          "<td "
              + "class=\"item\" id=\"x"
              + tableCol
              + "y"
              + tableRow
              + "\" "
              + "ondblclick=\"calendarListDoubleClick("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmousedown=\"calendarListMouseDown("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmouseup=\"calendarListMouseUp("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "tabindex=\"0\" "
              + "onkeydown=\"calendarListKeyDown("
              + tableRow
              + ",event.which)\" "
              + "onselectstart=\"return false\" "
              + ">");

      int endRow = CalendarTableView.getEndRow(item) + 1;
      if (endRow >= 0 && endRow < ScheduleEditWidget.END_TIMES.length)
        builder.append(ScheduleEditWidget.END_TIMES[endRow]);

      builder.append("</td>");
      tableCol++;

      builder.append(
          "<td "
              + "class=\"item\" id=\"x"
              + tableCol
              + "y"
              + tableRow
              + "\" "
              + "ondblclick=\"calendarListDoubleClick("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmousedown=\"calendarListMouseDown("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "onmouseup=\"calendarListMouseUp("
              + tableRow
              + ","
              + tableCol
              + ")\" "
              + "tabindex=\"0\" "
              + "onkeydown=\"calendarListKeyDown("
              + tableRow
              + ",event.which)\" "
              + "onselectstart=\"return false\" "
              + ">"
              + mScheduleController.getCourse(item.getCourseID()).getMaxEnroll()
              + "</td>");
      tableCol++;

      builder.append("</tr>");
      // builder.append("<tr height=0><td class=\"rowSpacer\" colspan=\"12\"></td></tr>");
      tableRow++;
    }

    builder.append("</table>");
    builder.append("</div>");

    mInnerHTML = builder.toString();
    setHTML(mInnerHTML);
    setLeftOffset(mLeftOffset);
    setTopOffset(mScheduleController.getWidget().getAbsoluteTop());
  }