El arrendar esta caaaaasi done <3

This commit is contained in:
Daniel Cortés
2019-07-05 12:46:56 -04:00
parent a65c776372
commit 1fd62570c8
14 changed files with 1357 additions and 7 deletions

View File

@@ -295,7 +295,7 @@ create table arriendo
fecha_arriendo date not null, fecha_arriendo date not null,
fecha_devolucion_estimada date not null, fecha_devolucion_estimada date not null,
fecha_devolucion_real date, fecha_devolucion_real date,
multa int, multa_diaria int,
inserted_at timestamp default CURRENT_TIMESTAMP, inserted_at timestamp default CURRENT_TIMESTAMP,
foreign key (trabajador_id) references trabajador (id) on delete restrict on update cascade, foreign key (trabajador_id) references trabajador (id) on delete restrict on update cascade,
foreign key (cliente_id) references cliente (id) on delete restrict on update cascade foreign key (cliente_id) references cliente (id) on delete restrict on update cascade

View File

@@ -6,6 +6,8 @@ import javax.swing.JMenu;
import javax.swing.JMenuBar; import javax.swing.JMenuBar;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JPanel; import javax.swing.JPanel;
import xyz.danielcortes.controllers.arrendar.ArrendarArrendarController;
import xyz.danielcortes.controllers.arrendar.ArrendarSearchController;
import xyz.danielcortes.controllers.autor.AutorCreateController; import xyz.danielcortes.controllers.autor.AutorCreateController;
import xyz.danielcortes.controllers.autor.AutorSearchController; import xyz.danielcortes.controllers.autor.AutorSearchController;
import xyz.danielcortes.controllers.autor.AutorUpdateController; import xyz.danielcortes.controllers.autor.AutorUpdateController;
@@ -95,6 +97,8 @@ import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Trabajador; import xyz.danielcortes.models.Trabajador;
import xyz.danielcortes.models.Usuario; import xyz.danielcortes.models.Usuario;
import xyz.danielcortes.views.LaunchFrame; import xyz.danielcortes.views.LaunchFrame;
import xyz.danielcortes.views.arrendar.ArrendarArrendarPanel;
import xyz.danielcortes.views.arrendar.ArrendarSearchPanel;
import xyz.danielcortes.views.autor.AutorCreatePanel; import xyz.danielcortes.views.autor.AutorCreatePanel;
import xyz.danielcortes.views.autor.AutorSearchPanel; import xyz.danielcortes.views.autor.AutorSearchPanel;
import xyz.danielcortes.views.autor.AutorUpdatePanel; import xyz.danielcortes.views.autor.AutorUpdatePanel;
@@ -316,6 +320,9 @@ public class LaunchController {
this.controllers.put(PanelName.VENDER_VENDER, new VenderVenderController(new VenderVenderPanel(), this)); this.controllers.put(PanelName.VENDER_VENDER, new VenderVenderController(new VenderVenderPanel(), this));
this.controllers.put(PanelName.VENDER_VER, new VenderVerController(new VenderVerPanel(), this)); this.controllers.put(PanelName.VENDER_VER, new VenderVerController(new VenderVerPanel(), this));
this.controllers.put(PanelName.ARRENDAR_SEARCH, new ArrendarSearchController(new ArrendarSearchPanel(), this));
this.controllers.put(PanelName.ARRENDAR_ARRENDAR, new ArrendarArrendarController(new ArrendarArrendarPanel(), this));
for (Entry<PanelName, BaseController> entry : this.controllers.entrySet()) { for (Entry<PanelName, BaseController> entry : this.controllers.entrySet()) {
this.frame.addCard(entry.getValue().getView().getContentPane(), entry.getKey()); this.frame.addCard(entry.getValue().getView().getContentPane(), entry.getKey());
} }

View File

@@ -0,0 +1,201 @@
package xyz.danielcortes.controllers.arrendar;
import java.time.LocalDate;
import java.util.List;
import javax.swing.JOptionPane;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.framework.ValidationResult;
import xyz.danielcortes.models.Arriendo;
import xyz.danielcortes.models.Cliente;
import xyz.danielcortes.models.Ejemplar;
import xyz.danielcortes.models.Estado;
import xyz.danielcortes.models.Trabajador;
import xyz.danielcortes.repository.ArrendarRepository;
import xyz.danielcortes.repository.ClienteRespository;
import xyz.danielcortes.repository.EjemplarRepository;
import xyz.danielcortes.repository.EstadoRepository;
import xyz.danielcortes.validator.ArriendoValidator;
import xyz.danielcortes.views.arrendar.ArrendarArrendarPanel;
public class ArrendarArrendarController extends BaseController {
private ArrendarArrendarPanel view;
private EjemplarRepository ejemplarRepository;
private EstadoRepository estadoRepository;
private ArrendarRepository arrendarRepository;
private ClienteRespository clienteRespository;
private ArriendoValidator validator;
public ArrendarArrendarController(ArrendarArrendarPanel view, LaunchController parentController) {
super(parentController);
this.view = view;
this.ejemplarRepository = new EjemplarRepository();
this.estadoRepository = new EstadoRepository();
this.arrendarRepository = new ArrendarRepository();
this.clienteRespository = new ClienteRespository();
this.validator = new ArriendoValidator();
this.setupListeners();
}
private void setupListeners() {
this.view.getAgregarButton().addActionListener(e -> this.agregar());
this.view.getRemoverButton().addActionListener(e -> this.remover());
this.view.getArrendarButton().addActionListener(e -> this.arrendar());
this.view.getCancelarButton().addActionListener(e -> this.cancelar());
}
private void agregar() {
if (this.view.getEjemplarComboModel().getSize() == 0) {
JOptionPane.showMessageDialog(
null,
"No hay ningun ejemplar que agregar",
"Error",
JOptionPane.ERROR_MESSAGE
);
return;
}
Ejemplar ejemplar = (Ejemplar) this.view.getEjemplarComboModel().getSelectedItem();
if (ejemplar == null) {
JOptionPane.showMessageDialog(
null,
"El ejemplar seleccionado es nulo, NO DEBERIA PASAR!!",
"ERROR AHHHHHHHHHHHHHHHHHH",
JOptionPane.ERROR_MESSAGE
);
return;
}
this.view.getEjemplaresCombo().removeItem(ejemplar);
this.view.getEjemplarTableModel().addRow(ejemplar);
}
private void remover() {
if (this.view.getEjemplarTableModel().getRowCount() == 0) {
JOptionPane.showMessageDialog(
null,
"No hay ningun ejemplar que remover",
"Error",
JOptionPane.ERROR_MESSAGE
);
return;
}
Ejemplar ejemplar = this.getSelectedEjemplar();
if (ejemplar == null)
return;
this.view.getEjemplaresCombo().addItem(ejemplar);
this.view.getEjemplarTableModel().removeRow(ejemplar);
}
private void arrendar() {
Cliente cliente = (Cliente) this.view.getClienteCombo().getSelectedItem();
ValidationResult clienteValidation = this.validator.validateCliente(cliente);
if (clienteValidation.hasError()) {
clienteValidation.showErrorDialog();
return;
}
Trabajador trabajador = this.parentController.getTrabajador();
ValidationResult trabajadorValidation = this.validator.validateTrabajador(trabajador);
if (trabajadorValidation.hasError()) {
trabajadorValidation.showErrorDialog();
return;
}
List<Ejemplar> ejemplares = this.view.getEjemplarTableModel().getRows();
ValidationResult ejemplaresValidation = this.validator.validateEjemplares(ejemplares);
if (ejemplaresValidation.hasError()) {
ejemplaresValidation.showErrorDialog();
return;
}
LocalDate fechaDevolucion = this.view.getDevolucionPicker().getDate();
ValidationResult fechaDevolucionValidation = this.validator.validateFechaDevolucion(fechaDevolucion);
if (fechaDevolucionValidation.hasError()) {
fechaDevolucionValidation.showErrorDialog();
return;
}
String costo = this.view.getCostoField().getText();
ValidationResult costoValidation = this.validator.validateCosto(costo);
if (costoValidation.hasError()) {
costoValidation.showErrorDialog();
return;
}
String multa = this.view.getMultaDiariaField().getText();
ValidationResult multaValidation = this.validator.validateMulta(multa);
if (multaValidation.hasError()) {
multaValidation.showErrorDialog();
return;
}
Estado estado = this.estadoRepository.getByNombre("Arrendado");
ejemplares.forEach(ejemplar -> ejemplar.setEstado(estado));
this.ejemplarRepository.save(ejemplares);
Arriendo arriendo = new Arriendo();
arriendo.setTrabajador(trabajador);
arriendo.setCliente(cliente);
arriendo.setCostoArriendo(Integer.parseInt(costo));
arriendo.setFechaArriendo(LocalDate.now());
arriendo.setFechaDevolucionEstimada(fechaDevolucion);
arriendo.setMultaDiaria(Integer.parseInt(multa));
arriendo.setEjemplares(ejemplares);
this.arrendarRepository.save(arriendo);
this.parentController.showCard(PanelName.ARRENDAR_SEARCH);
}
private void cancelar() {
this.parentController.showCard(PanelName.ARRENDAR_SEARCH);
}
private Ejemplar getSelectedEjemplar() {
int selectedRow = this.view.getEjemplaresTable().getSelectedRow();
if (selectedRow == -1) {
JOptionPane.showMessageDialog(
null,
"No hay ningun ejemplar seleccionado",
"Error",
JOptionPane.ERROR_MESSAGE
);
return null;
}
return this.view.getEjemplarTableModel().getRow(selectedRow);
}
@Override
public void show() {
Estado disponible = this.estadoRepository.getByNombre("Disponible");
List<Ejemplar> ejemplares = this.ejemplarRepository.getByEstado(disponible);
this.view.getEjemplarComboModel().removeAllElements();
this.view.getEjemplarComboModel().addAll(ejemplares);
List<Cliente> clientes = this.clienteRespository.getAll();
this.view.getClienteComboModel().removeAllElements();
this.view.getClienteComboModel().addAll(clientes);
this.view.getEjemplarTableModel().removeRows();
this.view.getClienteCombo().requestFocus();
this.view.getClienteCombo().setSelectedIndex(0);
this.view.getEjemplaresCombo().setSelectedIndex(0);
this.view.getDevolucionPicker().setDate(LocalDate.now());
this.view.getCostoField().setText("0");
this.view.getMultaDiariaField().setText("0");
}
@Override
public BasePanel getView() {
return this.view;
}
}

View File

@@ -0,0 +1,105 @@
package xyz.danielcortes.controllers.arrendar;
import java.time.LocalDate;
import java.time.Period;
import java.util.List;
import javax.swing.JOptionPane;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Arriendo;
import xyz.danielcortes.repository.ArrendarRepository;
import xyz.danielcortes.views.arrendar.ArrendarSearchPanel;
import xyz.danielcortes.views.arrendar.ArriendoRecibidoDialog;
public class ArrendarSearchController extends BaseController {
private ArrendarSearchPanel view;
private ArrendarRepository arrendarRepository;
public ArrendarSearchController(ArrendarSearchPanel view, LaunchController parent) {
super(parent);
this.view = view;
this.arrendarRepository = new ArrendarRepository();
this.setupListeners();
}
private void setupListeners() {
this.view.getArrendarButton().addActionListener(e -> this.getParentController().showCard(PanelName.ARRENDAR_ARRENDAR));
this.view.getBuscarField().addActionListener(e -> this.search());
this.view.getBuscarButton().addActionListener(e -> this.search());
this.view.getVerButton().addActionListener(e -> this.view());
this.view.getRecibirButton().addActionListener(e -> this.recibir());
}
private void search() {
String term = this.view.getBuscarField().getText();
List<Arriendo> arriendos = this.arrendarRepository.search(term);
this.loadArriendosTable(arriendos);
}
private void view() {
Arriendo arriendo = this.getSelectedArriendo();
if (arriendo == null)
return;
// AutorViewController controller = (AutorViewController) this.getParentController().getCard(PanelName.AUTOR_VIEW);
// controller.setAutor(autor);
// this.getParentController().showCard(PanelName.AUTOR_VIEW);
}
private void recibir() {
Arriendo arriendo = this.getSelectedArriendo();
if (arriendo == null)
return;
int multaDiaria = arriendo.getMultaDiaria();
int diasAtrasado = Period.between(arriendo.getFechaDevolucionEstimada(), LocalDate.now()).getDays();
ArriendoRecibidoDialog dialog = new ArriendoRecibidoDialog(multaDiaria, Math.max(0, diasAtrasado)); //Me vi en la necesidad de usar max, lo siento
dialog.execute();
}
private void loadArriendosTable(List<Arriendo> arriendos) {
BaseTableModel<Arriendo> model = this.view.getArriendosTableModel();
model.setRows(arriendos);
}
private Arriendo getSelectedArriendo() {
int selectedRow = this.view.getArriendosTable().getSelectedRow();
if (selectedRow == -1) {
JOptionPane.showMessageDialog(
null,
"No hay arriendo seleccionado",
"Error",
JOptionPane.ERROR_MESSAGE
);
return null;
}
return this.view.getArriendosTableModel().getRow(selectedRow);
}
@Override
public void show() {
this.reload();
}
public void reload() {
this.loadArriendosTable();
this.view.getBuscarButton().requestFocus();
this.view.getBuscarField().setText("");
this.view.getArriendosTable().clearSelection();
}
private void loadArriendosTable() {
List<Arriendo> arriendos = this.arrendarRepository.getAll();
this.loadArriendosTable(arriendos);
}
@Override
public BasePanel getView() {
return this.view;
}
}

View File

@@ -35,8 +35,8 @@ public class Arriendo {
@Column(name = "fecha_devolucion_real") @Column(name = "fecha_devolucion_real")
private LocalDate fechaDevolucionReal; private LocalDate fechaDevolucionReal;
@Column(name = "multa") @Column(name = "multa_diaria")
private Integer multa; private Integer multaDiaria;
@ManyToOne @ManyToOne
@JoinColumn(name = "trabajador_id", nullable = false) @JoinColumn(name = "trabajador_id", nullable = false)
@@ -93,12 +93,12 @@ public class Arriendo {
this.fechaDevolucionReal = fechaDevolucionReal; this.fechaDevolucionReal = fechaDevolucionReal;
} }
public Integer getMulta() { public Integer getMultaDiaria() {
return this.multa; return this.multaDiaria;
} }
public void setMulta(Integer multa) { public void setMultaDiaria(Integer multaDiaria) {
this.multa = multa; this.multaDiaria = multaDiaria;
} }
public Trabajador getTrabajador() { public Trabajador getTrabajador() {

View File

@@ -0,0 +1,26 @@
package xyz.danielcortes.repository;
import java.util.List;
import javax.persistence.TypedQuery;
import xyz.danielcortes.framework.BaseRepository;
import xyz.danielcortes.models.Arriendo;
public class ArrendarRepository extends BaseRepository<Arriendo> {
public ArrendarRepository() {
super(Arriendo.class);
}
public List<Arriendo> search(String term) {
TypedQuery<Arriendo> query = this.em.createQuery("SELECT o FROM Arriendo o WHERE "
+ " CONCAT(o.fechaArriendo, '') LIKE :term OR "
+ " CONCAT(o.fechaDevolucionEstimada, '') LIKE :term OR "
+ " CONCAT(o.fechaDevolucionReal, '') LIKE :term OR "
+ " CONCAT(o.ejemplares.size, '') LIKE :term OR "
+ " LOWER(o.cliente.rut) LIKE :term OR "
+ " LOWER(o.trabajador.rut) LIKE :term", Arriendo.class);
query.setParameter("term", "%" + term.toLowerCase() + "%");
return query.getResultList();
}
}

View File

@@ -0,0 +1,80 @@
package xyz.danielcortes.validator;
import java.time.LocalDate;
import java.util.List;
import xyz.danielcortes.framework.ValidationResult;
import xyz.danielcortes.models.Cliente;
import xyz.danielcortes.models.Ejemplar;
import xyz.danielcortes.models.Trabajador;
public class ArriendoValidator {
public ValidationResult validateCliente(Cliente cliente) {
if (cliente == null) {
return new ValidationResult("No hay cliente");
}
return ValidationResult.NON_ERROR;
}
public ValidationResult validateTrabajador(Trabajador trabajador) {
if (trabajador == null) {
return new ValidationResult("No hay trabajador, no deberia pasar!!!");
}
return ValidationResult.NON_ERROR;
}
public ValidationResult validateEjemplares(List<Ejemplar> ejemplares) {
if (ejemplares == null) {
return new ValidationResult("No hay ejemplares, no deberia pasar!!!");
}
if (ejemplares.size() == 0) {
return new ValidationResult("No hay ejemplares");
}
if (ejemplares.stream().anyMatch(ejemplar -> !ejemplar.getEstado().getNombre().equals("Disponible"))) {
return new ValidationResult("Por alguna razon hay un ejemplar no disponible, NO DEBERIA PASAR TAMPOCO!");
}
return ValidationResult.NON_ERROR;
}
public ValidationResult validateFechaDevolucion(LocalDate date) {
if (date.isBefore(LocalDate.now().plusDays(1)) || date.isEqual(LocalDate.now().plusDays(1))) {
return new ValidationResult("La fecha de devolucion debe ser al menos 1 dias despues de hoy");
}
return ValidationResult.NON_ERROR;
}
public ValidationResult validateCosto(String costo) {
if (costo == null) {
return new ValidationResult("El costo es null");
}
if (costo.isBlank()) {
return new ValidationResult("El costo esta vacio");
}
try {
int i = Integer.parseInt(costo);
return ValidationResult.NON_ERROR;
} catch (NumberFormatException e) {
return new ValidationResult("El costo no es un numero");
}
}
public ValidationResult validateMulta(String multa) {
if (multa == null) {
return new ValidationResult("La multa es null");
}
if (multa.isBlank()) {
return new ValidationResult("La multa esta vacia");
}
try {
int i = Integer.parseInt(multa);
return ValidationResult.NON_ERROR;
} catch (NumberFormatException e) {
return new ValidationResult("El multa no es un numero");
}
}
}

View File

@@ -0,0 +1,175 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.arrendar.ArrendarArrendarPanel">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="12" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="20" left="20" bottom="20" right="20"/>
<constraints>
<xy x="20" y="20" width="474" height="451"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="fdc1e" 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="10" 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="2ae64" class="javax.swing.JButton" binding="arrendarButton" default-binding="true">
<constraints>
<grid row="0" column="0" 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="Arrendar"/>
</properties>
</component>
<component id="e3831" class="javax.swing.JButton" binding="cancelarButton" default-binding="true">
<constraints>
<grid row="0" column="1" 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="Cancelar"/>
</properties>
</component>
</children>
</grid>
<vspacer id="1fdc5">
<constraints>
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<hspacer id="caa33">
<constraints>
<grid row="11" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="dd151">
<constraints>
<grid row="11" 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>
<component id="fe969" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="1" 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="Cliente:"/>
</properties>
</component>
<component id="494fa" class="javax.swing.JComboBox" binding="clienteCombo" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<grid id="3c925" layout-manager="GridLayoutManager" row-count="2" column-count="3" 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="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="bb56d" 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="Ejemplares:"/>
</properties>
</component>
<component id="a0b49" class="javax.swing.JComboBox" binding="ejemplaresCombo" custom-create="true">
<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"/>
</constraints>
<properties/>
</component>
<component id="bf57a" class="javax.swing.JButton" binding="agregarButton">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="50" height="-1"/>
</grid>
</constraints>
<properties>
<text value="+"/>
</properties>
</component>
<component id="aaeaa" class="javax.swing.JButton" binding="removerButton">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="50" height="-1"/>
</grid>
</constraints>
<properties>
<text value="-"/>
</properties>
</component>
</children>
</grid>
<scrollpane id="1efc7">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="4d6b9" class="javax.swing.JTable" binding="ejemplaresTable" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<component id="6e603" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="1" 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="Costo Base:"/>
</properties>
</component>
<component id="40d31" class="javax.swing.JTextField" binding="costoField">
<constraints>
<grid row="5" column="1" 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>
<component id="870f9" class="com.github.lgooddatepicker.components.DatePicker" binding="devolucionPicker">
<constraints>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="83713" class="javax.swing.JLabel">
<constraints>
<grid row="8" column="1" 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="Fecha devolucion:"/>
</properties>
</component>
<component id="a35d9" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="1" 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="Multa Diaria:"/>
</properties>
</component>
<component id="54a91" class="javax.swing.JTextField" binding="multaDiariaField">
<constraints>
<grid row="7" column="1" 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>
</children>
</grid>
</form>

View File

@@ -0,0 +1,234 @@
package xyz.danielcortes.views.arrendar;
import com.github.lgooddatepicker.components.DatePicker;
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 javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.models.Cliente;
import xyz.danielcortes.models.Ejemplar;
public class ArrendarArrendarPanel extends BasePanel {
private JPanel contentPane;
private JButton arrendarButton;
private JButton cancelarButton;
private JComboBox<Cliente> clienteCombo;
private DefaultComboBoxModel<Cliente> clienteComboModel;
private JTable ejemplaresTable;
private BaseTableModel<Ejemplar> ejemplarTableModel;
private JComboBox<Ejemplar> ejemplaresCombo;
private DefaultComboBoxModel<Ejemplar> ejemplarComboModel;
private JButton agregarButton;
private JButton removerButton;
private JTextField costoField;
private DatePicker devolucionPicker;
private JTextField multaDiariaField;
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
this.$$$setupUI$$$();
}
@Override
public JPanel getContentPane() {
return this.contentPane;
}
public JButton getArrendarButton() {
return this.arrendarButton;
}
public JButton getCancelarButton() {
return this.cancelarButton;
}
public JComboBox<Cliente> getClienteCombo() {
return this.clienteCombo;
}
public DefaultComboBoxModel<Cliente> getClienteComboModel() {
return this.clienteComboModel;
}
public JTable getEjemplaresTable() {
return this.ejemplaresTable;
}
public BaseTableModel<Ejemplar> getEjemplarTableModel() {
return this.ejemplarTableModel;
}
public JComboBox<Ejemplar> getEjemplaresCombo() {
return this.ejemplaresCombo;
}
public DefaultComboBoxModel<Ejemplar> getEjemplarComboModel() {
return this.ejemplarComboModel;
}
public JButton getAgregarButton() {
return this.agregarButton;
}
public JButton getRemoverButton() {
return this.removerButton;
}
public JTextField getCostoField() {
return this.costoField;
}
public DatePicker getDevolucionPicker() {
return this.devolucionPicker;
}
public JTextField getMultaDiariaField() {
return this.multaDiariaField;
}
/**
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
createUIComponents();
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(12, 3, new Insets(20, 20, 20, 20), -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(10, 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));
arrendarButton = new JButton();
arrendarButton.setText("Arrendar");
panel1.add(arrendarButton, new GridConstraints(0, 0, 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));
cancelarButton = new JButton();
cancelarButton.setText("Cancelar");
panel1.add(cancelarButton, new GridConstraints(0, 1, 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));
final Spacer spacer1 = new Spacer();
contentPane.add(spacer1,
new GridConstraints(11, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
null, null, 0, false));
final Spacer spacer2 = new Spacer();
contentPane.add(spacer2,
new GridConstraints(11, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1,
null, null, null, 0, false));
final Spacer spacer3 = new Spacer();
contentPane.add(spacer3,
new GridConstraints(11, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1,
null, null, null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("Cliente:");
contentPane.add(label1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
contentPane.add(clienteCombo,
new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel2, new GridConstraints(2, 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));
final JLabel label2 = new JLabel();
label2.setText("Ejemplares:");
panel2.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
panel2.add(ejemplaresCombo,
new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
agregarButton = new JButton();
agregarButton.setText("+");
panel2.add(agregarButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, -1),
null, 0, false));
removerButton = new JButton();
removerButton.setText("-");
panel2.add(removerButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, -1),
null, 0, false));
final JScrollPane scrollPane1 = new JScrollPane();
contentPane.add(scrollPane1, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
scrollPane1.setViewportView(ejemplaresTable);
final JLabel label3 = new JLabel();
label3.setText("Costo Base:");
contentPane.add(label3, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
costoField = new JTextField();
contentPane.add(costoField,
new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
devolucionPicker = new DatePicker();
contentPane.add(devolucionPicker,
new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label4 = new JLabel();
label4.setText("Fecha devolucion:");
contentPane.add(label4, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label5 = new JLabel();
label5.setText("Multa Diaria:");
contentPane.add(label5, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
multaDiariaField = new JTextField();
contentPane.add(multaDiariaField,
new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
}
private void createUIComponents() {
this.clienteComboModel = new DefaultComboBoxModel<>();
this.clienteCombo = new JComboBox<>(this.clienteComboModel);
this.ejemplarComboModel = new DefaultComboBoxModel<>();
this.ejemplaresCombo = new JComboBox<>(this.ejemplarComboModel);
this.ejemplarTableModel = new BaseTableModel<>(
new String[]{"ISBN", "Serie", "Titulo", "Precio"},
(row, rowIndex, colIndex) -> {
switch (colIndex) {
case 0:
return row.get(rowIndex).getLibro().getIsbn();
case 1:
return row.get(rowIndex).getSerie();
case 2:
return row.get(rowIndex).getLibro().getTitulo();
case 3:
return row.get(rowIndex).getLibro().getPrecioReferencia();
default:
return null;
}
}
);
this.ejemplaresTable = new JTable(this.ejemplarTableModel);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}

View File

@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.arrendar.ArrendarSearchPanel">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="20" left="20" bottom="20" right="20"/>
<constraints>
<xy x="20" y="20" width="430" height="450"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="ac3e2" 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="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="62a1c" class="javax.swing.JTextField" binding="buscarField">
<constraints>
<grid row="0" 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>
<component id="6d62a" class="javax.swing.JButton" binding="buscarButton" default-binding="true">
<constraints>
<grid row="0" column="1" 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="Buscar"/>
</properties>
</component>
</children>
</grid>
<scrollpane id="9f452">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="994e" class="javax.swing.JTable" binding="arriendosTable" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<grid id="ae99a" layout-manager="GridLayoutManager" row-count="1" column-count="3" 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="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="5f9be" class="javax.swing.JButton" binding="arrendarButton" default-binding="true">
<constraints>
<grid row="0" column="0" 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="Arrendar"/>
</properties>
</component>
<component id="20e93" class="javax.swing.JButton" binding="verButton" 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="Ver"/>
</properties>
</component>
<component id="8d5ef" class="javax.swing.JButton" binding="recibirButton" default-binding="true">
<constraints>
<grid row="0" column="1" 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="Recibir "/>
</properties>
</component>
</children>
</grid>
<vspacer id="72e52">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<hspacer id="f48c2">
<constraints>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="3b72d">
<constraints>
<grid row="3" 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>
</children>
</grid>
</form>

View File

@@ -0,0 +1,163 @@
package xyz.danielcortes.views.arrendar;
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 javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.models.Arriendo;
public class ArrendarSearchPanel extends BasePanel {
private JPanel contentPane;
private JTextField buscarField;
private JButton buscarButton;
private JTable arriendosTable;
private BaseTableModel<Arriendo> arriendosTableModel;
private JButton arrendarButton;
private JButton verButton;
private JButton recibirButton;
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
this.$$$setupUI$$$();
}
@Override
public JPanel getContentPane() {
return this.contentPane;
}
public JTextField getBuscarField() {
return this.buscarField;
}
public JButton getBuscarButton() {
return this.buscarButton;
}
public JTable getArriendosTable() {
return this.arriendosTable;
}
public BaseTableModel<Arriendo> getArriendosTableModel() {
return this.arriendosTableModel;
}
public JButton getArrendarButton() {
return this.arrendarButton;
}
public JButton getVerButton() {
return this.verButton;
}
public JButton getRecibirButton() {
return this.recibirButton;
}
/**
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
createUIComponents();
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(4, 3, new Insets(20, 20, 20, 20), -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(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));
buscarField = new JTextField();
panel1.add(buscarField,
new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
buscarButton = new JButton();
buscarButton.setText("Buscar");
panel1.add(buscarButton, new GridConstraints(0, 1, 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));
final JScrollPane scrollPane1 = new JScrollPane();
contentPane.add(scrollPane1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
scrollPane1.setViewportView(arriendosTable);
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel2, new GridConstraints(2, 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));
arrendarButton = new JButton();
arrendarButton.setText("Arrendar");
panel2.add(arrendarButton, new GridConstraints(0, 0, 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));
verButton = new JButton();
verButton.setText("Ver");
panel2.add(verButton, 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));
recibirButton = new JButton();
recibirButton.setText("Recibir ");
panel2.add(recibirButton, new GridConstraints(0, 1, 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));
final Spacer spacer1 = new Spacer();
contentPane.add(spacer1,
new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
null, null, 0, false));
final Spacer spacer2 = new Spacer();
contentPane.add(spacer2,
new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false));
final Spacer spacer3 = new Spacer();
contentPane.add(spacer3,
new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false));
}
private void createUIComponents() {
this.arriendosTableModel = new BaseTableModel<>(
new String[]{"Fecha arrendado", "Fecha estimada", "Fecha recibido", "Nº Ejemplares", "Trabajador", "Cliente"},
(row, rowIndex, colIndex) -> {
switch (colIndex) {
case 0:
return row.get(rowIndex).getFechaArriendo();
case 1:
return row.get(rowIndex).getFechaDevolucionEstimada();
case 2:
return row.get(rowIndex).getFechaDevolucionReal();
case 3:
return row.get(rowIndex).getEjemplares().size();
case 4:
return row.get(rowIndex).getTrabajador().getRut();
case 5:
return row.get(rowIndex).getCliente().getRut();
default:
return null;
}
}
);
this.arriendosTable = new JTable(this.arriendosTableModel);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}

View File

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.arrendar.ArriendoRecibidoDialog">
<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="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="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>
</children>
</grid>
</children>
</grid>
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" 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="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="10948" class="javax.swing.JLabel">
<constraints>
<grid row="2" 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="Multa Total:"/>
</properties>
</component>
<component id="3ffa0" 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="Dias Atrasados:"/>
</properties>
</component>
<component id="72710" class="javax.swing.JTextField" binding="multaTotalField">
<constraints>
<grid row="2" column="1" 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>
<editable value="false"/>
</properties>
</component>
<component id="7ac03" class="javax.swing.JTextField" binding="diasAtrasadosField">
<constraints>
<grid row="0" column="1" 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>
<editable value="false"/>
</properties>
</component>
<component id="3be4" class="javax.swing.JLabel">
<constraints>
<grid row="1" 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="Multa diaria:"/>
</properties>
</component>
<component id="adb47" class="javax.swing.JTextField" binding="multaDiariaField">
<constraints>
<grid row="1" column="1" 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>
<editable value="false"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>

View File

@@ -0,0 +1,138 @@
package xyz.danielcortes.views.arrendar;
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 ArriendoRecibidoDialog extends JDialog {
private JPanel contentPane;
private JButton buttonOK;
private JTextField multaTotalField;
private JTextField diasAtrasadosField;
private JTextField multaDiariaField;
private int multaDiaria;
private int diasAtrasados;
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
this.$$$setupUI$$$();
}
public ArriendoRecibidoDialog(int multaDiaria, int diasAtrasados) {
this.multaDiaria = multaDiaria;
this.diasAtrasados = diasAtrasados;
this.setContentPane(this.contentPane);
this.setModal(true);
this.setLocationRelativeTo(null);
this.getRootPane().setDefaultButton(this.buttonOK);
this.buttonOK.addActionListener(e -> this.dispose());
this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
ArriendoRecibidoDialog.this.dispose();
}
});
this.contentPane.registerKeyboardAction(
e -> this.dispose(),
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
);
this.fill();
}
private void fill() {
this.multaDiariaField.setText(String.valueOf(this.multaDiaria));
this.diasAtrasadosField.setText(String.valueOf(this.diasAtrasados));
this.multaTotalField.setText(String.valueOf(this.multaDiaria * this.diasAtrasados));
}
public void execute() {
this.pack();
this.setVisible(true);
}
/**
* 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, 1, new Insets(0, 0, 0, 0), -1, -1));
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));
final JPanel panel3 = new JPanel();
panel3.setLayout(new GridLayoutManager(3, 2, 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("Multa Total:");
panel3.add(label1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label2 = new JLabel();
label2.setText("Dias Atrasados:");
panel3.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
multaTotalField = new JTextField();
multaTotalField.setEditable(false);
panel3.add(multaTotalField,
new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
diasAtrasadosField = new JTextField();
diasAtrasadosField.setEditable(false);
panel3.add(diasAtrasadosField,
new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
final JLabel label3 = new JLabel();
label3.setText("Multa diaria:");
panel3.add(label3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
multaDiariaField = new JTextField();
multaDiariaField.setEditable(false);
panel3.add(multaDiariaField,
new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}

View File

@@ -159,6 +159,7 @@ public class VenderVerPanel extends BasePanel {
contentPane.add(label6, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, contentPane.add(label6, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
clienteField = new JTextField(); clienteField = new JTextField();
clienteField.setEditable(false);
contentPane.add(clienteField, contentPane.add(clienteField,
new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
@@ -197,4 +198,5 @@ public class VenderVerPanel extends BasePanel {
public JComponent $$$getRootComponent$$$() { public JComponent $$$getRootComponent$$$() {
return contentPane; return contentPane;
} }
} }