Ahora todos los fields de las vistas vistas se mueven de la misma manera

This commit is contained in:
Daniel Cortes
2019-02-16 14:49:40 -03:00
parent c2ff258cef
commit e65ac2bc10
7 changed files with 53 additions and 95 deletions

View File

@@ -24,7 +24,6 @@
package danielcortes.xyz.controllers;
import danielcortes.xyz.controllers.actions.MoveToAction;
import danielcortes.xyz.data.DAOManager;
import danielcortes.xyz.models.caja.Caja;
import danielcortes.xyz.models.egreso.Egreso;
@@ -42,7 +41,7 @@ import java.awt.event.MouseEvent;
* Controlador el cual esta orientado a manejar la vista de EgresosView
* Maneja su contenido y las acciones que esta realiza
*/
public class EgresosController {
public class EgresosController extends BaseController{
private EgresosView view;
private Caja caja;
@@ -103,15 +102,10 @@ public class EgresosController {
* - Cuando se selecciona una fila en la tabla se llama a updateButtonsEnabled
*/
private void setUpViewEvents() {
this.view.getNroField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
this.view.getValorField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
this.view.getDescripcionField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
this.view.getTipoCombo().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "save");
this.view.getNroField().getActionMap().put("nextField", new MoveToAction(this.view.getDescripcionField()));
this.view.getDescripcionField().getActionMap().put("nextField", new MoveToAction(this.view.getValorField()));
this.view.getValorField().getActionMap().put("nextField", new MoveToAction(this.view.getTipoCombo()));
this.view.getTipoCombo().getActionMap().put("save", new GuardarAction(this));
moveTo(this.view.getNroField(), this.view.getDescripcionField());
moveTo(this.view.getDescripcionField(), this.view.getValorField());
moveTo(this.view.getValorField(), this.view.getTipoCombo());
doAction(this.view.getTipoCombo(), "save", KeyStroke.getKeyStroke("ENTER"), e -> this.guardarActionListener());
this.view.getEgresosTable().getSelectionModel().addListSelectionListener(e -> updateButtonsEnabled());
this.view.getGuardarButton().addActionListener(e -> guardarActionListener());