Beispiel #1
0
  /**
   * This method updates the week by updating all of it's weekDayBlocks
   *
   * @param refSet is the new reference set
   * @param selectedDate is the currently selected date
   * @param selectedAppointment is the currently selected appointment
   */
  public void update(
      Set<RefAppointment> refSet, Date selectedDate, RefAppointment selectedAppointment) {
    Calendar curcal = Calendar.getInstance();
    curcal.setTime(selectedDate);

    Calendar tmpCal = Calendar.getInstance();
    WeekRange wRange = new WeekRange(selectedDate);
    for (int i = 0; i < blocks.size(); i++) { // for each day in the month
      tmpCal.setTime(wRange.getStartDate());
      tmpCal.add(Calendar.DATE, i);

      WeeklyDayBlock dayBox = blocks.get(i);
      dayBox.update(refSet, tmpCal.getTime(), selectedAppointment);
      dayBox.setSelected(tmpCal.get(Calendar.DAY_OF_YEAR) == curcal.get(Calendar.DAY_OF_YEAR));
    }
  }
Beispiel #2
0
  /**
   * This is the constructor of the class it creates all of the weekDayBlocks that are associated
   * with this class and sets the currently selected date and creates a weekRange around that date
   *
   * @param date is the currentlySelectedDate
   */
  public WeeklyPanel(Date date) {
    super();

    blocks = new ArrayList<WeeklyDayBlock>();

    JPanel daysPanel = new JPanel();
    daysPanel.setOpaque(false);
    daysPanel.setLayout(new GridLayout(1, 7));

    Calendar tmpCal = Calendar.getInstance();
    WeekRange week = new WeekRange();
    tmpCal.setTime(week.getStartDate());
    while (tmpCal.getTime().before(week.getEndDate())) {
      JLabel dayText =
          new JLabel(
              tmpCal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault()));
      dayText.setFont(dayText.getFont().deriveFont(13f).deriveFont(Font.BOLD));
      dayText.setOpaque(false);
      dayText.setHorizontalAlignment(SwingConstants.CENTER);
      daysPanel.add(dayText);
      tmpCal.add(Calendar.DATE, 1);
    }

    JPanel content = new JPanel();
    content.setOpaque(false);
    content.setLayout(new GridLayout(0, 7));

    ButtonGroup group = new ButtonGroup();

    WeekRange thisWeek = new WeekRange(date);
    tmpCal.setTime(thisWeek.getStartDate());
    while (tmpCal.getTime().before(thisWeek.getEndDate())) {
      WeeklyDayBlock currentDay = new WeeklyDayBlock(tmpCal.getTime());
      blocks.add(currentDay);
      content.add(currentDay);
      group.add(currentDay);
      tmpCal.add(Calendar.DATE, 1);
    }

    setLayout(new BorderLayout());
    setOpaque(false);
    add(daysPanel, BorderLayout.NORTH);
    add(content, BorderLayout.CENTER);

    update(new HashSet<RefAppointment>(), date, null);
  }