// Y lo cargo
final EstadoPresoController estadoPresoController = new EstadoPresoController(null, p, true);
final WindowsCreator ventana = new WindowsCreator(PrincipalController.instanciaControllerPrincipal(), estadoPresoController, true);
estadoPresoController.setPanelListener(new PanelListener() {
public void onPanelClose() {
ventana.dispose();
}
});
listener.onPanelClose();
} catch (UIValidateException ex) {
MessageGenerator.showWarningMsj("Guardar", ex.getMessage());
}
}
});
eliminarButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (p != null) {
if (MessageGenerator.showYesNoMsj("Eliminar", "Desea eliminar el detenido? No podra deshacer el cambio.") == JOptionPane.YES_OPTION) {
p.setEnabled(false);
Celda c = (Celda) ec.createQuery("select a.celda from AsignacionPresoCelda a where a.preso = :preso and a.fechaDesde >= (select max(a2.fechaDesde) from AsignacionPresoCelda a2 where a2.preso = a.preso)", AsignacionPresoCelda.class).setParameter("preso", p).getSingleResult();
modificarEstadoCelda(c);
ec.updateEntity(p);
MessageGenerator.showWarningMsj("Eliminar", "Dato Eliminado");
listener.onPanelClose();
}
}
}
});
asignarCeldaButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final AsignacionPresoController asignacionPresoController = new AsignacionPresoController(p, false);
final WindowsCreator v2 = new WindowsCreator(PrincipalController.instanciaControllerPrincipal(), asignacionPresoController, true);
asignacionPresoController.setPanelListener(new PanelListener() {
public void onPanelClose() {
v2.dispose();
}
});
listener.onPanelClose();
}
});
asignarEstadoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final EstadoPresoController estadoPresoController = new EstadoPresoController(null, p, false);
final WindowsCreator ventana = new WindowsCreator(PrincipalController.instanciaControllerPrincipal(), estadoPresoController, true);
estadoPresoController.setPanelListener(new PanelListener() {
public void onPanelClose() {
ventana.dispose();
}
});
listener.onPanelClose();
}
});
cargarFotoButt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileChooser chooser = new FileChooser();
int returnVal = chooser.showOpenDialog(PresoController.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
try {
File file = chooser.getSelectedFile();
if (file.exists()) {
System.out.println("File " + file.getPath());
fotoPersonal = new ImageIcon(file.getPath());
if (fotoPersonal.getIconHeight() <= ICON_HEIGHT && fotoPersonal.getIconWidth() <= ICON_WIDTH) {
fotoLabel.setIcon(fotoPersonal);
InputStream fis = new FileInputStream(file);
bufferFoto = new byte[(int) file.length()];
int readers = fis.read(bufferFoto);
System.out.println("Hola");
} else {
MessageGenerator.showWarningMsj("Imagen", "La imagen es muy grande");
}
}
} catch (IOException ex) {
Logger.getLogger(PresoController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
cargarHuellaBt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileChooser chooser = new FileChooser();
int returnVal = chooser.showOpenDialog(PresoController.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
//This is where a real application would open the file.
System.out.println("File " + file.getPath());
if (file.exists()) {
System.out.println("Tamaño " + file.length());
InputStream fis = null;
try {
System.out.println("File " + file.getPath());
huellaDactilar = new ImageIcon(file.getPath());
if (huellaDactilar.getIconHeight() <= ICON_HEIGHT && huellaDactilar.getIconWidth() <= ICON_WIDTH) {
huellaLabel.setIcon(huellaDactilar);
fis = new FileInputStream(file);
bufferHuella = new byte[(int) file.length()];
int readers = fis.read(bufferHuella);
System.out.println("Hola");
} else {
MessageGenerator.showWarningMsj("Imagen", "La imagen es muy grande");
}
} catch (IOException ex) {
Logger.getLogger(PresoController.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
fis.close();
} catch (IOException ex) {
Logger.getLogger(PresoController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
}
});
salirButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
listener.onPanelClose();
}
});
verCondenaButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final ListadoCondenaController listadoCondena = new ListadoCondenaController(p);
final WindowsCreator ventana = new WindowsCreator(PrincipalController.instanciaControllerPrincipal(), listadoCondena, true);
listadoCondena.setPanelListener(new PanelListener() {
public void onPanelClose() {
ventana.dispose();
}
});
}
});
}