/*Millersville University Faculty Scheduler System Written by: Joye E. Mills and Dawn White, Fall 1996 Purpose: This java applet has been written to allow the MU Faculty to: (a) Input their schedule for a given semester (b) Update their schedule (c) Show all faculty members schedules (d) Show a particular faculty member's schedule (e) Show all the available times and days that any N number of faculty members can meet (f) Notify the parties of the meeting request by e-mail */ //************************************************************************* import java.applet.*; import java.util.*; import java.awt.*; import java.io.*; public class SchedulerApplet extends Applet { public void init() { setLayout(new BorderLayout()); Panel p = new Panel(); p.setLayout(new GridLayout(3,2)); p.add(new Button("Add Faculty Schedule")); p.add(new Button("Edit Faculty Schedule")); p.add(new Button("Show All Faculty Schedules")); p.add(new Button("Show Individual Schedule")); p.add(new Button("Find Meeting Time")); p.add(new Button("Notify Faculty via Email")); add("Center", p); }// END init public boolean action (Event e, Object arg) { if (e.target instanceof Button) { String label = (String)arg; if (label.equals ("Add Faculty Schedule")) { Frame f = new Frame("Add Faculty Schedule"); f.show(); addWindow Add = new addWindow(this, f, "Add Schedule"); Add.resize(375, 300); Add.pack(); Add.show(); return true; } else if (label.equals ("Edit Faculty Schedule")) { Frame f = new Frame("Edit Faculty Schedule"); f.show(); editWindow Edit = new editWindow(this,f,"Edit Faculty Schedule"); Edit.resize(250,400); Edit.pack(); Edit.show(); return true; } else if (label.equals ("Show All Faculty Schedules")) { Frame f = new Frame("Show All Faculty Schedules"); f.show(); showAllWindow ShowAll = new showAllWindow(this, f, "Show All Faculty Schedules"); ShowAll.resize(250, 400); ShowAll.show(); return true; } else if (label.equals ("Show Individual Schedule")) { Frame f = new Frame("Show Individual Schedule"); f.show(); showIndWindow ShowInd = new showIndWindow(this,f,"Show Individual Schedule"); ShowInd.resize(250, 400); ShowInd.show(); return true; } else if (label.equals ("Find Meeting Time")) { Frame f = new Frame("Find Meeting Time"); f.show(); findMeetingWindow FindMeeting = new findMeetingWindow(this,f, "Find Meeting Time"); FindMeeting.resize(250,350); FindMeeting.show(); return true; } else if (label.equals ("Notify Faculty via Email")) { Frame f = new Frame("Notify Faculty via Email"); f.show(); notifyFacultyWindow NotifyFaculty = new notifyFacultyWindow(this,f,"Notify Faculty via Email"); NotifyFaculty.resize(350, 450); NotifyFaculty.show(); return true; } } return false; } } //END of SchedulerApplet //******************ADD WINDOW******************************************* class addWindow extends Frame { protected SchedulerApplet s; public Choice faculty, day; public TextField stop, start, desc; public String Name, Day, StartTime, StopTime, Commitment; public String afaculty, aday, astart, astop, acommitment; public addWindow(SchedulerApplet s, Frame parent, String title) { setTitle(title); this.setLayout(new BorderLayout()); this.s = s; Panel p1 = new Panel(); p1.setLayout(new GridLayout(6,6)); Label prompt1 = new Label("Select a faculty member: "); Choice faculty = new Choice(); faculty.addItem("Chaudhary"); faculty.addItem("Davis"); faculty.addItem("Hutchens"); faculty.addItem("Liffick"); faculty.addItem("Mertz"); faculty.addItem("Liffick"); faculty.addItem("Ross"); faculty.addItem("Webster"); Label prompt2 = new Label("Select a day: "); Choice day = new Choice(); day.addItem("Monday"); day.addItem("Tuesday"); day.addItem("Wednesday"); day.addItem("Thursday"); day.addItem("Friday"); Label prompt3 = new Label("Commitment: "); TextField desc = new TextField("", 20); Label prompt4 = new Label("Select a Start Time: "); TextField start = new TextField("",5); Label prompt5 = new Label("Select a Stop Time: "); TextField stop = new TextField("",5); Button done = new Button("DONE"); p1.add(prompt1); p1.add(faculty); p1.add(prompt2); p1.add(day); p1.add(prompt4); p1.add(start); p1.add(prompt5); p1.add(stop); p1.add(prompt3); p1.add(desc); p1.add(done); this.add("Center", p1); p1.show(); this.pack(); this.show(); } //Trying to get the values from off of the frame public void readScreen() { Name = faculty.getSelectedItem(); Day = day.getSelectedItem(); StartTime=start.getText(); StopTime = stop.getText(); Commitment = desc.getText(); } public boolean action (Event e, Object arg) { if (e.target instanceof Button) { String label = (String)arg; if (label.equals ("DONE")) { /* readScreen(); try { PrintStream output = new PrintStream(new FileOutputStream("data.dat")); writeData(output); } catch (IOException y) { System.out.print("Error"); System.exit (1); }*/ //Close the Window if (this.isShowing()) { this.hide(); this.dispose(); return true; } } } return false; } public void writeData(PrintStream os) throws IOException { os.print(Name); os.print("|"); os.print(Day); os.print("|"); os.print(StartTime); os.print("|"); os.print(StopTime); os.print("|"); os.println(Commitment); } public void readData(DataInput in) throws IOException { String line = in.readLine(); if (line == null) return; StringTokenizer t = new StringTokenizer(line, "|"); afaculty = t.nextToken(); aday = t.nextToken(); astart = t.nextToken(); astop = t.nextToken(); acommitment = t.nextToken(); } }//END addWindow //*********** Schedule Window************************** class scheduleWindow extends Frame { protected SchedulerApplet s; public scheduleWindow(String title) { setTitle(title); this.setLayout(new BorderLayout()); Panel p1 = new Panel(); p1.setLayout(new GridLayout(6,5)); Label label2 = new Label("Day"); Label label3 = new Label("Start Time"); Label label4 = new Label("Stop Time"); Label label5 = new Label("Commitment"); TextField day1 = new TextField("", 15); TextField start1 = new TextField("", 15); TextField stop1 = new TextField("", 15); TextField commit1 = new TextField("", 15); Button Next = new Button("NEXT"); Button Done = new Button("DONE"); p1.add(label2); p1.add(day1); p1.add(label3); p1.add(start1); p1.add(label4); p1.add(stop1); p1.add(label5); p1.add(commit1); p1.add(Next); p1.add(Done); p1.show(); this.add("Center", p1); } public boolean action (Event e, Object arg) { if (e.target instanceof Button) { String label = (String)arg; if (label.equals ("DONE")) { //Close the Window if (this.isShowing()) { this.hide(); this.dispose(); return true; } } } return false; } } // End Schedule Window //*********************Edit Window**************************************** class editWindow extends Frame { protected SchedulerApplet s; public editWindow(SchedulerApplet s, Frame parent, String title) { setTitle(title); this.setLayout(new BorderLayout()); this.s = s; Panel p1 = new Panel(); p1.setLayout(new GridLayout(9,1)); Label prompt = new Label ("Select a Faculty Member: "); Button Chaudhary = new Button("Chaudhary"); Button Davis = new Button("Davis"); Button Hutchens = new Button("Hutchens"); Button Liffick = new Button("Liffick"); Button Mertz = new Button("Mertz"); Button Ross = new Button("Ross"); Button Webster = new Button("Webster"); Button Cancel = new Button("CANCEL"); p1.add(prompt); p1.add(Chaudhary); p1.add(Davis); p1.add(Hutchens); p1.add(Liffick); p1.add(Mertz); p1.add(Ross); p1.add(Webster); p1.add(Cancel); this.add("Center", p1); p1.show(); this.pack(); this.show(); } public boolean action (Event e, Object arg) { if (e.target instanceof Button) { String label = (String)arg; if (label.equals ("Chaudhary")) { Frame g = new Frame(); g.show(); scheduleWindow Schedule = new scheduleWindow("Edit Schedule for Chaudhary"); Schedule.resize(300,300); Schedule.show(); return true; } if (label.equals ("Davis")) { Frame g = new Frame(); g.show(); scheduleWindow Schedule = new scheduleWindow("Edit Schedule for Davis"); Schedule.resize(300,300); Schedule.show(); return true; } if (label.equals ("Hutchens")) { Frame g = new Frame(); g.show(); scheduleWindow Schedule = new scheduleWindow("Edit Schedule for Hutchens"); Schedule.resize(300,300); Schedule.show(); return true; } if (label.equals ("Liffick")) { Frame g = new Frame(); g.show(); scheduleWindow Schedule = new scheduleWindow("Edit Schedule for Liffick"); Schedule.resize(300,300); Schedule.show(); return true; } if (label.equals ("Mertz")) { Frame g = new Frame(); g.show(); scheduleWindow Schedule = new scheduleWindow("Edit Schedule for Mertz"); Schedule.resize(300,300); Schedule.show(); return true; } if (label.equals ("Ross")) { Frame g = new Frame(); g.show(); scheduleWindow Schedule = new scheduleWindow("Edit Schedule for Ross"); Schedule.resize(300,300); Schedule.show(); return true; } if (label.equals ("Webster")) { Frame g = new Frame(); g.show(); scheduleWindow Schedule = new scheduleWindow("Edit Schedule for Webster"); Schedule.resize(300,300); Schedule.show(); return true; } if (label.equals ("CANCEL")) { if (this.isShowing()) { this.hide(); this.dispose(); return true; } } } return false; } } //END edit Window //************showAllWindow***************** class showAllWindow extends Frame { protected SchedulerApplet s; public showAllWindow(SchedulerApplet s, Frame parent, String title) { setTitle(title); this.setLayout(new BorderLayout()); this.s = s; Panel p1 = new Panel(); p1.setLayout(new GridLayout(9,1)); Label prompt = new Label ("Faculty Schedules"); Button Done = new Button ("DONE"); p1.add(prompt); p1.add(Done); this.add("Center", p1); p1.show(); this.pack(); this.show(); } public boolean action (Event e, Object arg) { if (e.target instanceof Button) { String label = (String)arg; if (label.equals ("DONE")) { //Close the Window if (this.isShowing()) { this.hide(); this.dispose(); return true; } } } return false; } } //************Show Individual Schedules********************* class showIndWindow extends Frame { protected SchedulerApplet s; public showIndWindow(SchedulerApplet s, Frame parent, String title) { setTitle(title); this.setLayout(new BorderLayout()); this.s = s; Panel p1 = new Panel(); p1.setLayout(new GridLayout(9,1)); Label prompt = new Label ("Select a Faculty Member: "); Button Chaudhary = new Button("Chaudhary"); Button Davis = new Button("Davis"); Button Hutchens = new Button("Hutchens"); Button Liffick = new Button("Liffick"); Button Mertz = new Button("Mertz"); Button Ross = new Button("Ross"); Button Webster = new Button("Webster"); Button Cancel = new Button("CANCEL"); p1.add(prompt); p1.add(Chaudhary); p1.add(Davis); p1.add(Hutchens); p1.add(Liffick); p1.add(Mertz); p1.add(Ross); p1.add(Webster); p1.add(Cancel); this.add("Center", p1); p1.show(); this.pack(); this.show(); } public boolean action (Event e, Object arg) { if (e.target instanceof Button) { String label = (String)arg; if (label.equals ("Chaudhary")) { Frame Schedule = new scheduleWindow("Chaudhary's Schedule"); Schedule.pack(); Schedule.show(); return true; } if (label.equals ("Davis")) { Frame Schedule = new scheduleWindow("Davis' Schedule"); Schedule.pack(); Schedule.show(); return true; } if (label.equals ("Hutchens")) { Frame Schedule = new scheduleWindow("Hutchens' Schedule"); Schedule.pack(); Schedule.show(); return true; } if (label.equals ("Liffick")) { Frame Schedule = new scheduleWindow("Liffick's Schedule"); Schedule.pack(); Schedule.show(); return true; } if (label.equals ("Mertz")) { Frame Schedule = new scheduleWindow("Mertz's Schedule"); Schedule.pack(); Schedule.show(); return true; } if (label.equals ("Ross")) { Frame Schedule = new scheduleWindow("Ross's Schedule"); Schedule.pack(); Schedule.show(); return true; } if (label.equals ("Webster")) { Frame Schedule = new scheduleWindow("Webster's Schedule"); Schedule.pack(); Schedule.show(); return true; } if (label.equals ("CANCEL")) { //Close the Window if (this.isShowing()) { this.hide(); this.dispose(); return true; } } } return false; } } //********* Find Meeting Time Window************************ class findMeetingWindow extends Frame { protected SchedulerApplet s; public findMeetingWindow(SchedulerApplet s, Frame parent, String title) { setTitle(title); this.setLayout(new BorderLayout()); this.s = s; Panel p1 = new Panel(); p1.setLayout(new GridLayout(9,1)); Label prompt = new Label ("Select the faculty you want to schedule a meeting with: "); Checkbox Chaudharybox = new Checkbox("Chaudhary"); Checkbox Davisbox = new Checkbox("Davis"); Checkbox Hutchensbox = new Checkbox("Hutchens"); Checkbox Liffickbox = new Checkbox("Liffick"); Checkbox Mertzbox = new Checkbox("Mertz"); Checkbox Rossbox = new Checkbox("Ross"); Checkbox Websterbox = new Checkbox("Webster"); Button Done = new Button ("DONE"); p1.add(prompt); p1.add(Chaudharybox); p1.add(Davisbox); p1.add(Hutchensbox); p1.add(Liffickbox); p1.add(Mertzbox); p1.add(Rossbox); p1.add(Websterbox); p1.add(Done); this.add("Center", p1); p1.show(); this.pack(); this.show(); } public boolean action (Event e, Object arg) { if (e.target instanceof Button) { String label = (String)arg; if (label.equals ("DONE")) { //Close the Window if (this.isShowing()) { this.hide(); this.dispose(); return true; } } } return false; } } //******************Notify Faculty Window****************** class notifyFacultyWindow extends Frame { protected SchedulerApplet s; public notifyFacultyWindow(SchedulerApplet s, Frame parent, String title) { setTitle(title); this.setLayout(new BorderLayout()); this.s = s; Panel p1 = new Panel(); p1.setLayout(new GridLayout(9,1)); Label prompt = new Label ("Notify faculty"); Button Done = new Button ("DONE"); p1.add(prompt); p1.add(Done); this.add("Center", p1); p1.show(); this.pack(); this.show(); } public boolean action (Event e, Object arg) { if (e.target instanceof Button) { String label = (String)arg; if (label.equals ("DONE")) { //Close the Window if (this.isShowing()) { this.hide(); this.dispose(); return true; } } } return false; } }