/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package clips.shedule.individual;
import TimeTable.DayOfWeek;
import TimeTable.JTimeTable;
import cli_fmw.main.ClipsException;
import cli_fmw.main.MainWindow;
import cli_fmw.main.audit.AuditManager;
import clips.delegate.shedule.individual.SheduleIndividualLocal;
import clips.delegate.shedule.individual.WeekIndex;
import clips.shedule.template.SheduleTemplateTableModel;
import cli_fmw.utils.MessageBox;
import clips.delegate.shedule.SheduledDay;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
/**
* та же модель, что и при просомтре запланированных данных,
* за исключением того, что есть контекстное меню
* @author axe
*/
public class SheduleIndividualExceptionTableModel extends SheduleTemplateTableModel {
private AuditManager am;
private SheduledDay sheduledDay;
SheduleIndividualExceptionTableModel(SheduledDay sheduledDay,
SheduleIndividualLocal sil, WeekIndex weekIndex, AuditManager am) throws ClipsException {
super(sil, weekIndex, am);
this.sheduledDay = sheduledDay;
}
/**
* Функция вызывается при нажатии клавиши контестного меню
* @param table - таблица
* @param x - позиция курсора мыши
* @param y - позиция курсора мыши
*/
@Override
public void contextMenu(JTimeTable table, int x, int y) {
DayOfWeek dayOfWeek = table.getDay().getDayOfWeek();
JPopupMenu popup = new JPopupMenu();
JMenuItem menuItem = new JMenuItem("Добавить работу...");
menuItem.addActionListener(new AddNewSpanAction(dayOfWeek));
popup.add(menuItem);
menuItem = new JMenuItem("Подробнее...");
menuItem.addActionListener(new DetailsBtnListener(dayOfWeek));
popup.add(menuItem);
popup.show(table, x, y);
}
/**
*
*/
class DetailsBtnListener implements ActionListener {
DayOfWeek dayOfweek;
public DetailsBtnListener (DayOfWeek dayOfweek) {
this.dayOfweek = dayOfweek;
}
@Override
public void actionPerformed(ActionEvent arg0) {
try {
SheduleIndividualExceptionDialog dlg =
new SheduleIndividualExceptionDialog(MainWindow.mainWindow,
sil, sheduledDay, currentweekIndex, dayOfweek, am);
dlg.setVisible(true);
rebuildContent(currentweekIndex);
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}
}
}