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:
BIN
dist/local-release/Programa Caja.jar
vendored
BIN
dist/local-release/Programa Caja.jar
vendored
Binary file not shown.
@@ -24,7 +24,7 @@
|
||||
|
||||
package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.controllers.actions.NextAction;
|
||||
import danielcortes.xyz.controllers.actions.MoveToAction;
|
||||
import danielcortes.xyz.data.DAOManager;
|
||||
import danielcortes.xyz.models.caja.Caja;
|
||||
import danielcortes.xyz.models.documentos.Documentos;
|
||||
@@ -174,14 +174,14 @@ public class ArqueoController {
|
||||
this.view.getCincuentaField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getDiezField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "save");
|
||||
|
||||
this.view.getVeinteMilField().getActionMap().put("nextField", new NextAction(this.view.getDiezMilField()));
|
||||
this.view.getDiezMilField().getActionMap().put("nextField", new NextAction(this.view.getCincoMilField()));
|
||||
this.view.getCincoMilField().getActionMap().put("nextField", new NextAction(this.view.getDosMilField()));
|
||||
this.view.getDosMilField().getActionMap().put("nextField", new NextAction(this.view.getMilField()));
|
||||
this.view.getMilField().getActionMap().put("nextField", new NextAction(this.view.getQuinientosField()));
|
||||
this.view.getQuinientosField().getActionMap().put("nextField", new NextAction(this.view.getCienField()));
|
||||
this.view.getCienField().getActionMap().put("nextField", new NextAction(this.view.getCincuentaField()));
|
||||
this.view.getCincuentaField().getActionMap().put("nextField", new NextAction(this.view.getDiezField()));
|
||||
this.view.getVeinteMilField().getActionMap().put("nextField", new MoveToAction(this.view.getDiezMilField()));
|
||||
this.view.getDiezMilField().getActionMap().put("nextField", new MoveToAction(this.view.getCincoMilField()));
|
||||
this.view.getCincoMilField().getActionMap().put("nextField", new MoveToAction(this.view.getDosMilField()));
|
||||
this.view.getDosMilField().getActionMap().put("nextField", new MoveToAction(this.view.getMilField()));
|
||||
this.view.getMilField().getActionMap().put("nextField", new MoveToAction(this.view.getQuinientosField()));
|
||||
this.view.getQuinientosField().getActionMap().put("nextField", new MoveToAction(this.view.getCienField()));
|
||||
this.view.getCienField().getActionMap().put("nextField", new MoveToAction(this.view.getCincuentaField()));
|
||||
this.view.getCincuentaField().getActionMap().put("nextField", new MoveToAction(this.view.getDiezField()));
|
||||
this.view.getDiezField().getActionMap().put("save", new GuardarEfectivoAction());
|
||||
|
||||
|
||||
@@ -189,8 +189,8 @@ public class ArqueoController {
|
||||
this.view.getTarjetasField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getRetiroField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "save");
|
||||
|
||||
this.view.getChequesField().getActionMap().put("nextField", new NextAction(this.view.getTarjetasField()));
|
||||
this.view.getTarjetasField().getActionMap().put("nextField", new NextAction(this.view.getRetiroField()));
|
||||
this.view.getChequesField().getActionMap().put("nextField", new MoveToAction(this.view.getTarjetasField()));
|
||||
this.view.getTarjetasField().getActionMap().put("nextField", new MoveToAction(this.view.getRetiroField()));
|
||||
this.view.getRetiroField().getActionMap().put("save", new GuardarDocumentosAction());
|
||||
|
||||
this.view.getGuardarEfectivoButton().addActionListener(e -> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.controllers.actions.NextAction;
|
||||
import danielcortes.xyz.controllers.actions.MoveToAction;
|
||||
import danielcortes.xyz.data.Configuration;
|
||||
import danielcortes.xyz.data.DAOManager;
|
||||
import danielcortes.xyz.models.caja.Caja;
|
||||
@@ -56,7 +56,7 @@ public class CalcularFondoController {
|
||||
this.view.getDescripcionField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "save");
|
||||
this.view.getFondoField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "updateResumen");
|
||||
|
||||
this.view.getValorField().getActionMap().put("nextField", new NextAction(this.view.getDescripcionField()));
|
||||
this.view.getValorField().getActionMap().put("nextField", new MoveToAction(this.view.getDescripcionField()));
|
||||
this.view.getDescripcionField().getActionMap().put("save", new GuardarAction());
|
||||
this.view.getFondoField().getActionMap().put("updateResumen", new UpdateResumenAction());
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.controllers.actions.NextAction;
|
||||
import danielcortes.xyz.controllers.actions.MoveToAction;
|
||||
import danielcortes.xyz.data.DAOManager;
|
||||
import danielcortes.xyz.models.caja.Caja;
|
||||
import danielcortes.xyz.models.egreso.Egreso;
|
||||
@@ -108,9 +108,9 @@ public class EgresosController {
|
||||
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 NextAction(this.view.getDescripcionField()));
|
||||
this.view.getDescripcionField().getActionMap().put("nextField", new NextAction(this.view.getValorField()));
|
||||
this.view.getValorField().getActionMap().put("nextField", new NextAction(this.view.getTipoCombo()));
|
||||
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));
|
||||
|
||||
this.view.getEgresosTable().getSelectionModel().addListSelectionListener(e -> updateButtonsEnabled());
|
||||
|
||||
@@ -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() {
|
||||
|
||||
35
src/danielcortes/xyz/controllers/actions/BasicAction.java
Normal file
35
src/danielcortes/xyz/controllers/actions/BasicAction.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package danielcortes.xyz.controllers.actions;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
public interface BasicAction extends Action {
|
||||
@Override
|
||||
default Object getValue(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
default void putValue(String key, Object value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void setEnabled(boolean b) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
default void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||
}
|
||||
|
||||
void actionPerformed(ActionEvent e);
|
||||
}
|
||||
@@ -27,10 +27,10 @@ package danielcortes.xyz.controllers.actions;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class NextAction extends AbstractAction {
|
||||
public class MoveToAction extends AbstractAction {
|
||||
private JComponent next;
|
||||
|
||||
public NextAction(JComponent next) {
|
||||
public MoveToAction(JComponent next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user