defaultWorkingTime.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setWorkingHours(null);
CalendarService service=CalendarService.getInstance();
WorkingCalendar wc=form.getCalendar();
service.makeDefaultDays(wc,sdCalendar.getSelectedFixedIntervals(), sdCalendar.getSelectedWeekDays());
dirtyWorkingHours = false;
updateWorkingHours();
updateView();
clearLastSelection();
}});
nonWorking.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setWorkingHours(null);
CalendarService service=CalendarService.getInstance();
WorkingCalendar wc=form.getCalendar();
WorkingCalendar copy = wc.makeScratchCopy();
try {
// try on copy first
service.setDaysNonWorking(copy,sdCalendar.getSelectedFixedIntervals(), sdCalendar.getSelectedWeekDays());
service.setDaysNonWorking(wc,sdCalendar.getSelectedFixedIntervals(), sdCalendar.getSelectedWeekDays());
} catch (InvalidCalendarException e1) {
Alert.error(e1.getMessage(),ChangeWorkingTimeDialogBox.this);
return;
}
dirtyWorkingHours = false;
updateWorkingHours();
updateView();
clearLastSelection();
}});
working.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
CalendarService service=CalendarService.getInstance();
WorkingCalendar wc=form.getCalendar();
setWorkingHours(defaultWorkingHours);
WorkingCalendar copy = wc.makeScratchCopy();
try {
service.setDaysWorkingHours(copy,sdCalendar.getSelectedFixedIntervals(), sdCalendar.getSelectedWeekDays(),defaultWorkingHours);
service.setDaysWorkingHours(wc,sdCalendar.getSelectedFixedIntervals(), sdCalendar.getSelectedWeekDays(),defaultWorkingHours);
dirtyWorkingHours = false;
updateWorkingHours();
updateView();
} catch (WorkRangeException e1) {
e1.printStackTrace();
} catch (InvalidCalendarException e2) {
Alert.error(e2.getMessage(),ChangeWorkingTimeDialogBox.this);
return;
}
clearLastSelection();
}});
sdCalendar.addPropertyChangeListener(new PropertyChangeListener(){
final CalendarService service=CalendarService.getInstance();
public void propertyChange(PropertyChangeEvent e){
// System.out.println("propery change");
String property=e.getPropertyName();
if ("lastDisplayedDate".equals(property)||"firstDisplayedDate".equals(property)){ //$NON-NLS-1$ //$NON-NLS-2$
updateView();
}else if ("selectedDates".equals(property)){ //$NON-NLS-1$
updateWorkingHours();
}
dirtyWorkingHours = false;
}
});
setCal(form.getCalendar());
// add listener at end so above setCal won't trigger update
calendarType.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
WorkingCalendar cal = (WorkingCalendar)calendarType.getSelectedItem();
if (cal != form.getCalendar()) {
setNewCalendar(cal);
setEditable(isCalEditable(cal));
}
}});