Volver button en update autor

This commit is contained in:
Daniel Cortés
2019-05-08 08:54:09 -04:00
parent e5acc24fd4
commit cfa098fb21
3 changed files with 45 additions and 23 deletions

View File

@@ -44,19 +44,24 @@ public class AutorUpdateController extends BaseController {
private void setupListeners() { private void setupListeners() {
this.view.getApellidoPaternoField().addActionListener(e -> update()); this.view.getApellidoPaternoField().addActionListener(e -> update());
this.view.getActualizarButton().addActionListener(e -> update()); this.view.getActualizarButton().addActionListener(e -> update());
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.AUTOR_SEARCH));
} }
private void update() { private void update() {
if(!validateOriginal(this.autor)) return; if (!validateOriginal(this.autor))
return;
String nombre = this.view.getNombreField().getText(); String nombre = this.view.getNombreField().getText();
if(!validateNombre(nombre)) return; if (!validateNombre(nombre))
return;
String apellidoPaterno = this.view.getApellidoPaternoField().getText(); String apellidoPaterno = this.view.getApellidoPaternoField().getText();
if(!validateApellidoPaterno(apellidoPaterno)) return; if (!validateApellidoPaterno(apellidoPaterno))
return;
String apellidoMaterno = this.view.getApellidoMaternoField().getText(); String apellidoMaterno = this.view.getApellidoMaternoField().getText();
if(!validateApellidoMaterno(apellidoMaterno)) return; if (!validateApellidoMaterno(apellidoMaterno))
return;
assert this.autor != null; assert this.autor != null;
this.autor.setNombre(nombre); this.autor.setNombre(nombre);

View File

@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.autor.AutorUpdatePanel"> <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.autor.AutorUpdatePanel">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="8" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="8" column-count="4" 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>
<xy x="20" y="20" width="500" height="400"/> <xy x="20" y="20" width="532" height="400"/>
</constraints> </constraints>
<properties/> <properties/>
<border type="none"/> <border type="none"/>
<children> <children>
<component id="c24c2" class="javax.swing.JLabel"> <component id="c24c2" class="javax.swing.JLabel">
<constraints> <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"/> <grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Nombre:"/> <text value="Nombre:"/>
@@ -18,7 +18,7 @@
</component> </component>
<component id="c6a4b" class="javax.swing.JTextField" binding="nombreField"> <component id="c6a4b" class="javax.swing.JTextField" binding="nombreField">
<constraints> <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"> <grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/> <preferred-size width="400" height="-1"/>
</grid> </grid>
</constraints> </constraints>
@@ -26,7 +26,7 @@
</component> </component>
<component id="48e89" class="javax.swing.JLabel"> <component id="48e89" class="javax.swing.JLabel">
<constraints> <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"/> <grid row="2" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Apellido Paterno:"/> <text value="Apellido Paterno:"/>
@@ -34,7 +34,7 @@
</component> </component>
<component id="294b" class="javax.swing.JTextField" binding="apellidoPaternoField"> <component id="294b" class="javax.swing.JTextField" binding="apellidoPaternoField">
<constraints> <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"> <grid row="3" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/> <preferred-size width="400" height="-1"/>
</grid> </grid>
</constraints> </constraints>
@@ -42,7 +42,7 @@
</component> </component>
<component id="c0a2b" class="javax.swing.JTextField" binding="apellidoMaternoField"> <component id="c0a2b" class="javax.swing.JTextField" binding="apellidoMaternoField">
<constraints> <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"> <grid row="5" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/> <preferred-size width="400" height="-1"/>
</grid> </grid>
</constraints> </constraints>
@@ -50,7 +50,7 @@
</component> </component>
<component id="a4360" class="javax.swing.JLabel"> <component id="a4360" class="javax.swing.JLabel">
<constraints> <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"/> <grid row="4" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Apellido Materno:"/> <text value="Apellido Materno:"/>
@@ -66,12 +66,12 @@
</component> </component>
<vspacer id="29de9"> <vspacer id="29de9">
<constraints> <constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> <grid row="7" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</vspacer> </vspacer>
<hspacer id="4e68"> <hspacer id="4e68">
<constraints> <constraints>
<grid row="7" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="7" column="3" 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>
<hspacer id="1cc6d"> <hspacer id="1cc6d">
@@ -79,6 +79,14 @@
<grid row="7" 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="7" 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>
<component id="125a5" class="javax.swing.JButton" binding="volverButton" default-binding="true">
<constraints>
<grid row="6" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Volver"/>
</properties>
</component>
</children> </children>
</grid> </grid>
</form> </form>

View File

@@ -19,6 +19,7 @@ public class AutorUpdatePanel extends BasePanel {
private JTextField apellidoMaternoField; private JTextField apellidoMaternoField;
private JButton actualizarButton; private JButton actualizarButton;
private JPanel contentPane; private JPanel contentPane;
private JButton volverButton;
public JTextField getNombreField() { public JTextField getNombreField() {
return nombreField; return nombreField;
@@ -36,6 +37,10 @@ public class AutorUpdatePanel extends BasePanel {
return actualizarButton; return actualizarButton;
} }
public JButton getVolverButton() {
return volverButton;
}
public JPanel getContentPane() { public JPanel getContentPane() {
return contentPane; return contentPane;
} }
@@ -55,30 +60,30 @@ public class AutorUpdatePanel extends BasePanel {
*/ */
private void $$$setupUI$$$() { private void $$$setupUI$$$() {
contentPane = new JPanel(); contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(8, 3, new Insets(0, 0, 0, 0), -1, -1)); contentPane.setLayout(new GridLayoutManager(8, 4, new Insets(0, 0, 0, 0), -1, -1));
final JLabel label1 = new JLabel(); final JLabel label1 = new JLabel();
label1.setText("Nombre:"); label1.setText("Nombre:");
contentPane.add(label1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, contentPane.add(label1, new GridConstraints(0, 1, 1, 2, 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));
nombreField = new JTextField(); nombreField = new JTextField();
contentPane.add(nombreField, contentPane.add(nombreField,
new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, new GridConstraints(1, 1, 1, 2, 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));
final JLabel label2 = new JLabel(); final JLabel label2 = new JLabel();
label2.setText("Apellido Paterno:"); label2.setText("Apellido Paterno:");
contentPane.add(label2, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, contentPane.add(label2, new GridConstraints(2, 1, 1, 2, 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));
apellidoPaternoField = new JTextField(); apellidoPaternoField = new JTextField();
contentPane.add(apellidoPaternoField, contentPane.add(apellidoPaternoField,
new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, new GridConstraints(3, 1, 1, 2, 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));
apellidoMaternoField = new JTextField(); apellidoMaternoField = new JTextField();
contentPane.add(apellidoMaternoField, contentPane.add(apellidoMaternoField,
new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, new GridConstraints(5, 1, 1, 2, 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));
final JLabel label3 = new JLabel(); final JLabel label3 = new JLabel();
label3.setText("Apellido Materno:"); label3.setText("Apellido Materno:");
contentPane.add(label3, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, contentPane.add(label3, new GridConstraints(4, 1, 1, 2, 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));
actualizarButton = new JButton(); actualizarButton = new JButton();
actualizarButton.setText("Actualizar"); actualizarButton.setText("Actualizar");
@@ -86,16 +91,20 @@ public class AutorUpdatePanel extends BasePanel {
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));
final Spacer spacer1 = new Spacer(); final Spacer spacer1 = new Spacer();
contentPane.add(spacer1, contentPane.add(spacer1,
new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, new GridConstraints(7, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
null, null, 0, false)); null, null, 0, false));
final Spacer spacer2 = new Spacer(); final Spacer spacer2 = new Spacer();
contentPane.add(spacer2, contentPane.add(spacer2,
new GridConstraints(7, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, new GridConstraints(7, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false)); null, null, 0, false));
final Spacer spacer3 = new Spacer(); final Spacer spacer3 = new Spacer();
contentPane.add(spacer3, contentPane.add(spacer3,
new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false)); null, null, 0, false));
volverButton = new JButton();
volverButton.setText("Volver");
contentPane.add(volverButton, new GridConstraints(6, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
} }
/** /**