window.setBeginDate(course.getBeginDate()); window.setEndDate(course.getEndDate());
if (columns.length > 1) { window.setStartHour(columns[0]); window.setEndHour(columns[columns.length-1]); } else window.setBeginDate(course.getBeginDate()); if (rows.length > 0) { Calendar date = Calendar.getInstance(); date.setTime(mainFrame.getDateSelected()); date.set(Calendar.DAY_OF_WEEK, rows[0] + 2); window.setDateCourse(date); } else window.setEndDate(course.getEndDate());
    public void actionPerformed(ActionEvent arg0) {        Course course = ClipboardManager.getCourse();                if (course == null)            return;                course.setIdCourse(null);        AddModifyCourseWindow window = new AddModifyCourseWindow(AddModifyCourseWindow.TYPE_MODIFY);        window.setBeginDate(course.getBeginDate());        window.setEndDate(course.getEndDate());        window.setTypeCourse(course.getIdCourseType().getNameCourseType());                try {            if (mainFrame.getFormationSelected() != null)                window.setCourseFormation(mainFrame.getFormationSelected());            else {                Formation formation = new Formation();                if (mainFrame.getSubjectSelected() != null) {                    formation.setIdFormation(mainFrame.getSubjectSelected().getIdFormation());                } else if (mainFrame.getCourseSelected() != null) {                    formation.setIdFormation(mainFrame.getCourseSelected().getIdFormation());                }                window.setCourseFormation(DaoManager.getFormationDao().getFormation(formation, null));            }            TakePartGroupSubjectCourse takePart = (TakePartGroupSubjectCourse) course.getGroupsSubjectsTakingPart().toArray()[0];            window.setIdGroup(takePart.getIdGroup());            window.setTeachers(course.getTeachersDirecting());            window.setRooms(course.getRooms());            window.setMaterials(course.getMaterials());            window.show();            if (window.isOk()) {                Calendar beginDate = window.getBeginDate();        	    beginDate.set(Calendar.HOUR_OF_DAY, beginDate.get(Calendar.HOUR_OF_DAY) + (beginDate.get(Calendar.DST_OFFSET) == 0 ? 1 : 2));        	    course.setBeginDate(beginDate);        	            	    Calendar endDate = window.getEndDate();        	    endDate.set(Calendar.HOUR_OF_DAY, endDate.get(Calendar.HOUR_OF_DAY) + (endDate.get(Calendar.DST_OFFSET) == 0 ? 1 : 2));        	    course.setEndDate(endDate);        	            	    course.setTeachersDirecting(new HashSet());        	    course.setTeachers(new HashSet());        	    Collection teachers = window.getTeachers();        	    for (Iterator i = teachers.iterator(); i.hasNext(); ) {        	        User user = (User) i.next();        	        course.addTeacherDirecting(new IsDirectedByCourseTeacher(user,course));        	        course.addTeacher(user);        	    }        	            	    course.setRooms(new HashSet());        	    Collection rooms = window.getPlaceCourse();        	    for (Iterator i = rooms.iterator(); i.hasNext(); )        	        course.addRoom((Room) i.next());        	            	    course.setMaterials(new HashSet());        	    Collection materials = window.getCourseEquipment();        	    for (Iterator i = materials.iterator(); i.hasNext(); )        	        course.addMaterial((Material) i.next());                course.setIdCourseType(DaoManager.getTimetableDao().getTypeCourse(window.getTypeCourse()));	            course = DaoManager.getTimetableDao().addCourse(course);	            /*if (course.getBeginDate().getTimeInMillis() >= mainFrame.getBeginPeriod().getTimeInMillis() &&                        course.getEndDate().getTimeInMillis() <= mainFrame.getEndPeriod().getTimeInMillis()) {	                course.getBeginDate().set(Calendar.HOUR_OF_DAY, window.getBeginDate().get(Calendar.HOUR_OF_DAY));	                course.getEndDate().set(Calendar.HOUR_OF_DAY, window.getEndDate().get(Calendar.HOUR_OF_DAY));	                mainFrame.getModel().getTimetable().addCourse(course);	                mainFrame.getModel().fireRefreshCourse(course, BoTModel.TYPE_ADD);                }*/	            JOptionPane.showMessageDialog(null, "Ajout effectu avec succs", "Information", JOptionPane.INFORMATION_MESSAGE);            }        } catch (Exception e) {            JOptionPane.showMessageDialog(null, "Une erreur interne est survenue", "Erreur", JOptionPane.ERROR_MESSAGE);        }    }