Agregada forma de crear ejemplares para un libro

Ademas movi los validator a su propio package
This commit is contained in:
Daniel Cortés
2019-05-13 21:06:25 -04:00
parent 0187e71187
commit 9fb94625e1
28 changed files with 430 additions and 77 deletions

View File

@@ -4,6 +4,7 @@ import xyz.danielcortes.controllers.BaseController;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.models.Autor;
import xyz.danielcortes.repository.AutorRepository;
import xyz.danielcortes.validator.AutorValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.autor.AutorCreatePanel;

View File

@@ -8,6 +8,7 @@ import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Autor;
import xyz.danielcortes.repository.AutorRepository;
import xyz.danielcortes.validator.AutorValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.autor.AutorSearchPanel;

View File

@@ -5,6 +5,7 @@ import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Autor;
import xyz.danielcortes.repository.AutorRepository;
import xyz.danielcortes.validator.AutorValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.autor.AutorUpdatePanel;

View File

@@ -4,6 +4,7 @@ import xyz.danielcortes.controllers.BaseController;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.models.Categoria;
import xyz.danielcortes.repository.CategoriaRepository;
import xyz.danielcortes.validator.CategoriaValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.categoria.CategoriaCreatePanel;

View File

@@ -8,6 +8,7 @@ import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Categoria;
import xyz.danielcortes.repository.CategoriaRepository;
import xyz.danielcortes.validator.CategoriaValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.categoria.CategoriaSearchPanel;

View File

@@ -4,6 +4,7 @@ import xyz.danielcortes.controllers.BaseController;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.models.Editorial;
import xyz.danielcortes.repository.EditorialRepository;
import xyz.danielcortes.validator.EditorialValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.editorial.EditorialCreatePanel;

View File

@@ -8,6 +8,7 @@ import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Editorial;
import xyz.danielcortes.repository.EditorialRepository;
import xyz.danielcortes.validator.EditorialValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.editorial.EditorialSearchPanel;

View File

@@ -5,6 +5,7 @@ import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Editorial;
import xyz.danielcortes.repository.EditorialRepository;
import xyz.danielcortes.validator.EditorialValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.editorial.EditorialUpdatePanel;

View File

@@ -4,6 +4,7 @@ import xyz.danielcortes.controllers.BaseController;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.models.Idioma;
import xyz.danielcortes.repository.IdiomaRepository;
import xyz.danielcortes.validator.IdiomaValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.idioma.IdiomaCreatePanel;

View File

@@ -8,6 +8,7 @@ import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Idioma;
import xyz.danielcortes.repository.IdiomaRepository;
import xyz.danielcortes.validator.IdiomaValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.idioma.IdiomaSearchPanel;

View File

@@ -5,6 +5,7 @@ import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Idioma;
import xyz.danielcortes.repository.IdiomaRepository;
import xyz.danielcortes.validator.IdiomaValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.idioma.IdiomaUpdatePanel;

View File

@@ -18,6 +18,7 @@ import xyz.danielcortes.repository.CategoriaRepository;
import xyz.danielcortes.repository.EditorialRepository;
import xyz.danielcortes.repository.IdiomaRepository;
import xyz.danielcortes.repository.LibroRepository;
import xyz.danielcortes.validator.LibroValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.libro.LibroCreatePanel;

View File

