Creado el movimiento con escape y enter en la vista de Estado resultado, se extendera a todo el resto el nuevo metodo por ser mas limpio
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.controllers.actions.BasicAction;
|
||||
import danielcortes.xyz.data.DAOManager;
|
||||
import danielcortes.xyz.models.estado_resultado.EstadoResultado;
|
||||
import danielcortes.xyz.models.estado_resultado.EstadoResultadoDAO;
|
||||
@@ -7,6 +8,7 @@ import danielcortes.xyz.models.tipo_egreso.TipoEgreso;
|
||||
import danielcortes.xyz.views.EstadoResultadoView;
|
||||
import danielcortes.xyz.views.listeners.FocusLostListener;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.time.YearMonth;
|
||||
|
||||
public class EstadoResultadoController {
|
||||
@@ -24,6 +26,13 @@ public class EstadoResultadoController {
|
||||
this.view.getMonthCombo().addActionListener(e -> this.updateMonth());
|
||||
this.view.getYearSpinner().addChangeListener(e -> this.updateMonth());
|
||||
|
||||
this.setupUpdateViewEvents();
|
||||
this.setupMovementViewEvents();
|
||||
|
||||
this.view.getGuardarButton().addActionListener(e -> EstadoResultadoController.this.guardarListener());
|
||||
}
|
||||
|
||||
private void setupUpdateViewEvents(){
|
||||
this.view.getGastosGeneralesCuentaCorrienteFactura().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosGenerales());
|
||||
this.view.getGastosGeneralesCuentaCorrienteBoleta().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosGenerales());
|
||||
this.view.getGastosGeneralesCuentaCorrienteSinRespaldo().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosGenerales());
|
||||
@@ -44,8 +53,34 @@ public class EstadoResultadoController {
|
||||
|
||||
this.view.getResumenIVAFavor().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateResumen());
|
||||
this.view.getResumenPPM().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateResumen());
|
||||
}
|
||||
|
||||
this.view.getGuardarButton().addActionListener(e -> EstadoResultadoController.this.guardarListener());
|
||||
private void setupMovementViewEvents() {
|
||||
moveTo(this.view.getGastosGeneralesCuentaCorrienteFactura(), this.view.getGastosGeneralesCuentaCorrienteBoleta());
|
||||
moveTo(this.view.getGastosGeneralesCuentaCorrienteBoleta(), this.view.getGastosGeneralesCuentaCorrienteSinRespaldo());
|
||||
moveTo(this.view.getGastosGeneralesCuentaCorrienteSinRespaldo(), this.view.getGastosOperacionalesCostoVenta());
|
||||
moveTo(this.view.getGastosOperacionalesCostoVenta(), this.view.getGastosOperacionalesRemuneraciones());
|
||||
moveTo(this.view.getGastosOperacionalesRemuneraciones(), this.view.getGastosOperacionalesFiniquitos());
|
||||
moveTo(this.view.getGastosOperacionalesFiniquitos(), this.view.getGastosOperacionalesAguinaldo());
|
||||
moveTo(this.view.getGastosOperacionalesAguinaldo(), this.view.getGastosOperacionalesBonos());
|
||||
moveTo(this.view.getGastosOperacionalesBonos(), this.view.getGastosOperacionalesHonorariosContador());
|
||||
moveTo(this.view.getGastosOperacionalesHonorariosContador(), this.view.getGastosOperacionalesArriendo());
|
||||
moveTo(this.view.getGastosOperacionalesArriendo(), this.view.getServiciosAgua());
|
||||
moveTo(this.view.getServiciosAgua(), this.view.getServiciosLuz());
|
||||
moveTo(this.view.getServiciosLuz(), this.view.getServiciosGas());
|
||||
moveTo(this.view.getServiciosGas(), this.view.getServiciosTelefono());
|
||||
moveTo(this.view.getServiciosTelefono(), this.view.getServiciosOtro());
|
||||
moveTo(this.view.getServiciosOtro(), this.view.getResumenPPM());
|
||||
moveTo(this.view.getResumenPPM(), this.view.getResumenIVAFavor());
|
||||
}
|
||||
|
||||
private static void moveTo(JComponent origin, JComponent destiny) {
|
||||
KeyStroke next = KeyStroke.getKeyStroke("ENTER");
|
||||
KeyStroke back = KeyStroke.getKeyStroke("ESCAPE");
|
||||
origin.getInputMap(JComponent.WHEN_FOCUSED).put(next, "nextField");
|
||||
destiny.getInputMap(JComponent.WHEN_FOCUSED).put(back, "previousField");
|
||||
origin.getActionMap().put("nextField", (BasicAction) e -> destiny.requestFocus());
|
||||
destiny.getActionMap().put("previousField", (BasicAction) e -> origin.requestFocus());
|
||||
}
|
||||
|
||||
private void guardarListener() {
|
||||
|
||||
Reference in New Issue
Block a user