/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Vista;
import Controlador.AlquilerControlador;
import Modelo.Apunte;
import Modelo.Articulo;
import Modelo.Usuario;
import java.util.LinkedHashMap;
import Controlador.Vistas;
/**
*
* @author tincho
*/
public class Main extends javax.swing.JFrame {
private AlquilerControlador valc = new AlquilerControlador();
private LinkedHashMap<Integer,Articulo> mapaArticulos = new LinkedHashMap<>();
private LinkedHashMap<Integer,Usuario> mapaUsuarios = new LinkedHashMap<>();
/**
* Creates new form Main
*/
public Main() {
initComponents();
Usuario u = new Usuario(null, null, WIDTH, null);
Apunte a = new Apunte(FRAMEBITS, null, null, null, WIDTH, null, null);
this.mapaUsuarios = u.deserializar();
this.mapaArticulos = a.deserializar();
}
public void salir() {
Usuario u = new Usuario(null, null, WIDTH, null);
Apunte a = new Apunte(FRAMEBITS, null, null, null, WIDTH, null, null);
u.serializar(mapaUsuarios);
a.serializar(mapaArticulos);
System.exit(0);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabelArticulos = new javax.swing.JLabel();
jLabelAlquiler = new javax.swing.JLabel();
jButtonAlquilerAgregar = new javax.swing.JButton();
jButtonAlquilerLeer = new javax.swing.JButton();
jButtonAlquilerModificar = new javax.swing.JButton();
jButtonAlquilerEliminar = new javax.swing.JButton();
jLabelBuscarArticulo = new javax.swing.JLabel();
jLabelBuscarID = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextAreaArticulo = new javax.swing.JTextArea();
jTextFieldID = new javax.swing.JTextField();
jButtonArticuloBuscar = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenuAlquiler = new javax.swing.JMenu();
jMenuItemCrear = new javax.swing.JMenuItem();
jMenuItemModificar = new javax.swing.JMenuItem();
jMenuItemLeer = new javax.swing.JMenuItem();
jMenuItemEliminar = new javax.swing.JMenuItem();
jMenuArticulo = new javax.swing.JMenu();
jMenuItemBuscar = new javax.swing.JMenuItem();
jMenuAdministracionInterna = new javax.swing.JMenu();
jMenuItemArticulos = new javax.swing.JMenuItem();
jMenuItemUsuarios = new javax.swing.JMenuItem();
jMenuSalir = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
setTitle("Sistema de Biblioteca");
setResizable(false);
jLabelArticulos.setText("Informacion del articulo");
jLabelAlquiler.setText("Alquiler");
jButtonAlquilerAgregar.setText("Agregar");
jButtonAlquilerAgregar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAlquilerAgregarActionPerformed(evt);
}
});
jButtonAlquilerLeer.setText("Leer");
jButtonAlquilerLeer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAlquilerLeerActionPerformed(evt);
}
});
jButtonAlquilerModificar.setText("Modificar");
jButtonAlquilerModificar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAlquilerModificarActionPerformed(evt);
}
});
jButtonAlquilerEliminar.setText("Eliminar");
jButtonAlquilerEliminar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAlquilerEliminarActionPerformed(evt);
}
});
jLabelBuscarArticulo.setText("Buscar articulo");
jLabelBuscarID.setText("ID:");
jTextAreaArticulo.setEditable(false);
jTextAreaArticulo.setColumns(20);
jTextAreaArticulo.setLineWrap(true);
jTextAreaArticulo.setRows(5);
jScrollPane2.setViewportView(jTextAreaArticulo);
jButtonArticuloBuscar.setText("Buscar");
jButtonArticuloBuscar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonArticuloBuscarActionPerformed(evt);
}
});
jMenuAlquiler.setText("Alquiler");
jMenuItemCrear.setText("Crear");
jMenuItemCrear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemCrearActionPerformed(evt);
}
});
jMenuAlquiler.add(jMenuItemCrear);
jMenuItemModificar.setText("Modificar");
jMenuItemModificar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemModificarActionPerformed(evt);
}
});
jMenuAlquiler.add(jMenuItemModificar);
jMenuItemLeer.setText("Leer");
jMenuItemLeer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemLeerActionPerformed(evt);
}
});
jMenuAlquiler.add(jMenuItemLeer);
jMenuItemEliminar.setText("Eliminar");
jMenuItemEliminar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemEliminarActionPerformed(evt);
}
});
jMenuAlquiler.add(jMenuItemEliminar);
jMenuBar1.add(jMenuAlquiler);
jMenuArticulo.setText("Articulo");
jMenuItemBuscar.setText("Buscar");
jMenuItemBuscar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemBuscarActionPerformed(evt);
}
});
jMenuArticulo.add(jMenuItemBuscar);
jMenuBar1.add(jMenuArticulo);
jMenuAdministracionInterna.setText("Administracion Interna");
jMenuItemArticulos.setText("Articulos");
jMenuItemArticulos.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemArticulosActionPerformed(evt);
}
});
jMenuAdministracionInterna.add(jMenuItemArticulos);
jMenuItemUsuarios.setText("Usuarios");
jMenuItemUsuarios.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemUsuariosActionPerformed(evt);
}
});
jMenuAdministracionInterna.add(jMenuItemUsuarios);
jMenuBar1.add(jMenuAdministracionInterna);
jMenuSalir.setText("Salir");
jMenuSalir.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jMenuSalirMouseClicked(evt);
}
});
jMenuBar1.add(jMenuSalir);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2)
.addGroup(layout.createSequentialGroup()
.addComponent(jButtonAlquilerAgregar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonAlquilerLeer))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelAlquiler)
.addGroup(layout.createSequentialGroup()
.addComponent(jButtonAlquilerEliminar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonAlquilerModificar)))
.addGap(42, 42, 42)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelBuscarArticulo)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabelBuscarID)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jButtonArticuloBuscar)
.addGap(0, 104, Short.MAX_VALUE))
.addComponent(jTextFieldID)))))))
.addGroup(layout.createSequentialGroup()
.addGap(136, 136, 136)
.addComponent(jLabelArticulos)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabelArticulos)
.addGap(5, 5, 5)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelAlquiler)
.addComponent(jLabelBuscarArticulo))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonAlquilerAgregar)
.addComponent(jButtonAlquilerLeer)
.addComponent(jLabelBuscarID)
.addComponent(jTextFieldID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonAlquilerEliminar)
.addComponent(jButtonAlquilerModificar)
.addComponent(jButtonArticuloBuscar))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButtonArticuloBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonArticuloBuscarActionPerformed
// TODO add your handling code here:
Vistas.getInstance().articulo.buscarArticulo(jTextFieldID, jTextAreaArticulo, mapaArticulos);
}//GEN-LAST:event_jButtonArticuloBuscarActionPerformed
private void jMenuSalirMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuSalirMouseClicked
// TODO add your handling code here:
salir();
}//GEN-LAST:event_jMenuSalirMouseClicked
private void jButtonAlquilerAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAlquilerAgregarActionPerformed
// TODO add your handling code here:
Vistas.getInstance().alquiler.ventanaCrear(mapaArticulos, mapaUsuarios, jTextFieldID);
}//GEN-LAST:event_jButtonAlquilerAgregarActionPerformed
private void jButtonAlquilerLeerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAlquilerLeerActionPerformed
// TODO add your handling code here:
Vistas.getInstance().alquiler.ventanaLeer(mapaArticulos, jTextFieldID);
}//GEN-LAST:event_jButtonAlquilerLeerActionPerformed
private void jButtonAlquilerEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAlquilerEliminarActionPerformed
// TODO add your handling code here:
Vistas.getInstance().alquiler.ventanaEliminar(mapaArticulos, jTextFieldID);
}//GEN-LAST:event_jButtonAlquilerEliminarActionPerformed
private void jButtonAlquilerModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAlquilerModificarActionPerformed
// TODO add your handling code here:
Vistas.getInstance().alquiler.ventanaModificar(mapaUsuarios, mapaArticulos, jTextFieldID);
}//GEN-LAST:event_jButtonAlquilerModificarActionPerformed
private void jMenuItemCrearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCrearActionPerformed
// TODO add your handling code here:
Vistas.getInstance().alquiler.ventanaCrear(mapaArticulos, mapaUsuarios,jTextFieldID);
}//GEN-LAST:event_jMenuItemCrearActionPerformed
private void jMenuItemModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemModificarActionPerformed
// TODO add your handling code here:
Vistas.getInstance().alquiler.ventanaModificar(mapaUsuarios, mapaArticulos, jTextFieldID);
}//GEN-LAST:event_jMenuItemModificarActionPerformed
private void jMenuItemLeerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemLeerActionPerformed
// TODO add your handling code here:
Vistas.getInstance().alquiler.ventanaLeer(mapaArticulos, jTextFieldID);
}//GEN-LAST:event_jMenuItemLeerActionPerformed
private void jMenuItemEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemEliminarActionPerformed
// TODO add your handling code here:
Vistas.getInstance().alquiler.ventanaEliminar(mapaArticulos, jTextFieldID);
}//GEN-LAST:event_jMenuItemEliminarActionPerformed
private void jMenuItemBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemBuscarActionPerformed
// TODO add your handling code here:
Vistas.getInstance().articulo.buscarArticulo(jTextFieldID, jTextAreaArticulo, mapaArticulos);
}//GEN-LAST:event_jMenuItemBuscarActionPerformed
private void jMenuItemArticulosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemArticulosActionPerformed
// TODO add your handling code here:
Vistas.getInstance().articulo.ventanaMain(mapaArticulos);
}//GEN-LAST:event_jMenuItemArticulosActionPerformed
private void jMenuItemUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemUsuariosActionPerformed
// TODO add your handling code here:
Vistas.getInstance().usuario.ventanaMain(mapaUsuarios);
}//GEN-LAST:event_jMenuItemUsuariosActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Main().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonAlquilerAgregar;
private javax.swing.JButton jButtonAlquilerEliminar;
private javax.swing.JButton jButtonAlquilerLeer;
private javax.swing.JButton jButtonAlquilerModificar;
private javax.swing.JButton jButtonArticuloBuscar;
private javax.swing.JLabel jLabelAlquiler;
private javax.swing.JLabel jLabelArticulos;
private javax.swing.JLabel jLabelBuscarArticulo;
private javax.swing.JLabel jLabelBuscarID;
private javax.swing.JMenu jMenuAdministracionInterna;
private javax.swing.JMenu jMenuAlquiler;
private javax.swing.JMenu jMenuArticulo;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItemArticulos;
private javax.swing.JMenuItem jMenuItemBuscar;
private javax.swing.JMenuItem jMenuItemCrear;
private javax.swing.JMenuItem jMenuItemEliminar;
private javax.swing.JMenuItem jMenuItemLeer;
private javax.swing.JMenuItem jMenuItemModificar;
private javax.swing.JMenuItem jMenuItemUsuarios;
private javax.swing.JMenu jMenuSalir;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextArea jTextAreaArticulo;
private javax.swing.JTextField jTextFieldID;
// End of variables declaration//GEN-END:variables
}