package caltool.model.view; import caltool.model.caldb.*; import caltool.model.schedule.*; import mvp.*; import java.util.*; /**** * * Class Lists is the model class that encapsulates the View->Lists commands. * These are commands to list appointments, meetings, tasks, events, and all * items. Lists also has a reference to the CustomLists class, which has * methods and data to support editing custom lists of items. *

* There are couple design alternatives for this class. In Alternative 1, the * way the class is currently designed, this Lists class supplies * array-returning methods that trace to the operations in the abstract spec. * These methods have been refined to return array values intstead of whole * model objects. This refinement supports the companion view classes that are * implemented as JTables, the rows of which are easily populated with * array-valued data. *

* Alternative 2, not currently implemented, would be patterned after the * current MontlyAgenda/MonthlyAgendaDisplay design. In this version of the * design,, the Lists class would have data fields that point to instances of * AppointmentLists, etc, and each such list class would provide iterator * methods, a la MontlyAgenda. In this case, the traceable * viewAppointmentsList method returns a (persistent) AppointmentList object * that serves as the appointment list factory, a la MonthlyAgenda. *

* Alternative 1 is more directly traceable to the spec, and more functional in * style, since the return values of the methods are not persistent objects. * Alternative 2 can be considered more object-oriented in style, with its * persistent object instances and iterator methods. I see no real qualitative * difference between the two designs, only a stylistic difference. * * @author Gene Fisher (gfisher@calpoly.edu) * @version 13apr15 * */ public class Lists extends mvp.Model { public Lists(CalendarDB caldb) { } /** * List all appointments between the current list-start and list-end option * settings. The default start/end setting is the three-week period * starting one week prior to today's date through two weeks after today's * date. The list of values is returned in an array of AppointmentListItems . * * The current implementation is a stub that returns a sample list with * values taken from * Figure 32 of the requirements. */ public Object[] viewAppointmentsList() { return generateSampleList(); } /** * Generate a sample appointments list for initial view testing. The list * is based on * ../../requirements/list-viewing.html#Figure Basic Appointments List> * Figure 32 of the requirements, with additional data added to * reflect that which is not visible in the default 20-line view. The data * were generated with the assistance of Emacs editing macros. */ protected Object[] generateSampleList() { Vector list = new Vector(); list.add( new AppointmentListItem( "Racket Ball", new caltool.model.schedule.Date("sep 17, 2015"), new Time("8 AM"), new Duration(1, 0), true, new Category("personal"), "Rec centre", Security.PublicTitle, Priority.Optional) ); list.add( new AppointmentListItem( "Office Hours", new caltool.model.schedule.Date("sep 21, 2015"), new Time("9 AM"), new Duration(1, 0), true, new Category("classes"), "14-210", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lecture", new caltool.model.schedule.Date("sep 21, 2015"), new Time("10 AM"), new Duration(1, 0), true, new Category("classes"), "14-256", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lab", new caltool.model.schedule.Date("sep 21, 2015"), new Time("11 AM"), new Duration(1, 0), true, new Category("classes"), "14-232", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Software Engineering Graduate Seminar", new caltool.model.schedule.Date("sep 21, 2015"), new Time("3 PM"), new Duration(2, 0), true, new Category("classes"), "14-301", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Racket Ball", new caltool.model.schedule.Date("sep 22, 2015"), new Time("8 AM"), new Duration(1, 0), true, new Category("personal"), "Rec centre", Security.PublicTitle, Priority.Optional) ); list.add( new AppointmentListItem( "Research", new caltool.model.schedule.Date("sep 22, 2015"), new Time("9 AM"), new Duration(8, 0), true, new Category("research"), "14-210", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Office Hours", new caltool.model.schedule.Date("sep 23, 2015"), new Time("9 AM"), new Duration(1, 0), true, new Category("classes"), "14-210", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lecture", new caltool.model.schedule.Date("sep 23, 2015"), new Time("10 AM"), new Duration(1, 0), true, new Category("classes"), "14-256", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lab", new caltool.model.schedule.Date("sep 23, 2015"), new Time("11 AM"), new Duration(1, 0), true, new Category("classes"), "14-232", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Lunch with Microsoft", new caltool.model.schedule.Date("sep 23, 2015"), new Time("12 PM"), new Duration(1, 30), false, new Category("department"), "Staff dining", Security.Public, Priority.Optional) ); list.add( new AppointmentListItem( "Racket Ball", new caltool.model.schedule.Date("sep 24, 2015"), new Time("8 AM"), new Duration(1, 0), true, new Category("personal"), "Rec centre", Security.PublicTitle, Priority.Optional) ); list.add( new AppointmentListItem( "Office Hours", new caltool.model.schedule.Date("sep 24, 2015"), new Time("1:15 PM"), new Duration(1, 45), true, new Category("classes"), "14-210", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Software Engineering Graduate Seminar", new caltool.model.schedule.Date("sep 24, 2015"), new Time("3 PM"), new Duration(2, 0), true, new Category("classes"), "14-301", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Dentist", new caltool.model.schedule.Date("sep 25, 2015"), new Time("8 AM"), new Duration(1, 30), false, new Category("personal"), "1342 Sycamore Dr", Security.PublicTitle, Priority.Must) ); list.add( new AppointmentListItem( "Office Hours", new caltool.model.schedule.Date("sep 25, 2015"), new Time("9 AM"), new Duration(1, 0), true, new Category("classes"), "14-210", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lecture", new caltool.model.schedule.Date("sep 25, 2015"), new Time("10 AM"), new Duration(1, 0), true, new Category("classes"), "14-256", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lab", new caltool.model.schedule.Date("sep 25, 2015"), new Time("11 AM"), new Duration(1, 0), true, new Category("classes"), "14-232", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Office Hours", new caltool.model.schedule.Date("sep 28, 2015"), new Time("9 AM"), new Duration(1, 0), true, new Category("classes"), "14-210", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lecture", new caltool.model.schedule.Date("sep 28, 2015"), new Time("10 AM"), new Duration(1, 0), true, new Category("classes"), "14-256", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lab", new caltool.model.schedule.Date("sep 28, 2015"), new Time("11 AM"), new Duration(1, 0), true, new Category("classes"), "14-232", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Software Engineering Graduate Seminar", new caltool.model.schedule.Date("sep 28, 2015"), new Time("3 PM"), new Duration(2, 0), true, new Category("classes"), "14-301", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Racket Ball", new caltool.model.schedule.Date("sep 29, 2015"), new Time("8 AM"), new Duration(1, 0), true, new Category("personal"), "Rec centre", Security.PublicTitle, Priority.Optional) ); list.add( new AppointmentListItem( "Research", new caltool.model.schedule.Date("sep 29, 2015"), new Time("9 AM"), new Duration(8, 0), true, new Category("research"), "14-210", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Office Hours", new caltool.model.schedule.Date("sep 30, 2015"), new Time("9 A"), new Duration(1, 0), true, new Category("classes"), "14-210", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lecture", new caltool.model.schedule.Date("sep 30, 2015"), new Time("10 AM"), new Duration(1, 0), true, new Category("classes"), "14-256", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lab", new caltool.model.schedule.Date("sep 30, 2015"), new Time("11 AM"), new Duration(1, 0), true, new Category("classes"), "14-232", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "CAD Research Project Meeting", new caltool.model.schedule.Date("sep 30, 2015"), new Time("2:30 PM"), new Duration(2, 0), true, new Category("research"), "14-301", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Racket Ball", new caltool.model.schedule.Date("oct 1, 2015"), new Time("8 AM"), new Duration(1, 0), true, new Category("personal"), "Rec centre", Security.PublicTitle, Priority.Optional) ); list.add( new AppointmentListItem( "Office Hours", new caltool.model.schedule.Date("oct 1, 2015"), new Time("1:15 PM"), new Duration(1, 45), true, new Category("classes"), "14-210", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Software Engineering Graduate Seminar", new caltool.model.schedule.Date("oct 1, 2015"), new Time("3 PM"), new Duration(2, 0), true, new Category("classes"), "14-301", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Office Hours", new caltool.model.schedule.Date("oct 2, 2015"), new Time("9 AM"), new Duration(1, 0), true, new Category("classes"), "14-210", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lecture", new caltool.model.schedule.Date("oct 2, 2015"), new Time("10 AM"), new Duration(1, 0), true, new Category("classes"), "14-256", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lab", new caltool.model.schedule.Date("oct 2, 2015"), new Time("11 AM"), new Duration(1, 0), true, new Category("classes"), "14-232", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Office Hours", new caltool.model.schedule.Date("oct 5, 2015"), new Time("9 AM"), new Duration(1, 0), true, new Category("classes"), "14-210", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lecture", new caltool.model.schedule.Date("oct 5, 2015"), new Time("10 AM"), new Duration(1, 0), true, new Category("classes"), "14-256", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Data Structures Lab", new caltool.model.schedule.Date("oct 5, 2015"), new Time("11 AM"), new Duration(1, 0), true, new Category("classes"), "14-232", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Software Engineering Graduate Seminar", new caltool.model.schedule.Date("oct 5, 2015"), new Time("3 PM"), new Duration(2, 0), true, new Category("classes"), "14-301", Security.Public, Priority.Must) ); list.add( new AppointmentListItem( "Racket Ball", new caltool.model.schedule.Date("oct 6, 2015"), new Time("8 AM"), new Duration(1, 0), true, new Category("personal"), "Rec centre", Security.PublicTitle, Priority.Optional) ); list.add( new AppointmentListItem( "Research", new caltool.model.schedule.Date("oct 6, 2015"), new Time("9 AM"), new Duration(8, 0), true, new Category("research"), "14-210", Security.Public, Priority.Must) ); return list.toArray(); } }