@@ -6,22 +6,31 @@ import xyz.danielcortes.controllers.BaseController;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Ejemplar;
import xyz.danielcortes.models.Libro;
import xyz.danielcortes.repository.EjemplarRepository;
import xyz.danielcortes.repository.LibroRepository;
import xyz.danielcortes.validator.EjemplarValidator;
import xyz.danielcortes.validator.LibroValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.libro.LibroAgregarStockDialog;
import xyz.danielcortes.views.libro.LibroSearchPanel;
public class LibroSearchController extends BaseController {
private LibroSearchPanel view;
private LibroRepository libroRepository;
private LibroValidator validator;
private EjemplarRepository ejemplarRepository;
private LibroValidator libroValidator;
private EjemplarValidator ejemplarValidator;
public LibroSearchController(LibroSearchPanel view, LaunchController parent) {
super(parent);
this.view = view;
this.libroRepository = new LibroRepository();
this.validator = new LibroValidator(this.libroRepository);
this.libroValidator = new LibroValidator(this.libroRepository);
this.ejemplarRepository = new EjemplarRepository();
this.ejemplarValidator = new EjemplarValidator(this.ejemplarRepository);
this.loadLibroTable();
this.setupListeners();
}
@@ -41,6 +50,7 @@ public class LibroSearchController extends BaseController {
this.view.getEliminarButton().addActionListener(e -> delete());
this.view.getEditarButton().addActionListener(e -> edit());
this.view.getVerButton().addActionListener(e -> view());
this.view.getAgregarStockButton().addActionListener(e -> addStock());
}
private void view() {
@@ -86,6 +96,34 @@ public class LibroSearchController extends BaseController {
this.loadLibroTable(libros);
}
private void addStock() {
Libro libro = getSelectedLibro();
if (libro == null)
return;
LibroAgregarStockDialog dialog = new LibroAgregarStockDialog();
dialog.pack();
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
String serie = dialog.getSerie();
if (serie == null)
return;
if (!this.ejemplarValidator.validateSerie(serie))
return;
Ejemplar ejemplar = new Ejemplar();
ejemplar.setLibro(libro);
ejemplar.setSerie(serie);
libro.getEjemplares().add(ejemplar);
this.ejemplarRepository.save(ejemplar);
this.libroRepository.update(libro);
this.reload();
}
private void loadLibroTable(List<Libro> libros) {
BaseTableModel<Libro> model = this.view.getLibrosModel();
model.setRows(libros);

View File

@@ -19,6 +19,7 @@ import xyz.danielcortes.repository.CategoriaRepository;
import xyz.danielcortes.repository.EditorialRepository;
import xyz.danielcortes.repository.IdiomaRepository;
import xyz.danielcortes.repository.LibroRepository;
import xyz.danielcortes.validator.LibroValidator;
import xyz.danielcortes.views.BasePanel;
import xyz.danielcortes.views.libro.LibroUpdatePanel;

View File

@@ -2,6 +2,7 @@ package xyz.danielcortes.models;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@@ -25,7 +26,7 @@ public class Ejemplar {
@JoinColumn(name = "libro_id")
private Libro libro;
@ManyToOne
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "estado_id")
private Estado estado;

View File

@@ -6,6 +6,7 @@ import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@@ -70,7 +71,7 @@ public class Libro {
@JoinColumn(name = "editorial_id")
private Editorial editorial;
@OneToMany(mappedBy = "libro")
@OneToMany(mappedBy = "libro", fetch = FetchType.EAGER, orphanRemoval = true )
private Set<Ejemplar> ejemplares;
public Integer getId() {

View File

@@ -0,0 +1,76 @@
package xyz.danielcortes.repository;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceException;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import xyz.danielcortes.framework.PersistenceManager;
import xyz.danielcortes.models.Ejemplar;
public class EjemplarRepository {
private EntityManager em;
public EjemplarRepository() {
this.em = PersistenceManager.getEntityManager();
}
public List<Ejemplar> getAll() {
TypedQuery<Ejemplar> query = em.createQuery("SELECT e FROM Ejemplar e", Ejemplar.class);
return query.getResultList();
}
public List<Ejemplar> search(String term) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Ejemplar> query = cb.createQuery(Ejemplar.class);
Root<Ejemplar> r = query.from(Ejemplar.class);
query.where(
cb.or(
cb.like(cb.lower(r.get("serie")), "%" + term.toLowerCase() + "%")
)
);
return em.createQuery(query).getResultList();
}
public void save(Ejemplar ejemplar) {
em.getTransaction().begin();
try {
em.persist(ejemplar);
} catch (PersistenceException e) {
e.printStackTrace();
}
em.getTransaction().commit();
}
public void update(Ejemplar ejemplar) {
em.getTransaction().begin();
try {
em.merge(ejemplar);
} catch (PersistenceException e) {
e.printStackTrace();
}
em.getTransaction().commit();
}
public void delete(Ejemplar ejemplar) {
em.getTransaction().begin();
try {
em.remove(ejemplar);
} catch (PersistenceException e) {
e.printStackTrace();
}
em.getTransaction().commit();
}
public boolean exists(String serie, Integer id) {
Query query = em.createQuery("SELECT count(e) FROM Ejemplar e WHERE serie = :serie and id != :id");
query.setParameter("serie", serie);
query.setParameter("id", id);
return (Long) query.getResultList().get(0) == 1;
}
}

View File

@@ -3,7 +3,6 @@ package xyz.danielcortes.repository;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceException;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
@@ -75,10 +74,4 @@ public class LibroRepository {
em.getTransaction().commit();
}
public boolean exists(String serie, Integer id) {
Query query = em.createQuery("SELECT count(l) FROM Libro l WHERE serie = :serie and id != :id");
query.setParameter("serie", serie);
query.setParameter("id", id);
return (Long) query.getResultList().get(0) == 1;
}
}

View File

@@ -1,4 +1,4 @@
package xyz.danielcortes.controllers.autor;
package xyz.danielcortes.validator;
import javax.swing.JOptionPane;
import xyz.danielcortes.models.Autor;

View File

@@ -1,4 +1,4 @@
package xyz.danielcortes.controllers.categoria;
package xyz.danielcortes.validator;
import javax.swing.JOptionPane;
import xyz.danielcortes.models.Categoria;
@@ -31,7 +31,6 @@ public class CategoriaValidator {
return true;
}
public boolean isDeleteable(Categoria categoria){
if(categoria.getLibros().size() > 0){
JOptionPane.showMessageDialog(

View File

@@ -1,4 +1,4 @@
package xyz.danielcortes.controllers.editorial;
package xyz.danielcortes.validator;
import javax.swing.JOptionPane;
import xyz.danielcortes.models.Editorial;

View File

@@ -0,0 +1,52 @@
package xyz.danielcortes.validator;
import javax.swing.JOptionPane;
import xyz.danielcortes.models.Ejemplar;
import xyz.danielcortes.repository.EjemplarRepository;
public class EjemplarValidator {
private EjemplarRepository ejemplarRepository;
public EjemplarValidator(EjemplarRepository ejemplarRepository) {
this.ejemplarRepository = ejemplarRepository;
}
public boolean validateSerie(String serie) {
if (serie == null) {
JOptionPane.showMessageDialog(
null,
"La serie es nula",
"Error",
JOptionPane.ERROR_MESSAGE);
return false;
}
if (serie.isEmpty()) {
JOptionPane.showMessageDialog(
null,
"La serie esta vacia",
"Error",
JOptionPane.ERROR_MESSAGE);
return false;
}
return true;
}
public boolean validateSerie(String serie, Ejemplar original) {
if (!validateSerie(serie))
return false;
if (!ejemplarRepository.exists(serie, original.getId())) {
JOptionPane.showMessageDialog(
null,
"El numero de serie ya existe",
"Error",
JOptionPane.ERROR_MESSAGE);
return false;
}
return true;
}
}

View File

@@ -1,4 +1,4 @@
package xyz.danielcortes.controllers.idioma;
package xyz.danielcortes.validator;
import javax.swing.JOptionPane;
import xyz.danielcortes.models.Idioma;

View File

@@ -1,4 +1,4 @@
package xyz.danielcortes.controllers.libro;
package xyz.danielcortes.validator;
import java.util.List;
import java.util.Objects;
@@ -15,11 +15,11 @@ public class LibroValidator {
private LibroRepository libroRepository;
LibroValidator(LibroRepository libroRepository) {
public LibroValidator(LibroRepository libroRepository) {
this.libroRepository = libroRepository;
}
boolean validateLibro(Libro libro) {
public boolean validateLibro(Libro libro) {
if (libro == null) {
JOptionPane.showMessageDialog(
null,
@@ -32,52 +32,7 @@ public class LibroValidator {
return true;
}
boolean validateSerie(String serie) {
if (serie == null) {
JOptionPane.showMessageDialog(
null,
"La serie es nula",
"Error",
JOptionPane.ERROR_MESSAGE);
return false;
}
if (serie.isEmpty()) {
JOptionPane.showMessageDialog(
null,
"La serie esta vacia",
"Error",
JOptionPane.ERROR_MESSAGE);
return false;
}
if (!GeneralValidator.isLong(serie)) {
JOptionPane.showMessageDialog(
null,
"La serie no es numero valido",
"Error",
JOptionPane.ERROR_MESSAGE);
return false;
}
return true;
}
boolean validateSerie(String serie, Libro original) {
if (!validateSerie(serie))
return false;
if (libroRepository.exists(serie, original.getId())) {
JOptionPane.showMessageDialog(
null,
"El numero de serie ya existe",
"Error",
JOptionPane.ERROR_MESSAGE);
return false;
}
return true;
}
boolean validateISBN(String isbn) {
public boolean validateISBN(String isbn) {
if (isbn == null) {
JOptionPane.showMessageDialog(
null,
@@ -109,7 +64,7 @@ public class LibroValidator {
return true;
}
boolean validateTitulo(String titulo) {
public boolean validateTitulo(String titulo) {
if (titulo == null) {
JOptionPane.showMessageDialog(
null,
@@ -129,7 +84,7 @@ public class LibroValidator {
return true;
}
boolean validateNumeroPaginas(String numeroPaginas) {
public boolean validateNumeroPaginas(String numeroPaginas) {
if (numeroPaginas == null) {
JOptionPane.showMessageDialog(
null,
@@ -158,7 +113,7 @@ public class LibroValidator {
return true;
}
boolean validatePrecioReferencia(String precioReferencia) {
public boolean validatePrecioReferencia(String precioReferencia) {
if (precioReferencia == null) {
JOptionPane.showMessageDialog(
null,
@@ -187,7 +142,7 @@ public class LibroValidator {
return true;
}
boolean validateAnoPublicacion(String anoPublicacion) {
public boolean validateAnoPublicacion(String anoPublicacion) {
if (anoPublicacion == null) {
JOptionPane.showMessageDialog(
null,
@@ -223,7 +178,7 @@ public class LibroValidator {
return true;
}
boolean validateIdiomas(List<Idioma> idiomas) {
public boolean validateIdiomas(List<Idioma> idiomas) {
if (idiomas.size() == 0) {
JOptionPane.showMessageDialog(
null,
@@ -244,7 +199,7 @@ public class LibroValidator {
return true;
}
boolean validateAutores(List<Autor> autores) {
public boolean validateAutores(List<Autor> autores) {
if (autores.size() == 0) {
JOptionPane.showMessageDialog(
null,
@@ -265,7 +220,7 @@ public class LibroValidator {
return true;
}
boolean validateCategorias(List<Categoria> categorias) {
public boolean validateCategorias(List<Categoria> categorias) {
if (categorias.size() == 0) {
JOptionPane.showMessageDialog(
null,
@@ -286,7 +241,7 @@ public class LibroValidator {
return true;
}
boolean validateEditorial(Editorial editorial) {
public boolean validateEditorial(Editorial editorial) {
if (editorial == null) {
JOptionPane.showMessageDialog(
null,

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.libro.LibroAgregarStockDialog">
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="48" y="54" width="436" height="297"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="98af6">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="OK"/>
</properties>
</component>
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Cancel"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="acb2b" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Numero de Serie:"/>
</properties>
</component>
<component id="798d0" class="javax.swing.JTextField" binding="serieField">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<vspacer id="8814e">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
</children>
</grid>
</form>

View File

@@ -0,0 +1,120 @@
package xyz.danielcortes.views.libro;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
public class LibroAgregarStockDialog extends JDialog {
private JPanel contentPane;
private JButton buttonOK;
private JButton buttonCancel;
private JTextField serieField;
private String serie;
public LibroAgregarStockDialog() {
setContentPane(contentPane);
setModal(true);
getRootPane().setDefaultButton(buttonOK);
buttonOK.addActionListener(e -> onOK());
buttonCancel.addActionListener(e -> onCancel());
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
onCancel();
}
});
contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
private void onOK() {
this.serie = this.serieField.getText();
dispose();
}
private void onCancel() {
dispose();
}
public String getSerie() {
return this.serie;
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
panel1.add(spacer1,
new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1, true, false));
panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
buttonOK = new JButton();
buttonOK.setText("OK");
panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
buttonCancel = new JButton();
buttonCancel.setText("Cancel");
panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel3 = new JPanel();
panel3.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("Numero de Serie:");
panel3.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
serieField = new JTextField();
panel3.add(serieField,
new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
final Spacer spacer2 = new Spacer();
panel3.add(spacer2,
new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
null, null, 0, false));
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}

View File

@@ -51,7 +51,7 @@
</component>
</children>
</grid>
<grid id="606a7" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="606a7" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -81,7 +81,7 @@
</component>
<component id="bc714" class="javax.swing.JButton" binding="eliminarButton" default-binding="true">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
@@ -89,6 +89,16 @@
<text value="Eliminar"/>
</properties>
</component>
<component id="44c6c" class="javax.swing.JButton" binding="agregarStockButton" default-binding="true">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="Agregar Stock"/>
</properties>
</component>
</children>
</grid>
</children>

View File

@@ -25,6 +25,7 @@ public class LibroSearchPanel extends BasePanel {
private JButton verButton;
private JButton editarButton;
private JButton eliminarButton;
private JButton agregarStockButton;
public JTable getLibrosTable() {
return librosTable;
@@ -58,6 +59,10 @@ public class LibroSearchPanel extends BasePanel {
return eliminarButton;
}
public JButton getAgregarStockButton() {
return agregarStockButton;
}
private void createUIComponents() {
this.createLibrosTable();
}
@@ -117,7 +122,7 @@ public class LibroSearchPanel extends BasePanel {
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
panel2.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
@@ -133,7 +138,12 @@ public class LibroSearchPanel extends BasePanel {
null, 0, false));
eliminarButton = new JButton();
eliminarButton.setText("Eliminar");
panel2.add(eliminarButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
panel2.add(eliminarButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
agregarStockButton = new JButton();
agregarStockButton.setText("Agregar Stock");
panel2.add(agregarStockButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
}