se ejecuto limpieza del codigo, reformateo del codigo y optimizacion de los imports por parte del IDE
This commit is contained in:
@@ -33,7 +33,9 @@ import danielcortes.xyz.views.IngresosView;
|
||||
import danielcortes.xyz.views.components.IngresosTableModel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
/**
|
||||
* Controlador el cual esta orientado a manejar la vista de IngresosView
|
||||
@@ -74,6 +76,7 @@ public class IngresosController {
|
||||
|
||||
/**
|
||||
* Getter!!!
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TipoIngresoDAO getTipoIngresoDAO() {
|
||||
@@ -83,7 +86,7 @@ public class IngresosController {
|
||||
/**
|
||||
* Guarda la caja ingresada y actualiza el contenido de la tabla de ingresos y el campo de total de ingresos
|
||||
*/
|
||||
public void updateCaja(Caja caja){
|
||||
public void updateCaja(Caja caja) {
|
||||
this.caja = caja;
|
||||
this.fillIngresosTable();
|
||||
this.updateTotalIngresos();
|
||||
@@ -113,7 +116,7 @@ public class IngresosController {
|
||||
/**
|
||||
* Genera los eventos para los distintos componentes de la vista
|
||||
* - Cuando se presiona el boton de guardar o se apreta enter en los fields de valor, nro inicial,
|
||||
* nro final y tipo se llama a guardarActionListener
|
||||
* nro final y tipo se llama a guardarActionListener
|
||||
* - Cuando se presiona el boton de eliminar se llama al eliminarActionListener
|
||||
* - Cuando se selecciona una fila en la tabla se llama a updateButtonsEnabled
|
||||
* - Cuando se presiona el boton de editar o se hace doble click sobre una fila de la tabla se llama a editarActionListener
|
||||
@@ -165,7 +168,7 @@ public class IngresosController {
|
||||
String nroFinal = this.view.getNroFinalField().getText();
|
||||
TipoIngreso tipoIngreso = (TipoIngreso) this.view.getTipoCombo().getSelectedItem();
|
||||
|
||||
if(editing) {
|
||||
if (editing) {
|
||||
this.editarIngreso(valor, nroZInicial, nroZFinal, nroInicial, nroFinal, tipoIngreso, this.caja);
|
||||
} else {
|
||||
this.guardarIngreso(valor, nroZInicial, nroZFinal, nroInicial, nroFinal, tipoIngreso, this.caja);
|
||||
@@ -180,7 +183,7 @@ public class IngresosController {
|
||||
*/
|
||||
private void eliminarActionListener() {
|
||||
int selectedId = this.view.getIngresosTable().getSelectedRow();
|
||||
if(selectedId >= 0){
|
||||
if (selectedId >= 0) {
|
||||
Ingreso ingreso = this.view.getIngresosTableModel().getIngreso(selectedId);
|
||||
this.view.getIngresosTableModel().removeRow(selectedId);
|
||||
this.ingresoDAO.deleteIngreso(ingreso);
|
||||
@@ -200,7 +203,7 @@ public class IngresosController {
|
||||
|
||||
int selectedID = this.view.getIngresosTable().getSelectedRow();
|
||||
int selectedModelID = this.view.getIngresosTable().getRowSorter().convertRowIndexToModel(selectedID);
|
||||
if(selectedModelID >= 0) {
|
||||
if (selectedModelID >= 0) {
|
||||
Ingreso ingreso = this.view.getIngresosTableModel().getIngreso(selectedModelID);
|
||||
|
||||
this.editingId = selectedModelID;
|
||||
@@ -219,7 +222,7 @@ public class IngresosController {
|
||||
/**
|
||||
* Obtiene el total de ingresos de la caja y lo coloca en el el field totalingresos
|
||||
*/
|
||||
private void updateTotalIngresos(){
|
||||
private void updateTotalIngresos() {
|
||||
int total = this.ingresoDAO.getTotalIngreso(this.caja);
|
||||
this.view.getTotalIngresoField().setValue(total);
|
||||
}
|
||||
@@ -230,10 +233,10 @@ public class IngresosController {
|
||||
* Si es asi, son habilidatos, si no, de deshabilitan
|
||||
*/
|
||||
private void updateButtonsEnabled() {
|
||||
if(this.view.getIngresosTable().getSelectedRow()>=0){
|
||||
if (this.view.getIngresosTable().getSelectedRow() >= 0) {
|
||||
this.view.getEliminarButton().setEnabled(true);
|
||||
this.view.getEditarButton().setEnabled(true);
|
||||
}else{
|
||||
} else {
|
||||
this.view.getEliminarButton().setEnabled(false);
|
||||
this.view.getEditarButton().setEnabled(false);
|
||||
}
|
||||
@@ -243,8 +246,8 @@ public class IngresosController {
|
||||
* Guarda un ingreso tras llamar a validar el input
|
||||
* Luego de guardar agrega a la tabla el ingreso, llama a limpiar los campos de input y a actualizar el total de ingresos
|
||||
*/
|
||||
private void guardarIngreso(int valor, String nroZInicial, String nroZFinal, String nroInicial, String nroFinal, TipoIngreso tipoIngreso, Caja caja){
|
||||
if(this.validateInput(nroZInicial, nroZFinal, nroInicial, nroFinal, tipoIngreso, caja)){
|
||||
private void guardarIngreso(int valor, String nroZInicial, String nroZFinal, String nroInicial, String nroFinal, TipoIngreso tipoIngreso, Caja caja) {
|
||||
if (this.validateInput(nroZInicial, nroZFinal, nroInicial, nroFinal, tipoIngreso, caja)) {
|
||||
Ingreso ingreso = new Ingreso();
|
||||
ingreso.setTipoIngreso(tipoIngreso);
|
||||
ingreso.setCaja(caja);
|
||||
@@ -265,10 +268,9 @@ public class IngresosController {
|
||||
/**
|
||||
* Edita el ingreso tras llamar a validar el input
|
||||
* Tras esto actualiza el ingreso en la tabla, llama a actualizar el total de ingresos, a limpiar los campos de input y a desactivar la flag de editing.
|
||||
*
|
||||
*/
|
||||
private void editarIngreso(int valor, String nroZInicial, String nroZFinal, String nroInicial, String nroFinal, TipoIngreso tipoIngreso, Caja caja){
|
||||
if(this.validateInput(nroZInicial, nroZFinal, nroInicial, nroFinal, tipoIngreso, caja)){
|
||||
private void editarIngreso(int valor, String nroZInicial, String nroZFinal, String nroInicial, String nroFinal, TipoIngreso tipoIngreso, Caja caja) {
|
||||
if (this.validateInput(nroZInicial, nroZFinal, nroInicial, nroFinal, tipoIngreso, caja)) {
|
||||
this.editingIngreso.setTipoIngreso(tipoIngreso);
|
||||
this.editingIngreso.setValor(valor);
|
||||
this.editingIngreso.setNroZInicial(nroZInicial);
|
||||
@@ -285,6 +287,7 @@ public class IngresosController {
|
||||
|
||||
/**
|
||||
* Llama a los metodos necesarios para validar el input
|
||||
*
|
||||
* @return true cuando todas las validaciones retoran true, si no, false
|
||||
*/
|
||||
private boolean validateInput(String nroZInicial, String nroZFinal, String nroInicial, String nroFinal, TipoIngreso tipoIngreso, Caja caja) {
|
||||
@@ -300,7 +303,8 @@ public class IngresosController {
|
||||
|
||||
/**
|
||||
* Valida la variable caja este caso
|
||||
* - Es null
|
||||
* - Es null
|
||||
*
|
||||
* @return Si este caso es true se retornara false, si no, se retorna true
|
||||
*/
|
||||
private boolean validateCaja(Caja caja) {
|
||||
@@ -309,12 +313,13 @@ public class IngresosController {
|
||||
|
||||
/**
|
||||
* Valida la variable nroInicial contra los casos
|
||||
* - Es null
|
||||
* - Esta vacio
|
||||
* Cuando el primer caso sea true, colocara un mensaje de error correspondiente en el jlabel correspondiente
|
||||
* - Es null
|
||||
* - Esta vacio
|
||||
* Cuando el primer caso sea true, colocara un mensaje de error correspondiente en el jlabel correspondiente
|
||||
*
|
||||
* @return Si cualquiera de estos casos son true se retornara false, si no, se retorna true
|
||||
*/
|
||||
private boolean validateNroInicial(String nroInicial){
|
||||
private boolean validateNroInicial(String nroInicial) {
|
||||
if (nroInicial == null) {
|
||||
this.view.getErrorNroInicial().setText("Hubo un problema con los datos");
|
||||
this.view.getErrorNroInicial().setVisible(true);
|
||||
@@ -331,12 +336,13 @@ public class IngresosController {
|
||||
|
||||
/**
|
||||
* Valida la variable nroFinal contra los casos
|
||||
* - Es null
|
||||
* - Esta vacio
|
||||
* Cuando el primer caso sea true, colocara un mensaje de error correspondiente en el jlabel correspondiente
|
||||
* - Es null
|
||||
* - Esta vacio
|
||||
* Cuando el primer caso sea true, colocara un mensaje de error correspondiente en el jlabel correspondiente
|
||||
*
|
||||
* @return Si cualquiera de estos casos son true se retornara false, si no, se retorna true
|
||||
*/
|
||||
private boolean validateNroFinal(String nroFinal){
|
||||
private boolean validateNroFinal(String nroFinal) {
|
||||
if (nroFinal == null) {
|
||||
this.view.getErrorNroFinal().setText("Hubo un problema con los datos");
|
||||
this.view.getErrorNroFinal().setVisible(true);
|
||||
@@ -353,8 +359,9 @@ public class IngresosController {
|
||||
|
||||
/**
|
||||
* Valida la variable caja este caso
|
||||
* - Es null
|
||||
* Cuando sea true, colocara un mensaje de error en el jlabel correspondiente
|
||||
* - Es null
|
||||
* Cuando sea true, colocara un mensaje de error en el jlabel correspondiente
|
||||
*
|
||||
* @return Si este caso es true se retornara false, si no, se retorna true
|
||||
*/
|
||||
private boolean validateTipoIngreso(TipoIngreso tipoIngreso) {
|
||||
@@ -391,7 +398,7 @@ public class IngresosController {
|
||||
/**
|
||||
* Ejecuta un trim sobre todos los jtextfield
|
||||
*/
|
||||
private void normalizeInputs(){
|
||||
private void normalizeInputs() {
|
||||
this.view.getNroZInicialField().setText(this.view.getNroZInicialField().getText().trim());
|
||||
this.view.getNroZFinalField().setText(this.view.getNroZFinalField().getText().trim());
|
||||
this.view.getNroInicialField().setText(this.view.getNroInicialField().getText().trim());
|
||||
@@ -401,14 +408,14 @@ public class IngresosController {
|
||||
/**
|
||||
* Le pide focus al tipo combo
|
||||
*/
|
||||
private void resetFocus(){
|
||||
private void resetFocus() {
|
||||
this.view.getValorField().requestFocus();
|
||||
}
|
||||
|
||||
private class NextAction extends AbstractAction{
|
||||
private class NextAction extends AbstractAction {
|
||||
JComponent next;
|
||||
|
||||
NextAction(JComponent next){
|
||||
NextAction(JComponent next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
@@ -418,9 +425,10 @@ public class IngresosController {
|
||||
}
|
||||
}
|
||||
|
||||
private class GuardarAction extends AbstractAction{
|
||||
private class GuardarAction extends AbstractAction {
|
||||
IngresosController controller;
|
||||
GuardarAction(IngresosController controller){
|
||||
|
||||
GuardarAction(IngresosController controller) {
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user