예제 #1
0
  /**
   * Writes this AppointmentBlock's RefAppointment to the JTextArea
   *
   * @param a the RefAppointment to write
   */
  public void updateAppointment(RefAppointment appt) {
    this.appt = appt;
    if (!limitDisplay) {

      setText(
          "Title: "
              + appt.getTemplate().getTitle()
              + "\n"
              + "Description: "
              + appt.getTemplate().getDescription()
              + "\n"
              + "Time: "
              + FORMAT.format(appt.getStartDate())
              + " to "
              + FORMAT.format(appt.getEndDate()));
    } else { // limit the display (used for the monthlyDayBlocks)
      setText(FORMAT.format(appt.getStartDate()) + " - " + appt.getTemplate().getTitle());
    }

    setEditable(false);
    setOpaque(false);
    setBorder(new EtchedBorder());
    setLineWrap(true);
    setWrapStyleWord(true);
  }
예제 #2
0
 /**
  * sets the current appointment, checks it for validity, and marks this CalendarModel as changed
  * if a change has been made
  *
  * @param appt new current appointment
  * @throws IllegalArgumentException the passed appointment is not in the RefAppointment set
  */
 private void internalSetCurrentAppointment(RefAppointment appt) {
   if (appt != null && !apptSet.contains(appt))
     throw new IllegalArgumentException("appt does not exist or has not bee added");
   if (appt == null ? curAppt != null : !appt.equals(curAppt)) this.setChanged();
   curAppt = appt;
   if (curAppt != null) internalSetCurrentDate(curAppt.getStartDate());
 }
  /**
   * This allows the user to modify an appointment when they click the edit button.
   *
   * @param ActionEvent e is the event sent to this method when the user pressed the edit button.
   */
  public void actionPerformed(ActionEvent e) {
    RefAppointment ref = controller.getModel().getCurrentAppointment();
    if (ref != null) {
      if (ref.getPattern() != null) {
        AppointmentTemplate apptTmpl = (AppointmentTemplate) ref.getTemplate().clone();
        apptTmpl.setPattern(null);
        RefAppointment appt = new RefAppointment(ref.getStartDate(), apptTmpl);

        if (AppointmentDialog.changeAppointment(controller.getView(), appt)) {
          controller.getModel().getAppointmentSet().remove(ref);
          CalendarModelUtility.add(controller.getModel(), appt);
        }
      } else
        JOptionPane.showMessageDialog(
            controller.getView(),
            "the selected appointment does not recur",
            "",
            JOptionPane.ERROR_MESSAGE);
    } else
      JOptionPane.showMessageDialog(
          controller.getView(), "no appointment is selected", "", JOptionPane.ERROR_MESSAGE);
  }