package editor;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;
import controllers.ControllerFactory;
import controllers.HalconController;
import vista.AbmPersonal;
import vista.ModificarPersonal;
import vista.MostrarPersonal;
import base.Personal;
public class EditorPersonal extends Editor implements TableCellEditor, ActionListener {
/**
*
*/
private HalconController halconController = ControllerFactory.GetHalconController();
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
private AbmPersonal a;
@SuppressWarnings("unchecked")
public EditorPersonal(AbmPersonal abm, int m, int e) {
super(m,e);
this.a=abm;
}
public void actionPerformed(ActionEvent e) {
int id = Integer.parseInt((String) a.table.getValueAt(fila, 0));
Personal personal = halconController.getPersonalById(id);
if (columna==mod){
ModificarPersonal m = new ModificarPersonal(this.a, personal);
a.removeAll();
a.add(m);
}
else
if(columna==eli){
int option=JOptionPane.showConfirmDialog(null, "�Seguro que desea eliminar al cliente?");
if (option==JOptionPane.YES_OPTION)
halconController.DeletePersonalByClass(personal);
}
else
{
MostrarPersonal m = new MostrarPersonal(this.a, personal);
a.removeAll();
a.add(m);
}
a.repaint();
fireEditingStopped();
a.cargarTabla();
}
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}
}