scheduler.view
Class View

java.lang.Object
  extended by scheduler.view.View
All Implemented Interfaces:
java.util.Observer

public class View
extends java.lang.Object
implements java.util.Observer

Class View is the top-level model class in the view package. It controls the top level UI and provides methods to view a schedule as a list or a calendar. There are also methods to view a schedule by selectedDay or by week. Methods are provided for extended viewing through popups and dialogs. Methods are provided to filter various aspects of scheduled items.

Author:
Jason Mak (jamak3@gmail.com)

Field Summary
static AdvancedFilter advancedFilter
          filter to show or hide times and dates
protected  CalendarView calendarView
          The view of the schedule as a calendar.
protected  javax.swing.Box hbox
          Top level box in the viewing window.
protected  ListView listView
          The view of the schedule as a list.
protected  Schedule schedule
          The schedule to be viewed.
protected  scheduler.Scheduler scheduler
          The top level program.
protected  ViewCourseFilter viewCourseFilter
          filter to show or hide schedule items that contain certain courses
protected  ViewInstructorFilter viewInstructorFilter
          filter to show or hide schedule items that contain certain instructors
protected  ViewLocationFilter viewLocationFilter
          filter to show or hide schedule items that contain certain locations
protected  ViewSettings viewSettings
          The viewSettings used for drawing a schedule.
 
Constructor Summary
View(scheduler.Scheduler scheduler)
          Constructs a shell.
 
Method Summary
 void autoView()
          This method creates a view on the screen immediately after a new schedule is generated.
 AdvancedFilter getAdvancedFilter()
          Return the advancedFilter object.
 CalendarView getCalendarView()
          Return the calendarView object.
 ListView getListView()
          Return the listView object;
 Schedule getSchedule()
          Return the schedule to be viewed.
 ViewCourseFilter getViewCourseFilter()
          Return the ViewCourseFilter object.
 ViewInstructorFilter getViewInstructorFilter()
          Return the ViewInstructorFilter object.
 ViewLocationFilter getViewLocationFilter()
          Return the ViewLocationFilter object;
 ViewSettings getViewSettings()
          Return the viewSettings object.
 void initSettings()
          Initializes the View object with some default view settings.
 void setSchedule(Schedule schedule)
          Associate a new schedule with the view.
 void setViewCourseFilter(ViewCourseFilter newCourseFilter)
          Set the ViewCourseFilter object to a new one.
 void setViewInstructorFilter(ViewInstructorFilter newInstrFilter)
          Set the ViewInstructorFilter object to a new one;
 void setViewLocationFilter(ViewLocationFilter newLocationFilter)
          Set the ViewLocationFilter object to a new one;
 void setViewSettings(ViewSettings viewSettings)
          Set viewSettings to the new viewSettings object.
 void update(java.util.Observable O, java.lang.Object arg)
          Updates the top level UI when one of its observable components changes.
 void viewSchedule()
          Display a schedule view for the given schedule with the given information specified in viewSettings, filterOptions, and advancedFilters Pre: //The schedule to be viewed cannot be null schedule != null Post: //A view with a mode corresponding to viewMode is drawn.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viewSettings

protected ViewSettings viewSettings
The viewSettings used for drawing a schedule.


hbox

protected javax.swing.Box hbox
Top level box in the viewing window.


scheduler

protected scheduler.Scheduler scheduler
The top level program.


schedule

protected Schedule schedule
The schedule to be viewed.


viewCourseFilter

protected ViewCourseFilter viewCourseFilter
filter to show or hide schedule items that contain certain courses


viewInstructorFilter

protected ViewInstructorFilter viewInstructorFilter
filter to show or hide schedule items that contain certain instructors


viewLocationFilter

protected ViewLocationFilter viewLocationFilter
filter to show or hide schedule items that contain certain locations


advancedFilter

public static AdvancedFilter advancedFilter
filter to show or hide times and dates


listView

protected ListView listView
The view of the schedule as a list.


calendarView

protected CalendarView calendarView
The view of the schedule as a calendar.

Constructor Detail

View

public View(scheduler.Scheduler scheduler)
Constructs a shell. Default settings are initialized with initSettings.

Parameters:
scheduler - the main program
Method Detail

viewSchedule

public void viewSchedule()
                  throws NullScheduleException,
                         Instructor.NullUserIDException
Display a schedule view for the given schedule with the given information specified in viewSettings, filterOptions, and advancedFilters Pre: //The schedule to be viewed cannot be null schedule != null Post: //A view with a mode corresponding to viewMode is drawn. if (viewMode == ViewMode.LIST) then (return == new ListViewUI()); else (return == new CalendarViewUI()) //If schedule is null, then throw exception if (schedule == null) then throw = NullScheduleException

Throws:
Instructor.NullUserIDException - check instructor validity
NullScheduleException - check for null schedule

initSettings

public void initSettings()
Initializes the View object with some default view settings. The default settings views the schedule by course, by Mondays, and in list mode. A few filter options are turned on.


autoView

public void autoView()
This method creates a view on the screen immediately after a new schedule is generated. It uses the current view settings, which are the default settings if no schedule has been viewed yet. No courses, instructors, or locations of the new schedule are filtered out by default. A user can replace this view with a new view by course, instructor, or location from under the view menu.


getAdvancedFilter

public AdvancedFilter getAdvancedFilter()
Return the advancedFilter object.

Returns:
the advanced filters object

setViewSettings

public void setViewSettings(ViewSettings viewSettings)
Set viewSettings to the new viewSettings object.

Parameters:
viewSettings - Viewing settings for this schedule view Pre: Post: //Updated this.viewSettings must be consistent with changes made from GUI this.viewSettings == viewSettings

getViewSettings

public ViewSettings getViewSettings()
Return the viewSettings object.

Returns:
ViewSettings object

setViewCourseFilter

public void setViewCourseFilter(ViewCourseFilter newCourseFilter)
Set the ViewCourseFilter object to a new one.

Parameters:
newCourseFilter - new ViewCourseFilter object

setViewInstructorFilter

public void setViewInstructorFilter(ViewInstructorFilter newInstrFilter)
Set the ViewInstructorFilter object to a new one;

Parameters:
newInstrFilter - new ViewInstructorFilter object

setViewLocationFilter

public void setViewLocationFilter(ViewLocationFilter newLocationFilter)
Set the ViewLocationFilter object to a new one;

Parameters:
newLocationFilter - new ViewLocationFilter object

getViewCourseFilter

public ViewCourseFilter getViewCourseFilter()
Return the ViewCourseFilter object.

Returns:
current filtered courses

getViewInstructorFilter

public ViewInstructorFilter getViewInstructorFilter()
Return the ViewInstructorFilter object.

Returns:
current filtered instructors

getViewLocationFilter

public ViewLocationFilter getViewLocationFilter()
Return the ViewLocationFilter object;

Returns:
current filtered locations

setSchedule

public void setSchedule(Schedule schedule)
Associate a new schedule with the view.

Parameters:
schedule - the schedule to be viewed

getListView

public ListView getListView()
Return the listView object;

Returns:
the list view model data.

getCalendarView

public CalendarView getCalendarView()
Return the calendarView object.

Returns:
the calendar view model data.

update

public void update(java.util.Observable O,
                   java.lang.Object arg)
Updates the top level UI when one of its observable components changes. Only the calendar or list is updated depending on the active mode.

Specified by:
update in interface java.util.Observer
Parameters:
O - the observable class changed its state
arg - the argument passed by the observable class through notifyAll

getSchedule

public Schedule getSchedule()
Return the schedule to be viewed.

Returns:
current schedule associated with the view