public void btnSaveCourse_Pressed() { Schedule schedule = Manager.INSTANCE.currentEditingSchedule; Classroom classroom = null; if (!chBxClassrooms.getSelectionModel().isEmpty()) { String classroomString = chBxClassrooms.getSelectionModel().getSelectedItem(); for (Classroom classroomLocal : Manager.INSTANCE.classrooms) { if (classroomLocal.getInitials().equals(classroomString)) { classroom = classroomLocal; break; } } String alertMessage = ""; String clashes = ""; ICourse iCourse = Manager.INSTANCE.currentEditignICourse; for (Professor professor : ((Lecture) iCourse).getProfessors()) { String pClash = CourseModificationChecker.professorClash(professor, schedule, iCourse); if (!pClash.equals("")) { clashes += professor.getName() + " " + professor.getLastnameFather() + ":" + pClash + "\n"; } } if (!clashes.equals("")) { alertMessage += "No se puede usar este horario, ya que tiene problemas de topes de horarios de profesores:\n" + clashes; } clashes = CourseModificationChecker.classroomClash( classroom, schedule, Manager.INSTANCE.currentEditignICourse); if (clashes != "") { alertMessage += "No se puede crear la clase debido a que la sala esta ocupada en ese horario por otro(s) curso(s):\n" + clashes; } if (!alertMessage.equals("")) { ViewUtilities.showAlert(alertMessage); } else { Manager.INSTANCE.currentEditignICourse.setSchedule(schedule); Manager.INSTANCE.currentEditignICourse.setClassroom(classroom); if (isCreating) { Manager.INSTANCE.currentEditignCourse.addCourse(Manager.INSTANCE.currentEditignICourse); } Manager.INSTANCE.currentEditignICourse = null; Manager.INSTANCE.currentEditingSchedule = null; super.btnBack_Pressed(); } } else { ViewUtilities.showAlert("Primero debes asignar una sala a la clase"); } }
public void btnRemoveICourse_Pressed() { if (Manager.INSTANCE.currentEditignICourse != null) { ArrayList<ICourse> courses = Manager.INSTANCE.currentEditignCourse.getCourses(); if (courses.contains(Manager.INSTANCE.currentEditignICourse)) { courses.remove(Manager.INSTANCE.currentEditignICourse); Manager.INSTANCE.currentEditignCourse.setCourses(courses); super.btnBack_Pressed(); } else { ViewUtilities.showAlert("The class is not in the classes of the course"); } } else { ViewUtilities.showAlert("The ICourse is null"); } }