Agrege el arrendar <3

This commit is contained in:
Daniel Cortés
2019-07-07 11:24:09 -04:00
parent 1fd62570c8
commit 7d27a8f8c9
8 changed files with 551 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ import javax.swing.JMenuItem;
import javax.swing.JPanel; import javax.swing.JPanel;
import xyz.danielcortes.controllers.arrendar.ArrendarArrendarController; import xyz.danielcortes.controllers.arrendar.ArrendarArrendarController;
import xyz.danielcortes.controllers.arrendar.ArrendarSearchController; import xyz.danielcortes.controllers.arrendar.ArrendarSearchController;
import xyz.danielcortes.controllers.arrendar.ArrendarViewRecibidoController;
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;
@@ -99,6 +100,7 @@ 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.ArrendarArrendarPanel;
import xyz.danielcortes.views.arrendar.ArrendarSearchPanel; import xyz.danielcortes.views.arrendar.ArrendarSearchPanel;
import xyz.danielcortes.views.arrendar.ArrendarViewPanel;
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;
@@ -322,6 +324,7 @@ public class LaunchController {
this.controllers.put(PanelName.ARRENDAR_SEARCH, new ArrendarSearchController(new ArrendarSearchPanel(), this)); this.controllers.put(PanelName.ARRENDAR_SEARCH, new ArrendarSearchController(new ArrendarSearchPanel(), this));
this.controllers.put(PanelName.ARRENDAR_ARRENDAR, new ArrendarArrendarController(new ArrendarArrendarPanel(), this)); this.controllers.put(PanelName.ARRENDAR_ARRENDAR, new ArrendarArrendarController(new ArrendarArrendarPanel(), this));
this.controllers.put(PanelName.ARRENDAR_VIEW, new ArrendarViewRecibidoController(new ArrendarViewPanel(), 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

@@ -44,9 +44,10 @@ public class ArrendarSearchController extends BaseController {
Arriendo arriendo = this.getSelectedArriendo(); Arriendo arriendo = this.getSelectedArriendo();
if (arriendo == null) if (arriendo == null)
return; return;
// AutorViewController controller = (AutorViewController) this.getParentController().getCard(PanelName.AUTOR_VIEW);
// controller.setAutor(autor); ArrendarViewRecibidoController controller = (ArrendarViewRecibidoController) this.getParentController().getCard(PanelName.ARRENDAR_VIEW);
// this.getParentController().showCard(PanelName.AUTOR_VIEW); controller.setArriendo(arriendo);
this.getParentController().showCard(PanelName.ARRENDAR_VIEW);
} }
private void recibir() { private void recibir() {
@@ -59,6 +60,12 @@ public class ArrendarSearchController extends BaseController {
ArriendoRecibidoDialog dialog = new ArriendoRecibidoDialog(multaDiaria, Math.max(0, diasAtrasado)); //Me vi en la necesidad de usar max, lo siento ArriendoRecibidoDialog dialog = new ArriendoRecibidoDialog(multaDiaria, Math.max(0, diasAtrasado)); //Me vi en la necesidad de usar max, lo siento
dialog.execute(); dialog.execute();
if (dialog.isAcepted()) {
arriendo.setFechaDevolucionReal(LocalDate.now());
this.arrendarRepository.update(arriendo);
this.view.getArriendosTableModel().fireTableDataChanged();
}
} }
private void loadArriendosTable(List<Arriendo> arriendos) { private void loadArriendosTable(List<Arriendo> arriendos) {

View File

@@ -0,0 +1,56 @@
package xyz.danielcortes.controllers.arrendar;
import java.time.Period;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Arriendo;
import xyz.danielcortes.views.arrendar.ArrendarViewPanel;
public class ArrendarViewRecibidoController extends BaseController {
public ArrendarViewPanel view;
public Arriendo arriendo;
public ArrendarViewRecibidoController(ArrendarViewPanel view, LaunchController parentController) {
super(parentController);
this.view = view;
this.setupListeners();
}
private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> this.parentController.showCard(PanelName.ARRENDAR_VIEW));
}
public void setArriendo(Arriendo arriendo) {
this.arriendo = arriendo;
}
@Override
public void show() {
if (this.arriendo != null && this.arriendo.getFechaDevolucionReal() != null) {
int costoBase = this.arriendo.getCostoArriendo();
int diasAtrasado = Math.max(0, Period.between(this.arriendo.getFechaDevolucionEstimada(), this.arriendo.getFechaDevolucionReal()).getDays());
int multaDiaria = this.arriendo.getMultaDiaria();
int costoTotal = costoBase + multaDiaria * diasAtrasado;
this.view.getClientesField().setText(this.arriendo.getCliente().getRut());
this.view.getVendedorField().setText(this.arriendo.getTrabajador().getRut());
this.view.getEjemplaresTableModel().setRows(this.arriendo.getEjemplares());
this.view.getFechaEntregaEstipuladaField().setText(this.arriendo.getFechaDevolucionEstimada().toString());
this.view.getFechaEntregaRealField().setText(this.arriendo.getFechaDevolucionReal().toString());
this.view.getCostoBaseField().setText(String.valueOf(costoBase));
this.view.getMultaDiariaField().setText(String.valueOf(multaDiaria));
this.view.getDiasAtrasadosField().setText(String.valueOf(diasAtrasado));
this.view.getCostoTotalField().setText(String.valueOf(costoTotal));
}
}
@Override
public BasePanel getView() {
return this.view;
}
}

View File

@@ -110,5 +110,5 @@ public enum PanelName {
ARRENDAR_SEARCH, ARRENDAR_SEARCH,
ARRENDAR_ARRENDAR, ARRENDAR_ARRENDAR,
ARRENDAR_RECIBIR, ARRENDAR_VIEW
} }

View File

@@ -0,0 +1,215 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.arrendar.ArrendarViewPanel">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="20" 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="484" height="557"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3e5ab" 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="b4507" class="javax.swing.JTextField" binding="clientesField">
<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="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<scrollpane id="82a3f">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="ae9a6" class="javax.swing.JTable" binding="ejemplaresTable" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<component id="a728" 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="Ejemplares:"/>
</properties>
</component>
<component id="59491" class="javax.swing.JTextField" binding="costoBaseField">
<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="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="c10cc" 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="Costo Base:"/>
</properties>
</component>
<component id="fe88c" class="javax.swing.JTextField" binding="multaDiariaField">
<constraints>
<grid row="9" 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="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="6f85c" 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="Multa Diaria"/>
</properties>
</component>
<component id="80326" class="javax.swing.JLabel">
<constraints>
<grid row="10" 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 Entrega Estipulada:"/>
</properties>
</component>
<component id="fbf12" class="javax.swing.JTextField" binding="fechaEntregaEstipuladaField">
<constraints>
<grid row="11" 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="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<grid id="869a8" 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="18" 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="22ec0" class="javax.swing.JButton" binding="volverButton" 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="Volver"/>
</properties>
</component>
</children>
</grid>
<vspacer id="d06b7">
<constraints>
<grid row="19" 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="ec4ca">
<constraints>
<grid row="19" 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="79102">
<constraints>
<grid row="19" 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="c9b67" class="javax.swing.JLabel">
<constraints>
<grid row="12" 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 Entrega Real:"/>
</properties>
</component>
<component id="11579" class="javax.swing.JTextField" binding="fechaEntregaRealField">
<constraints>
<grid row="13" 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="b84f1" class="javax.swing.JLabel">
<constraints>
<grid row="16" 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 Total:"/>
</properties>
</component>
<component id="5920a" class="javax.swing.JTextField" binding="costoTotalField">
<constraints>
<grid row="17" 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="50c2e" class="javax.swing.JLabel">
<constraints>
<grid row="14" 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="Dias Atrasado:"/>
</properties>
</component>
<component id="bd7af" class="javax.swing.JTextField" binding="diasAtrasadosField">
<constraints>
<grid row="15" 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="f5987" class="javax.swing.JLabel">
<constraints>
<grid row="2" 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="Vendedor:"/>
</properties>
</component>
<component id="241c4" class="javax.swing.JTextField" binding="vendedorField">
<constraints>
<grid row="3" 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>
</form>

View File

@@ -0,0 +1,231 @@
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.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.Ejemplar;
public class ArrendarViewPanel extends BasePanel {
private JPanel contentPane;
private JTable ejemplaresTable;
private BaseTableModel<Ejemplar> ejemplaresTableModel;
private JTextField clientesField;
private JTextField costoBaseField;
private JTextField multaDiariaField;
private JTextField fechaEntregaEstipuladaField;
private JTextField fechaEntregaRealField;
private JTextField costoTotalField;
private JTextField diasAtrasadosField;
private JTextField vendedorField;
private JButton volverButton;
{
// 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 JTable getEjemplaresTable() {
return this.ejemplaresTable;
}
public BaseTableModel<Ejemplar> getEjemplaresTableModel() {
return this.ejemplaresTableModel;
}
public JTextField getClientesField() {
return this.clientesField;
}
public JTextField getCostoBaseField() {
return this.costoBaseField;
}
public JTextField getMultaDiariaField() {
return this.multaDiariaField;
}
public JTextField getFechaEntregaEstipuladaField() {
return this.fechaEntregaEstipuladaField;
}
public JTextField getFechaEntregaRealField() {
return this.fechaEntregaRealField;
}
public JTextField getCostoTotalField() {
return this.costoTotalField;
}
public JTextField getDiasAtrasadosField() {
return this.diasAtrasadosField;
}
public JTextField getVendedorField() {
return this.vendedorField;
}
public JButton getVolverButton() {
return this.volverButton;
}
/**
* 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(20, 3, new Insets(20, 20, 20, 20), -1, -1));
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));
clientesField = new JTextField();
clientesField.setEditable(false);
contentPane.add(clientesField,
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));
final JScrollPane scrollPane1 = new JScrollPane();
contentPane.add(scrollPane1, new GridConstraints(5, 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, new Dimension(400, -1), null, 0, false));
scrollPane1.setViewportView(ejemplaresTable);
final JLabel label2 = new JLabel();
label2.setText("Ejemplares:");
contentPane.add(label2, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
costoBaseField = new JTextField();
costoBaseField.setEditable(false);
contentPane.add(costoBaseField,
new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
final JLabel label3 = new JLabel();
label3.setText("Costo Base:");
contentPane.add(label3, 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();
multaDiariaField.setEditable(false);
contentPane.add(multaDiariaField,
new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
final JLabel label4 = new JLabel();
label4.setText("Multa Diaria");
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("Fecha Entrega Estipulada:");
contentPane.add(label5, new GridConstraints(10, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
fechaEntregaEstipuladaField = new JTextField();
fechaEntregaEstipuladaField.setEditable(false);
contentPane.add(fechaEntregaEstipuladaField,
new GridConstraints(11, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel1, new GridConstraints(18, 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));
volverButton = new JButton();
volverButton.setText("Volver");
panel1.add(volverButton, 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));
final Spacer spacer1 = new Spacer();
contentPane.add(spacer1,
new GridConstraints(19, 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(19, 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(19, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1,
null, null, null, 0, false));
final JLabel label6 = new JLabel();
label6.setText("Fecha Entrega Real:");
contentPane.add(label6, new GridConstraints(12, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
fechaEntregaRealField = new JTextField();
fechaEntregaRealField.setEditable(false);
contentPane.add(fechaEntregaRealField,
new GridConstraints(13, 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 label7 = new JLabel();
label7.setText("Costo Total:");
contentPane.add(label7, new GridConstraints(16, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
costoTotalField = new JTextField();
costoTotalField.setEditable(false);
contentPane.add(costoTotalField,
new GridConstraints(17, 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 label8 = new JLabel();
label8.setText("Dias Atrasado:");
contentPane.add(label8, new GridConstraints(14, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
diasAtrasadosField = new JTextField();
diasAtrasadosField.setEditable(false);
contentPane.add(diasAtrasadosField,
new GridConstraints(15, 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 label9 = new JLabel();
label9.setText("Vendedor:");
contentPane.add(label9, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
vendedorField = new JTextField();
vendedorField.setEditable(false);
contentPane.add(vendedorField,
new GridConstraints(3, 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.ejemplaresTableModel = 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.ejemplaresTableModel);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}

View File

@@ -21,7 +21,7 @@
<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"/> <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> </constraints>
</hspacer> </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"> <grid id="9538f" 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"/> <margin top="0" left="0" bottom="0" right="0"/>
<constraints> <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"/> <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"/>
@@ -37,6 +37,14 @@
<text value="OK"/> <text value="OK"/>
</properties> </properties>
</component> </component>
<component id="1de20" class="javax.swing.JButton" binding="cancelButton" default-binding="true">
<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> </children>
</grid> </grid>
</children> </children>

View File

@@ -23,10 +23,13 @@ public class ArriendoRecibidoDialog extends JDialog {
private JTextField multaTotalField; private JTextField multaTotalField;
private JTextField diasAtrasadosField; private JTextField diasAtrasadosField;
private JTextField multaDiariaField; private JTextField multaDiariaField;
private JButton cancelButton;
private int multaDiaria; private int multaDiaria;
private int diasAtrasados; private int diasAtrasados;
private boolean acepted;
{ {
// GUI initializer generated by IntelliJ IDEA GUI Designer // GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<< // >>> IMPORTANT!! <<<
@@ -41,17 +44,27 @@ public class ArriendoRecibidoDialog extends JDialog {
this.setContentPane(this.contentPane); this.setContentPane(this.contentPane);
this.setModal(true); this.setModal(true);
this.setLocationRelativeTo(null); this.setLocationRelativeTo(null);
this.getRootPane().setDefaultButton(this.buttonOK);
this.buttonOK.addActionListener(e -> this.dispose());
this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
this.getRootPane().setDefaultButton(this.buttonOK);
this.buttonOK.addActionListener(e -> {
this.acepted = true;
this.dispose();
});
this.addWindowListener(new WindowAdapter() { this.addWindowListener(new WindowAdapter() {
@Override @Override
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
ArriendoRecibidoDialog.this.acepted = false;
ArriendoRecibidoDialog.this.dispose(); ArriendoRecibidoDialog.this.dispose();
} }
}); });
this.contentPane.registerKeyboardAction( this.contentPane.registerKeyboardAction(
e -> this.dispose(), e -> {
this.acepted = false;
this.dispose();
},
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
); );
@@ -70,6 +83,10 @@ public class ArriendoRecibidoDialog extends JDialog {
this.setVisible(true); this.setVisible(true);
} }
public boolean isAcepted() {
return this.acepted;
}
/** /**
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code! * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code!
* *
@@ -87,7 +104,7 @@ public class ArriendoRecibidoDialog extends JDialog {
new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false)); null, null, 0, false));
final JPanel panel2 = new JPanel(); final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, 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,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
@@ -95,6 +112,10 @@ public class ArriendoRecibidoDialog extends JDialog {
buttonOK.setText("OK"); buttonOK.setText("OK");
panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 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)); GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
cancelButton = new JButton();
cancelButton.setText("Cancel");
panel2.add(cancelButton, 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(); final JPanel panel3 = new JPanel();
panel3.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); 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, contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
@@ -135,4 +156,5 @@ public class ArriendoRecibidoDialog extends JDialog {
public JComponent $$$getRootComponent$$$() { public JComponent $$$getRootComponent$$$() {
return contentPane; return contentPane;
} }
} }