Пример #1
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());
 }
Пример #2
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);
  }
  /**
   * 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);
  }
Пример #4
0
  /**
   * creates a new Calendar model:
   *
   * <ul>
   *   <li>current date: moment of object creation
   *   <li>current appointment: null
   *   <li>current URI: null
   *   <li>appointment template set: empty
   *   <li>appointment reference set: empty
   * </ul>
   */
  public CalendarModel() {
    super();
    that = this;
    curDate = new Date();
    curAppt = null;
    curFile = null;
    apptTmplSet = new ObservableSet<AppointmentTemplate>();
    apptSet = new ApptObservableSet();
    diffFile = false;
    defaultApptTmpl = new RefAppointment(new Date(63, 0, 16), new Date(63, 0, 16));

    apptTmplSet.addObserver(new ApptTmplSetObserver());
    apptTmplSet.addObserver(new SetObserver());
    apptSet.addObserver(new SetObserver());
    defaultApptTmpl.addObserver(new ElementObserver());
  }