panel.addParagraph(additionalText);
panel.addRow();
panel.add(additionalComponent, cc.xyw(2, panel.getRow(), panel.getColumnCount() - 1));
}
final ProgramRangeSelectionPanel programSelection = ProgramRangeSelectionPanel.createPanel(mPrgTime.getProgram(),(short)6);
panel.addParagraph(mLocalizer.msg("programSelection","Program selection"));
panel.addRow();
panel.add(programSelection, cc.xyw(2, panel.getRow(), panel.getColumnCount() - 1));
programSelection.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if(!e.getValueIsAdjusting()) {
/* prevent concurrent changing of end date */
if(!mEndDateChanging) {
mProgramSelectionChanging = true;
Program[] progs = ((ProgramList)e.getSource()).getSelectedPrograms();
if(progs != null) {
Program prog = progs[progs.length-1];
Calendar c = Calendar.getInstance();
c.setTimeInMillis(prog.getDate().getCalendar().getTimeInMillis());
c.set(Calendar.HOUR_OF_DAY, prog.getHours());
c.set(Calendar.MINUTE, prog.getMinutes());
if (prog.getLength() <= 0) {
c.add(Calendar.MINUTE, 1);
} else {
c.add(Calendar.MINUTE, prog.getLength());
}
c.set(Calendar.SECOND, 0);
c.add(Calendar.MINUTE, postTime);
mEnd.setValue(c.getTime());
mProgramSelectionChanging = false;
}
}
}
}
});
mEnd.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
try {
/* prevent concurrent changing of end date */
if(!mProgramSelectionChanging) {
mEndDateChanging = true;
programSelection.setEndDate(mEnd.getDate());
mEndDateChanging = false;
}
}catch(Throwable t) {t.printStackTrace();}
}
});