Cree las versiones abstractas de direccion y telefono
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
package xyz.danielcortes.controllers.abstract_direccion;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.BaseController;
|
||||||
|
import xyz.danielcortes.framework.BasePanel;
|
||||||
|
import xyz.danielcortes.repository.DireccionRepository;
|
||||||
|
import xyz.danielcortes.validator.DireccionValidator;
|
||||||
|
import xyz.danielcortes.views.direccion.DireccionCreatePanel;
|
||||||
|
|
||||||
|
public abstract class AbstractDireccionCreateController extends BaseController {
|
||||||
|
|
||||||
|
private DireccionCreatePanel view;
|
||||||
|
private DireccionRepository repository;
|
||||||
|
private DireccionValidator validator;
|
||||||
|
|
||||||
|
public AbstractDireccionCreateController(DireccionCreatePanel view, LaunchController parentController) {
|
||||||
|
super(parentController);
|
||||||
|
this.view = view;
|
||||||
|
this.repository = new DireccionRepository();
|
||||||
|
this.validator = new DireccionValidator(this.repository);
|
||||||
|
this.setupListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LaunchController getParentController() {
|
||||||
|
return this.parentController;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
this.view.getCalleField().requestFocus();
|
||||||
|
this.view.getCalleField().setText("");
|
||||||
|
this.view.getNumeroField().setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasePanel getView() {
|
||||||
|
return this.view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupListeners() {
|
||||||
|
this.view.getGuardarButton().addActionListener(e -> this.save());
|
||||||
|
this.view.getNumeroField().addActionListener(e -> this.save());
|
||||||
|
this.view.getVolverButton().addActionListener(e -> this.volver());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void save();
|
||||||
|
|
||||||
|
protected abstract void volver();
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package xyz.danielcortes.controllers.abstract_direccion;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.BaseController;
|
||||||
|
import xyz.danielcortes.framework.BasePanel;
|
||||||
|
import xyz.danielcortes.framework.BaseTableModel;
|
||||||
|
import xyz.danielcortes.models.Direccion;
|
||||||
|
import xyz.danielcortes.repository.DireccionRepository;
|
||||||
|
import xyz.danielcortes.validator.DireccionValidator;
|
||||||
|
import xyz.danielcortes.views.direccion.DireccionSearchPanel;
|
||||||
|
|
||||||
|
public abstract class AbstractDireccionSearchController extends BaseController {
|
||||||
|
|
||||||
|
private DireccionSearchPanel view;
|
||||||
|
private DireccionRepository direccionRepository;
|
||||||
|
private DireccionValidator validator;
|
||||||
|
|
||||||
|
public AbstractDireccionSearchController(DireccionSearchPanel view, LaunchController parent) {
|
||||||
|
super(parent);
|
||||||
|
this.view = view;
|
||||||
|
this.direccionRepository = new DireccionRepository();
|
||||||
|
this.validator = new DireccionValidator(this.direccionRepository);
|
||||||
|
this.setupListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasePanel getView() {
|
||||||
|
return this.view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reload() {
|
||||||
|
this.loadDireccionesTable();
|
||||||
|
this.view.getDireccionesTable().clearSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupListeners() {
|
||||||
|
this.view.getCrearButton().addActionListener(e -> this.create());
|
||||||
|
this.view.getSearchField().addActionListener(e -> this.search());
|
||||||
|
this.view.getBuscarButton().addActionListener(e -> this.search());
|
||||||
|
this.view.getVerButton().addActionListener(e -> this.view());
|
||||||
|
this.view.getEditarButton().addActionListener(e -> this.edit());
|
||||||
|
this.view.getEliminarButton().addActionListener(e -> this.delete());
|
||||||
|
this.view.getVolverButton().addActionListener(e -> this.volver());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void create();
|
||||||
|
|
||||||
|
protected abstract void edit();
|
||||||
|
|
||||||
|
protected abstract void delete();
|
||||||
|
|
||||||
|
protected abstract void view();
|
||||||
|
|
||||||
|
protected abstract void search();
|
||||||
|
|
||||||
|
protected abstract void volver();
|
||||||
|
|
||||||
|
protected abstract void loadDireccionesTable();
|
||||||
|
|
||||||
|
private void loadDireccionesTable(List<Direccion> direccions) {
|
||||||
|
BaseTableModel<Direccion> model = this.view.getDireccionModel();
|
||||||
|
model.setRows(direccions);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Direccion getSelectedDireccion() {
|
||||||
|
int selectedRow = this.view.getDireccionesTable().getSelectedRow();
|
||||||
|
if (selectedRow == -1) {
|
||||||
|
JOptionPane.showMessageDialog(
|
||||||
|
null,
|
||||||
|
"No hay abstract_direccion seleccionada",
|
||||||
|
"Error",
|
||||||
|
JOptionPane.ERROR_MESSAGE
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.view.getDireccionModel().getRow(selectedRow);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package xyz.danielcortes.controllers.abstract_direccion;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.BaseController;
|
||||||
|
import xyz.danielcortes.framework.BasePanel;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
|
import xyz.danielcortes.models.Direccion;
|
||||||
|
import xyz.danielcortes.repository.DireccionRepository;
|
||||||
|
import xyz.danielcortes.validator.DireccionValidator;
|
||||||
|
import xyz.danielcortes.views.direccion.DireccionUpdatePanel;
|
||||||
|
|
||||||
|
public abstract class AbstractDireccionUpdateController extends BaseController {
|
||||||
|
|
||||||
|
private Direccion direccion;
|
||||||
|
private DireccionUpdatePanel view;
|
||||||
|
private DireccionRepository repository;
|
||||||
|
private DireccionValidator validator;
|
||||||
|
|
||||||
|
public AbstractDireccionUpdateController(DireccionUpdatePanel view, LaunchController parentController) {
|
||||||
|
super(parentController);
|
||||||
|
this.view = view;
|
||||||
|
this.repository = new DireccionRepository();
|
||||||
|
this.validator = new DireccionValidator(this.repository);
|
||||||
|
this.setupListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LaunchController getParentController() {
|
||||||
|
return this.parentController;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
this.view.getCalleField().requestFocus();
|
||||||
|
this.fillDireccion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasePanel getView() {
|
||||||
|
return this.view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDireccion(Direccion direccion) {
|
||||||
|
this.direccion = direccion;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fillDireccion() {
|
||||||
|
this.view.getCalleField().setText(this.direccion.getCalle());
|
||||||
|
this.view.getNumeroField().setText(this.direccion.getNumero());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupListeners() {
|
||||||
|
this.view.getNumeroField().addActionListener(e -> this.update());
|
||||||
|
this.view.getActualizarButton().addActionListener(e -> this.update());
|
||||||
|
this.view.getVolverButton().addActionListener(e -> this.volver());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update() {
|
||||||
|
String calle = this.view.getCalleField().getText();
|
||||||
|
String numero = this.view.getNumeroField().getText();
|
||||||
|
|
||||||
|
ValidationResult originalValidation = this.validator.validateOriginal(this.direccion);
|
||||||
|
if (originalValidation.hasError()) {
|
||||||
|
originalValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidationResult direccionValidation = this.validator.validateCalle(calle);
|
||||||
|
if (direccionValidation.hasError()) {
|
||||||
|
direccionValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidationResult numeroValidation = this.validator.validateNumero(numero);
|
||||||
|
if (numeroValidation.hasError()) {
|
||||||
|
numeroValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.direccion.setCalle(calle);
|
||||||
|
this.direccion.setNumero(numero);
|
||||||
|
this.repository.update(this.direccion);
|
||||||
|
|
||||||
|
this.volver();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void volver();
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package xyz.danielcortes.controllers.abstract_direccion;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.BaseController;
|
||||||
|
import xyz.danielcortes.framework.BasePanel;
|
||||||
|
import xyz.danielcortes.models.Direccion;
|
||||||
|
import xyz.danielcortes.views.direccion.DireccionViewPanel;
|
||||||
|
|
||||||
|
public abstract class AbstractDireccionViewController extends BaseController {
|
||||||
|
|
||||||
|
private Direccion direccion;
|
||||||
|
private DireccionViewPanel view;
|
||||||
|
|
||||||
|
public AbstractDireccionViewController(DireccionViewPanel view, LaunchController parentController) {
|
||||||
|
super(parentController);
|
||||||
|
this.view = view;
|
||||||
|
this.setupListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LaunchController getParentController() {
|
||||||
|
return this.parentController;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
this.fillDireccion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasePanel getView() {
|
||||||
|
return this.view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDireccion(Direccion direccion) {
|
||||||
|
this.direccion = direccion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillDireccion() {
|
||||||
|
this.view.getCalleField().setText(this.direccion.getCalle());
|
||||||
|
this.view.getNumeroField().setText(this.direccion.getNumero());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupListeners() {
|
||||||
|
this.view.getVolverButton().addActionListener(e -> this.volver());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void volver();
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package xyz.danielcortes.controllers.abstract_telefono;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.BaseController;
|
||||||
|
import xyz.danielcortes.framework.BasePanel;
|
||||||
|
import xyz.danielcortes.repository.TelefonoRepository;
|
||||||
|
import xyz.danielcortes.validator.TelefonoValidator;
|
||||||
|
import xyz.danielcortes.views.telefono.TelefonoCreatePanel;
|
||||||
|
|
||||||
|
public abstract class AbstractTelefonoCreateController extends BaseController {
|
||||||
|
|
||||||
|
private TelefonoCreatePanel view;
|
||||||
|
private TelefonoRepository repository;
|
||||||
|
private TelefonoValidator validator;
|
||||||
|
|
||||||
|
public AbstractTelefonoCreateController(TelefonoCreatePanel view, LaunchController parentController) {
|
||||||
|
super(parentController);
|
||||||
|
this.view = view;
|
||||||
|
this.repository = new TelefonoRepository();
|
||||||
|
this.validator = new TelefonoValidator(this.repository);
|
||||||
|
this.setupListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LaunchController getParentController() {
|
||||||
|
return this.parentController;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
this.view.getNumeroField().requestFocus();
|
||||||
|
this.view.getNumeroField().setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasePanel getView() {
|
||||||
|
return this.view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupListeners() {
|
||||||
|
this.view.getNumeroField().addActionListener(e -> this.save());
|
||||||
|
this.view.getGuardarButton().addActionListener(e -> this.save());
|
||||||
|
this.view.getVolverButton().addActionListener(e -> this.volver());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void save();
|
||||||
|
|
||||||
|
protected abstract void volver();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package xyz.danielcortes.controllers.abstract_telefono;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.BaseController;
|
||||||
|
import xyz.danielcortes.framework.BasePanel;
|
||||||
|
import xyz.danielcortes.framework.BaseTableModel;
|
||||||
|
import xyz.danielcortes.models.Telefono;
|
||||||
|
import xyz.danielcortes.repository.TelefonoRepository;
|
||||||
|
import xyz.danielcortes.validator.TelefonoValidator;
|
||||||
|
import xyz.danielcortes.views.telefono.TelefonoSearchPanel;
|
||||||
|
|
||||||
|
public abstract class AbstractTelefonoSearchController extends BaseController {
|
||||||
|
|
||||||
|
private TelefonoSearchPanel view;
|
||||||
|
private TelefonoRepository telefonoRepository;
|
||||||
|
private TelefonoValidator validator;
|
||||||
|
|
||||||
|
public AbstractTelefonoSearchController(TelefonoSearchPanel view, LaunchController parent) {
|
||||||
|
super(parent);
|
||||||
|
this.view = view;
|
||||||
|
this.telefonoRepository = new TelefonoRepository();
|
||||||
|
this.validator = new TelefonoValidator(this.telefonoRepository);
|
||||||
|
this.setupListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasePanel getView() {
|
||||||
|
return this.view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reload() {
|
||||||
|
this.loadTelefonosTable();
|
||||||
|
this.view.getTelefonosTable().clearSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupListeners() {
|
||||||
|
this.view.getCrearButton().addActionListener(e -> this.create());
|
||||||
|
this.view.getSearchField().addActionListener(e -> this.search());
|
||||||
|
this.view.getBuscarButton().addActionListener(e -> this.search());
|
||||||
|
this.view.getVerButton().addActionListener(e -> this.view());
|
||||||
|
this.view.getEditarButton().addActionListener(e -> this.edit());
|
||||||
|
this.view.getEliminarButton().addActionListener(e -> this.delete());
|
||||||
|
this.view.getVolverButton().addActionListener(e -> this.volver());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void create();
|
||||||
|
|
||||||
|
protected abstract void edit();
|
||||||
|
|
||||||
|
protected abstract void delete();
|
||||||
|
|
||||||
|
protected abstract void view();
|
||||||
|
|
||||||
|
protected abstract void search();
|
||||||
|
|
||||||
|
protected abstract void volver();
|
||||||
|
|
||||||
|
protected abstract void loadTelefonosTable();
|
||||||
|
|
||||||
|
private void loadTelefonosTable(List<Telefono> telefonos) {
|
||||||
|
BaseTableModel<Telefono> model = this.view.getTelefonoModel();
|
||||||
|
model.setRows(telefonos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Telefono getSelectedTelefono() {
|
||||||
|
int selectedRow = this.view.getTelefonosTable().getSelectedRow();
|
||||||
|
if (selectedRow == -1) {
|
||||||
|
JOptionPane.showMessageDialog(
|
||||||
|
null,
|
||||||
|
"No hay abstract_telefono seleccionado",
|
||||||
|
"Error",
|
||||||
|
JOptionPane.ERROR_MESSAGE
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.view.getTelefonoModel().getRow(selectedRow);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package xyz.danielcortes.controllers.abstract_telefono;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.BaseController;
|
||||||
|
import xyz.danielcortes.framework.BasePanel;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
|
import xyz.danielcortes.models.Telefono;
|
||||||
|
import xyz.danielcortes.repository.TelefonoRepository;
|
||||||
|
import xyz.danielcortes.validator.TelefonoValidator;
|
||||||
|
import xyz.danielcortes.views.telefono.TelefonoUpdatePanel;
|
||||||
|
|
||||||
|
public abstract class AbstractTelefonoUpdateController extends BaseController {
|
||||||
|
|
||||||
|
private Telefono telefono;
|
||||||
|
private TelefonoUpdatePanel view;
|
||||||
|
private TelefonoRepository repository;
|
||||||
|
private TelefonoValidator validator;
|
||||||
|
|
||||||
|
public AbstractTelefonoUpdateController(TelefonoUpdatePanel view, LaunchController parentController) {
|
||||||
|
super(parentController);
|
||||||
|
this.view = view;
|
||||||
|
this.repository = new TelefonoRepository();
|
||||||
|
this.validator = new TelefonoValidator(this.repository);
|
||||||
|
this.setupListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LaunchController getParentController() {
|
||||||
|
return this.parentController;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
this.view.getTelefonoField().requestFocus();
|
||||||
|
this.fillTelefono();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasePanel getView() {
|
||||||
|
return this.view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTelefono(Telefono telefono) {
|
||||||
|
this.telefono = telefono;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillTelefono() {
|
||||||
|
this.view.getTelefonoField().setText(this.telefono.getNumero());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupListeners() {
|
||||||
|
this.view.getTelefonoField().addActionListener(e -> this.update());
|
||||||
|
this.view.getActualizarButton().addActionListener(e -> this.update());
|
||||||
|
this.view.getVolverButton().addActionListener(e -> this.volver());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update() {
|
||||||
|
String telefono = this.view.getTelefonoField().getText();
|
||||||
|
|
||||||
|
ValidationResult originalValidation = this.validator.validateOriginal(this.telefono);
|
||||||
|
if (originalValidation.hasError()) {
|
||||||
|
originalValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ValidationResult telefonoValidation = this.validator.validateTelefono(telefono);
|
||||||
|
if (telefonoValidation.hasError()) {
|
||||||
|
telefonoValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.telefono.setNumero(telefono);
|
||||||
|
this.repository.update(this.telefono);
|
||||||
|
|
||||||
|
this.volver();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void volver();
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package xyz.danielcortes.controllers.abstract_telefono;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.BaseController;
|
||||||
|
import xyz.danielcortes.framework.BasePanel;
|
||||||
|
import xyz.danielcortes.models.Telefono;
|
||||||
|
import xyz.danielcortes.views.telefono.TelefonoViewPanel;
|
||||||
|
|
||||||
|
public abstract class AbstractTelefonoViewController extends BaseController {
|
||||||
|
|
||||||
|
private Telefono telefono;
|
||||||
|
private TelefonoViewPanel view;
|
||||||
|
|
||||||
|
public AbstractTelefonoViewController(TelefonoViewPanel view, LaunchController parentController) {
|
||||||
|
super(parentController);
|
||||||
|
this.view = view;
|
||||||
|
this.setupListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LaunchController getParentController() {
|
||||||
|
return this.parentController;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
this.fillTelefono();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasePanel getView() {
|
||||||
|
return this.view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTelefono(Telefono telefono) {
|
||||||
|
this.telefono = telefono;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillTelefono() {
|
||||||
|
this.view.getTelefonoField().setText(this.telefono.getNumero());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupListeners() {
|
||||||
|
this.view.getVolverButton().addActionListener(e -> this.volver());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void volver();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -37,13 +37,13 @@ public class ClienteViewController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// private void gotoDireccionView() {
|
// private void gotoDireccionView() {
|
||||||
// DireccionSearchController controller = (DireccionSearchController) this.getParentController().getCard(PanelName.DIRECCION_SEARCH);
|
// AbstractDireccionSearchController controller = (AbstractDireccionSearchController) this.getParentController().getCard(PanelName.DIRECCION_SEARCH);
|
||||||
// controller.setCliente(cliente);
|
// controller.setCliente(cliente);
|
||||||
// this.getParentController().showCard(PanelName.DIRECCION_SEARCH);
|
// this.getParentController().showCard(PanelName.DIRECCION_SEARCH);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// private void gotoTelefonoView() {
|
// private void gotoTelefonoView() {
|
||||||
// TelefonoSearchController controller = (TelefonoSearchController) this.getParentController().getCard(PanelName.TELEFONO_SEARCH);
|
// AbstractTelefonoSearchController controller = (AbstractTelefonoSearchController) this.getParentController().getCard(PanelName.TELEFONO_SEARCH);
|
||||||
// controller.setCliente(cliente);
|
// controller.setCliente(cliente);
|
||||||
// this.getParentController().showCard(PanelName.TELEFONO_SEARCH);
|
// this.getParentController().showCard(PanelName.TELEFONO_SEARCH);
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ public class DistribuidorViewController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// private void gotoDireccionView() {
|
// private void gotoDireccionView() {
|
||||||
// DireccionSearchController controller = (DireccionSearchController) this.getParentController().getCard(PanelName.DIRECCION_SEARCH);
|
// AbstractDireccionSearchController controller = (AbstractDireccionSearchController) this.getParentController().getCard(PanelName.DIRECCION_SEARCH);
|
||||||
// controller.setCliente(distribuidor);
|
// controller.setCliente(distribuidor);
|
||||||
// this.getParentController().showCard(PanelName.DIRECCION_SEARCH);
|
// this.getParentController().showCard(PanelName.DIRECCION_SEARCH);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// private void gotoTelefonoView() {
|
// private void gotoTelefonoView() {
|
||||||
// TelefonoSearchController controller = (TelefonoSearchController) this.getParentController().getCard(PanelName.TELEFONO_SEARCH);
|
// AbstractTelefonoSearchController controller = (AbstractTelefonoSearchController) this.getParentController().getCard(PanelName.TELEFONO_SEARCH);
|
||||||
// controller.setCliente(distribuidor);
|
// controller.setCliente(distribuidor);
|
||||||
// this.getParentController().showCard(PanelName.TELEFONO_SEARCH);
|
// this.getParentController().showCard(PanelName.TELEFONO_SEARCH);
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class DireccionSearchController extends BaseController {
|
|||||||
|
|
||||||
int option = JOptionPane.showConfirmDialog(
|
int option = JOptionPane.showConfirmDialog(
|
||||||
null,
|
null,
|
||||||
"¿Estas seguro de que deseas eliminar la direccion?",
|
"¿Estas seguro de que deseas eliminar la abstract_direccion?",
|
||||||
"Confirmacion",
|
"Confirmacion",
|
||||||
JOptionPane.YES_NO_OPTION,
|
JOptionPane.YES_NO_OPTION,
|
||||||
JOptionPane.QUESTION_MESSAGE
|
JOptionPane.QUESTION_MESSAGE
|
||||||
@@ -131,7 +131,7 @@ public class DireccionSearchController extends BaseController {
|
|||||||
if (selectedRow == -1) {
|
if (selectedRow == -1) {
|
||||||
JOptionPane.showMessageDialog(
|
JOptionPane.showMessageDialog(
|
||||||
null,
|
null,
|
||||||
"No hay direccion seleccionada",
|
"No hay abstract_direccion seleccionada",
|
||||||
"Error",
|
"Error",
|
||||||
JOptionPane.ERROR_MESSAGE
|
JOptionPane.ERROR_MESSAGE
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class TelefonoSearchController extends BaseController {
|
|||||||
|
|
||||||
int option = JOptionPane.showConfirmDialog(
|
int option = JOptionPane.showConfirmDialog(
|
||||||
null,
|
null,
|
||||||
"¿Estas seguro de que deseas eliminar el telefono?",
|
"¿Estas seguro de que deseas eliminar el abstract_telefono?",
|
||||||
"Confirmacion",
|
"Confirmacion",
|
||||||
JOptionPane.YES_NO_OPTION,
|
JOptionPane.YES_NO_OPTION,
|
||||||
JOptionPane.QUESTION_MESSAGE
|
JOptionPane.QUESTION_MESSAGE
|
||||||
@@ -131,7 +131,7 @@ public class TelefonoSearchController extends BaseController {
|
|||||||
if (selectedRow == -1) {
|
if (selectedRow == -1) {
|
||||||
JOptionPane.showMessageDialog(
|
JOptionPane.showMessageDialog(
|
||||||
null,
|
null,
|
||||||
"No hay telefono seleccionado",
|
"No hay abstract_telefono seleccionado",
|
||||||
"Error",
|
"Error",
|
||||||
JOptionPane.ERROR_MESSAGE
|
JOptionPane.ERROR_MESSAGE
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,14 +5,15 @@ import xyz.danielcortes.models.Direccion;
|
|||||||
import xyz.danielcortes.repository.DireccionRepository;
|
import xyz.danielcortes.repository.DireccionRepository;
|
||||||
|
|
||||||
public class DireccionValidator {
|
public class DireccionValidator {
|
||||||
|
|
||||||
private DireccionRepository direccionRepository;
|
private DireccionRepository direccionRepository;
|
||||||
|
|
||||||
public DireccionValidator(DireccionRepository direccionRepository) {
|
public DireccionValidator(DireccionRepository direccionRepository) {
|
||||||
this.direccionRepository = direccionRepository;
|
this.direccionRepository = direccionRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValidationResult validateCalle(String calle) {
|
public ValidationResult validateCalle(String calle) {
|
||||||
if(calle == null) {
|
if (calle == null) {
|
||||||
return new ValidationResult("La calle es nula");
|
return new ValidationResult("La calle es nula");
|
||||||
} else if (calle.isEmpty()) {
|
} else if (calle.isEmpty()) {
|
||||||
return new ValidationResult("La calle esta vacia");
|
return new ValidationResult("La calle esta vacia");
|
||||||
@@ -21,7 +22,7 @@ public class DireccionValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ValidationResult validateNumero(String numero) {
|
public ValidationResult validateNumero(String numero) {
|
||||||
if(numero == null) {
|
if (numero == null) {
|
||||||
return new ValidationResult("La calle es nula");
|
return new ValidationResult("La calle es nula");
|
||||||
} else if (numero.isEmpty()) {
|
} else if (numero.isEmpty()) {
|
||||||
return new ValidationResult("La calle esta vacia");
|
return new ValidationResult("La calle esta vacia");
|
||||||
@@ -30,8 +31,8 @@ public class DireccionValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ValidationResult validateOriginal(Direccion original) {
|
public ValidationResult validateOriginal(Direccion original) {
|
||||||
if(original == null) {
|
if (original == null) {
|
||||||
return new ValidationResult("El direccion seleccionada no existe");
|
return new ValidationResult("El abstract_direccion seleccionada no existe");
|
||||||
}
|
}
|
||||||
return ValidationResult.NON_ERROR;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,24 +5,25 @@ import xyz.danielcortes.models.Telefono;
|
|||||||
import xyz.danielcortes.repository.TelefonoRepository;
|
import xyz.danielcortes.repository.TelefonoRepository;
|
||||||
|
|
||||||
public class TelefonoValidator {
|
public class TelefonoValidator {
|
||||||
|
|
||||||
private TelefonoRepository telefonoRepository;
|
private TelefonoRepository telefonoRepository;
|
||||||
|
|
||||||
public TelefonoValidator(TelefonoRepository telefonoRepository) {
|
public TelefonoValidator(TelefonoRepository telefonoRepository) {
|
||||||
this.telefonoRepository = telefonoRepository;
|
this.telefonoRepository = telefonoRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValidationResult validateTelefono(String telefono) {
|
public ValidationResult validateTelefono(String telefono) {
|
||||||
if(telefono == null) {
|
if (telefono == null) {
|
||||||
return new ValidationResult("El telefono es nulo");
|
return new ValidationResult("El abstract_telefono es nulo");
|
||||||
} else if (telefono.isEmpty()) {
|
} else if (telefono.isEmpty()) {
|
||||||
return new ValidationResult("El telefono esta vacio");
|
return new ValidationResult("El abstract_telefono esta vacio");
|
||||||
}
|
}
|
||||||
return ValidationResult.NON_ERROR;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValidationResult validateOriginal(Telefono original) {
|
public ValidationResult validateOriginal(Telefono original) {
|
||||||
if(original == null) {
|
if (original == null) {
|
||||||
return new ValidationResult("El telefono seleccionado no existe");
|
return new ValidationResult("El abstract_telefono seleccionado no existe");
|
||||||
}
|
}
|
||||||
return ValidationResult.NON_ERROR;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user