Ahora todos los fields de las vistas vistas se mueven de la misma manera
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,6 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.controllers;
|
package danielcortes.xyz.controllers;
|
||||||
|
|
||||||
import danielcortes.xyz.controllers.actions.MoveToAction;
|
|
||||||
import danielcortes.xyz.data.DAOManager;
|
import danielcortes.xyz.data.DAOManager;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.documentos.Documentos;
|
import danielcortes.xyz.models.documentos.Documentos;
|
||||||
@@ -41,7 +40,7 @@ import java.awt.event.ActionEvent;
|
|||||||
* Controlador destinado a la vista ArqueoView
|
* Controlador destinado a la vista ArqueoView
|
||||||
* Maneja su contenido y las acciones que esta realiza.
|
* Maneja su contenido y las acciones que esta realiza.
|
||||||
*/
|
*/
|
||||||
public class ArqueoController {
|
public class ArqueoController extends BaseController{
|
||||||
private ArqueoView view;
|
private ArqueoView view;
|
||||||
private Caja caja;
|
private Caja caja;
|
||||||
private Efectivo efectivo;
|
private Efectivo efectivo;
|
||||||
@@ -164,45 +163,22 @@ public class ArqueoController {
|
|||||||
* Setea los eventos de los fields de la vista
|
* Setea los eventos de los fields de la vista
|
||||||
*/
|
*/
|
||||||
private void setUpViewEvents() {
|
private void setUpViewEvents() {
|
||||||
this.view.getVeinteMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getVeinteMilField(), this.view.getDiezMilField());
|
||||||
this.view.getDiezMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getDiezMilField(), this.view.getCincoMilField());
|
||||||
this.view.getCincoMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getCincoMilField(), this.view.getDosMilField());
|
||||||
this.view.getDosMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getDosMilField(), this.view.getMilField());
|
||||||
this.view.getMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getMilField(), this.view.getQuinientosField());
|
||||||
this.view.getQuinientosField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getQuinientosField(), this.view.getCienField());
|
||||||
this.view.getCienField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getCienField(), this.view.getCincuentaField());
|
||||||
this.view.getCincuentaField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getCincuentaField(), this.view.getDiezField());
|
||||||
this.view.getDiezField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "save");
|
doAction(this.view.getDiezField(), "save", KeyStroke.getKeyStroke("ENTER"), e -> this.guardarEfectivoActionListener());
|
||||||
|
moveTo(this.view.getChequesField(), this.view.getTarjetasField());
|
||||||
this.view.getVeinteMilField().getActionMap().put("nextField", new MoveToAction(this.view.getDiezMilField()));
|
moveTo(this.view.getTarjetasField(), this.view.getRetiroField());
|
||||||
this.view.getDiezMilField().getActionMap().put("nextField", new MoveToAction(this.view.getCincoMilField()));
|
doAction(this.view.getRetiroField(), "save", KeyStroke.getKeyStroke("ENTER"), e -> this.guardarDocumentosActionListener());
|
||||||
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());
|
|
||||||
|
|
||||||
|
|
||||||
this.view.getChequesField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
|
||||||
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 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 -> {
|
|
||||||
this.guardarEfectivoActionListener();
|
|
||||||
});
|
|
||||||
this.view.getGuardarDocumentosButton().addActionListener(e -> {
|
|
||||||
this.guardarEfectivoActionListener();
|
|
||||||
});
|
|
||||||
this.view.getCalcularFondoButton().addActionListener(e -> {
|
|
||||||
this.calcularFondoActionListener();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
this.view.getGuardarEfectivoButton().addActionListener(e -> this.guardarEfectivoActionListener());
|
||||||
|
this.view.getGuardarDocumentosButton().addActionListener(e -> this.guardarEfectivoActionListener());
|
||||||
|
this.view.getCalcularFondoButton().addActionListener(e -> this.calcularFondoActionListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
20
src/danielcortes/xyz/controllers/BaseController.java
Normal file
20
src/danielcortes/xyz/controllers/BaseController.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package danielcortes.xyz.controllers;
|
||||||
|
|
||||||
|
import danielcortes.xyz.controllers.actions.BasicAction;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
class BaseController {
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
static void doAction(JComponent target, String name, KeyStroke keyStroke, BasicAction action){
|
||||||
|
target.getInputMap(JComponent.WHEN_FOCUSED).put(keyStroke, name);
|
||||||
|
target.getActionMap().put(name, action);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package danielcortes.xyz.controllers;
|
package danielcortes.xyz.controllers;
|
||||||
|
|
||||||
import danielcortes.xyz.controllers.actions.MoveToAction;
|
|
||||||
import danielcortes.xyz.data.Configuration;
|
import danielcortes.xyz.data.Configuration;
|
||||||
import danielcortes.xyz.data.DAOManager;
|
import danielcortes.xyz.data.DAOManager;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
@@ -13,7 +12,7 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
public class CalcularFondoController {
|
public class CalcularFondoController extends BaseController{
|
||||||
private JComponent parent;
|
private JComponent parent;
|
||||||
private CalcularFondoView view;
|
private CalcularFondoView view;
|
||||||
private Caja caja;
|
private Caja caja;
|
||||||
@@ -52,20 +51,14 @@ public class CalcularFondoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupViewEvents() {
|
private void setupViewEvents() {
|
||||||
this.view.getValorField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getValorField(), this.view.getDescripcionField());
|
||||||
this.view.getDescripcionField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "save");
|
doAction(this.view.getDescripcionField(), "save", KeyStroke.getKeyStroke("ENTER"), e -> this.guardarActionListener());
|
||||||
this.view.getFondoField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "updateResumen");
|
doAction(this.view.getFondoField(), "updateResumen", KeyStroke.getKeyStroke("ENTER"), e -> this.updateResumen());
|
||||||
|
|
||||||
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());
|
|
||||||
|
|
||||||
this.view.getTable().getSelectionModel().addListSelectionListener(e -> updateButtonsEnabled());
|
this.view.getTable().getSelectionModel().addListSelectionListener(e -> updateButtonsEnabled());
|
||||||
|
|
||||||
this.view.getGuardarButton().addActionListener(e -> guardarActionListener());
|
this.view.getGuardarButton().addActionListener(e -> guardarActionListener());
|
||||||
this.view.getEditarButton().addActionListener(e -> editarActionListener());
|
this.view.getEditarButton().addActionListener(e -> editarActionListener());
|
||||||
this.view.getEliminarButton().addActionListener(e -> eliminarActionListener());
|
this.view.getEliminarButton().addActionListener(e -> eliminarActionListener());
|
||||||
|
|
||||||
this.view.getTable().addMouseListener(new MouseAdapter() {
|
this.view.getTable().addMouseListener(new MouseAdapter() {
|
||||||
public void mouseClicked(MouseEvent mouseEvent) {
|
public void mouseClicked(MouseEvent mouseEvent) {
|
||||||
JTable table = (JTable) mouseEvent.getSource();
|
JTable table = (JTable) mouseEvent.getSource();
|
||||||
@@ -174,13 +167,6 @@ public class CalcularFondoController {
|
|||||||
this.view.getValorField().requestFocus();
|
this.view.getValorField().requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GuardarAction extends AbstractAction {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
CalcularFondoController.this.guardarActionListener();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class UpdateResumenAction extends AbstractAction {
|
private class UpdateResumenAction extends AbstractAction {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.controllers;
|
package danielcortes.xyz.controllers;
|
||||||
|
|
||||||
import danielcortes.xyz.controllers.actions.MoveToAction;
|
|
||||||
import danielcortes.xyz.data.DAOManager;
|
import danielcortes.xyz.data.DAOManager;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.egreso.Egreso;
|
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
|
* Controlador el cual esta orientado a manejar la vista de EgresosView
|
||||||
* Maneja su contenido y las acciones que esta realiza
|
* Maneja su contenido y las acciones que esta realiza
|
||||||
*/
|
*/
|
||||||
public class EgresosController {
|
public class EgresosController extends BaseController{
|
||||||
private EgresosView view;
|
private EgresosView view;
|
||||||
private Caja caja;
|
private Caja caja;
|
||||||
|
|
||||||
@@ -103,15 +102,10 @@ public class EgresosController {
|
|||||||
* - Cuando se selecciona una fila en la tabla se llama a updateButtonsEnabled
|
* - Cuando se selecciona una fila en la tabla se llama a updateButtonsEnabled
|
||||||
*/
|
*/
|
||||||
private void setUpViewEvents() {
|
private void setUpViewEvents() {
|
||||||
this.view.getNroField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getNroField(), this.view.getDescripcionField());
|
||||||
this.view.getValorField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getDescripcionField(), this.view.getValorField());
|
||||||
this.view.getDescripcionField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getValorField(), this.view.getTipoCombo());
|
||||||
this.view.getTipoCombo().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "save");
|
doAction(this.view.getTipoCombo(), "save", KeyStroke.getKeyStroke("ENTER"), e -> this.guardarActionListener());
|
||||||
|
|
||||||
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());
|
this.view.getEgresosTable().getSelectionModel().addListSelectionListener(e -> updateButtonsEnabled());
|
||||||
this.view.getGuardarButton().addActionListener(e -> guardarActionListener());
|
this.view.getGuardarButton().addActionListener(e -> guardarActionListener());
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package danielcortes.xyz.controllers;
|
package danielcortes.xyz.controllers;
|
||||||
|
|
||||||
import danielcortes.xyz.controllers.actions.BasicAction;
|
|
||||||
import danielcortes.xyz.data.DAOManager;
|
import danielcortes.xyz.data.DAOManager;
|
||||||
import danielcortes.xyz.models.estado_resultado.EstadoResultado;
|
import danielcortes.xyz.models.estado_resultado.EstadoResultado;
|
||||||
import danielcortes.xyz.models.estado_resultado.EstadoResultadoDAO;
|
import danielcortes.xyz.models.estado_resultado.EstadoResultadoDAO;
|
||||||
@@ -8,10 +7,9 @@ import danielcortes.xyz.models.tipo_egreso.TipoEgreso;
|
|||||||
import danielcortes.xyz.views.EstadoResultadoView;
|
import danielcortes.xyz.views.EstadoResultadoView;
|
||||||
import danielcortes.xyz.views.listeners.FocusLostListener;
|
import danielcortes.xyz.views.listeners.FocusLostListener;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.time.YearMonth;
|
import java.time.YearMonth;
|
||||||
|
|
||||||
public class EstadoResultadoController {
|
public class EstadoResultadoController extends BaseController{
|
||||||
private EstadoResultadoView view;
|
private EstadoResultadoView view;
|
||||||
private EstadoResultado estadoResultado;
|
private EstadoResultado estadoResultado;
|
||||||
private YearMonth mes;
|
private YearMonth mes;
|
||||||
@@ -74,15 +72,6 @@ public class EstadoResultadoController {
|
|||||||
moveTo(this.view.getResumenPPM(), this.view.getResumenIVAFavor());
|
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() {
|
private void guardarListener() {
|
||||||
EstadoResultadoDAO dao = DAOManager.getEstadoResultadoDAO();
|
EstadoResultadoDAO dao = DAOManager.getEstadoResultadoDAO();
|
||||||
dao.updateEstadoResultado(this.estadoResultado);
|
dao.updateEstadoResultado(this.estadoResultado);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import java.awt.event.MouseEvent;
|
|||||||
* Controlador el cual esta orientado a manejar la vista de IngresosView
|
* Controlador el cual esta orientado a manejar la vista de IngresosView
|
||||||
* Maneja su contenido y las acciones que esta realiza
|
* Maneja su contenido y las acciones que esta realiza
|
||||||
*/
|
*/
|
||||||
public class IngresosController {
|
public class IngresosController extends BaseController{
|
||||||
private IngresosView view;
|
private IngresosView view;
|
||||||
private Caja caja;
|
private Caja caja;
|
||||||
|
|
||||||
@@ -103,19 +103,12 @@ public class IngresosController {
|
|||||||
* - Cuando se presiona el boton de editar o se hace doble click sobre una fila de la tabla se llama a editarActionListener
|
* - Cuando se presiona el boton de editar o se hace doble click sobre una fila de la tabla se llama a editarActionListener
|
||||||
*/
|
*/
|
||||||
private void setupViewEvents() {
|
private void setupViewEvents() {
|
||||||
this.view.getValorField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getValorField(), this.view.getNroZInicialField());
|
||||||
this.view.getNroZInicialField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getNroZInicialField(), this.view.getNroZFinalField());
|
||||||
this.view.getNroZFinalField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getNroZFinalField(), this.view.getNroInicialField());
|
||||||
this.view.getNroInicialField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getNroInicialField(), this.view.getNroFinalField());
|
||||||
this.view.getNroFinalField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
moveTo(this.view.getNroFinalField(), this.view.getTipoCombo());
|
||||||
this.view.getTipoCombo().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "save");
|
doAction(this.view.getTipoCombo(), "save", KeyStroke.getKeyStroke("ENTER"), e ->this.guardarActionListener());
|
||||||
|
|
||||||
this.view.getValorField().getActionMap().put("nextField", new NextAction(this.view.getNroZInicialField()));
|
|
||||||
this.view.getNroZInicialField().getActionMap().put("nextField", new NextAction(this.view.getNroZFinalField()));
|
|
||||||
this.view.getNroZFinalField().getActionMap().put("nextField", new NextAction(this.view.getNroInicialField()));
|
|
||||||
this.view.getNroInicialField().getActionMap().put("nextField", new NextAction(this.view.getNroFinalField()));
|
|
||||||
this.view.getNroFinalField().getActionMap().put("nextField", new NextAction(this.view.getTipoCombo()));
|
|
||||||
this.view.getTipoCombo().getActionMap().put("save", new GuardarAction(this));
|
|
||||||
|
|
||||||
this.view.getIngresosTable().getSelectionModel().addListSelectionListener(e -> updateButtonsEnabled());
|
this.view.getIngresosTable().getSelectionModel().addListSelectionListener(e -> updateButtonsEnabled());
|
||||||
this.view.getGuardarButton().addActionListener(e -> guardarActionListener());
|
this.view.getGuardarButton().addActionListener(e -> guardarActionListener());
|
||||||
|
|||||||
Reference in New Issue
Block a user