package caltool.model.model.view;
import caltool.model.model.schedule.*;
import mvp.*;
/****
*
* An AppointmentListItem is the somewhat abbreviated description of an
* appointment that appears in appointments and meetings list views. The
* precise relation between a full Appointment compared to an
* AppointmentListItem is as follows:
*
-
* The titles are the same.
*
-
* The list item has only a start date, with no end date. This is
* because there is a separte list item for every instance of a
* recurring appointment.
*
-
* The start time and duration are the same.
*
-
* There is only a boolean-valued Recurs component in the list item,
* instead of the full recurring structure of the Appointment. The
* rationale is that the list would be too cluttered if it contained
* all of the recurring information of the full appointment.
*
-
* The category, location, security, and priority are the same.
*
-
* The list item contains no remind information or details. The
* rationale is again not to clutter the list.
*/
public class AppointmentListItem extends Model {
/**
* Construct with the given field values.
*/
public AppointmentListItem(String title, Date date, Time time,
Duration duration, boolean recurs, Category category,
String location, Security security, Priority priority) {
this.title = title;
this.date = date;
this.time = time;
this.duration = duration;
this.recurs = recurs;
this.category = category;
this.location = location;
this.security = security;
this.priority = priority;
}
/**
* Convert this to an array of its data fields. This method serves the
* companion view class
* AppointmentsListDisplay , the update method of which uses the array
* to populate the rows of the table view.
*/
public Object[] toArray() {
Object[] array = new Object[9];
array[0] = title;
array[1] = date;
array[2] = time;
array[3] = duration;
array[4] = recurs ? "yes" : "no";
array[5] = category;
array[6] = location;
array[7] = security;
array[8] = priority;
return array;
}
/** Brief description of the scheduled item */
protected String title;
/** Date on which item is scheduled or due. This is the single-instance
date the listed item.
*/
protected Date date;
/** Starting time of the appointment */
protected Time time;
/** How long the appointment lasts */
protected Duration duration;
/** Flag indicating whether the appointent recurs */
protected boolean recurs;
/** Color-coded category */
protected Category category;
/** Where the appointment is held */
protected String location;
/** Indicates who can see that the appointment is scheduled */
protected Security security;
/** How important the appointment is */
protected Priority priority;
}