generated from javiertuya/samples-test-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into HU-CompararAtletas
- Loading branch information
Showing
27 changed files
with
1,743 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
GrupoCovadonga;11;;;; | ||
[email protected];Alberto;2006;10;12;Masculino | ||
[email protected];Bego�a;2001;7;25;Femenino | ||
[email protected];Carlos;2004;4;27;Masculino | ||
[email protected];Daniel;2003;2;8;Masculino | ||
[email protected];Enrique;1998;5;18;Masculino | ||
[email protected];Fernando;1995;9;21;Masculino | ||
[email protected];Gonzalo;2005;11;24;Masculino | ||
[email protected];Hugo;2006;4;14;Masculino | ||
[email protected];Irlanda;2002;2;9;Femenino | ||
[email protected];Juana;2000;7;11;Femenino | ||
[email protected];Karoline;1999;8;3;Femenino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
GrupoMasaveu;3;;;; | ||
[email protected];Luis;2006;10;12;Masculino | ||
[email protected];Marta;2001;7;25;Femenino | ||
[email protected];Nuria;2004;4;27;Femenino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package giis.demo.tkrun; | ||
|
||
public class CategoriaDisplayDTO { | ||
private String id_c; | ||
private String nombre_cat; | ||
private int edadMin; | ||
private int edadMax; | ||
private String genero; | ||
public CategoriaDisplayDTO() {} | ||
public CategoriaDisplayDTO(String rownombre, int rowMin, int rowMax, String rowGenero) { | ||
this.nombre_cat=rownombre; | ||
this.edadMin=rowMin; | ||
this.edadMax=rowMax; | ||
this.genero = rowGenero; | ||
} | ||
public String getId() { return this.id_c; } | ||
public String getNombre() { return this.nombre_cat; } | ||
public int getEdadMin() { return this.edadMin; } | ||
public int getEdadMax() { return this.edadMax; } | ||
public String getGenero() { return this.genero; } | ||
public void setId(String value) { this.id_c=value; } | ||
public void setNombre(String value) { this.nombre_cat=value; } | ||
public void setEdadMin(int value) { this.edadMin=value; } | ||
public void setEdadMax(int value) { this.edadMax=value; } | ||
public void setGenero(String value) { this.genero=value; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package giis.demo.tkrun; | ||
|
||
/** | ||
* Datos del modelo de dominio de cada una de las carreras | ||
* IMPORTANTE: Cuando se usan los componentes de Apache Commons DbUtils debe | ||
* mantenerse de forma estricta el convenio de capitalización de Java: | ||
* - Capitalizar todas las palabras que forman un identificador | ||
* excepto la primera letra de nombres de métodos y variables. | ||
* - No utilizar subrayados | ||
* Seguir tambien estos mismos criterios en los nombres de tablas y campos de la BD | ||
*/ | ||
public class CategoriaEntity { | ||
private String id_comp; | ||
private String nombre_cat; | ||
private int edadMin; | ||
private int edadMax; | ||
private String genero; | ||
|
||
public String getId() { return this.id_comp; } | ||
public String getNombre() { return this.nombre_cat; } | ||
public int getEdadMin() { return this.edadMin; } | ||
public int getEdadMax() { return this.edadMax; } | ||
public String getGenero() { return this.genero; } | ||
public void setId(String value) { this.id_comp=value; } | ||
public void setNombre(String value) { this.nombre_cat=value; } | ||
public void setEdadMin(int value) { this.edadMin=value; } | ||
public void setEdadMax(int value) { this.edadMax=value; } | ||
public void setGenero(String value) { this.genero=value; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package giis.demo.tkrun; | ||
|
||
import java.awt.event.MouseAdapter; | ||
import java.awt.event.MouseEvent; | ||
import java.util.List; | ||
|
||
import javax.swing.JOptionPane; | ||
import javax.swing.table.TableModel; | ||
|
||
import giis.demo.util.SwingUtil; | ||
|
||
/** | ||
* Controlador para la funcionalidad de visualizacion de carreras para la inscripcion. | ||
* Es el punto de entrada de esta pantalla que se invocará: | ||
* -instanciando el controlador con la vista y el modelo | ||
* -ejecutando initController que instalara los manejadores de eventos | ||
*/ | ||
public class ClubController { | ||
private ClubModel model; | ||
private ClubView view; | ||
private String lastSelectedKey=""; //recuerda la ultima fila seleccionada para restaurarla cuando cambie la tabla de carreras | ||
|
||
public ClubController(ClubModel m, ClubView v) { | ||
this.model = m; | ||
this.view = v; | ||
//no hay inicializacion especifica del modelo, solo de la vista | ||
this.initView(); | ||
} | ||
/** | ||
* Inicializacion del controlador: anyade los manejadores de eventos a los objetos del UI. | ||
* Cada manejador de eventos se instancia de la misma forma, para que invoque un metodo privado | ||
* de este controlador, encerrado en un manejador de excepciones generico para mostrar ventanas | ||
* emergentes cuando ocurra algun problema o excepcion controlada. | ||
*/ | ||
public void initController() { | ||
//ActionListener define solo un metodo actionPerformed(), es un interfaz funcional que se puede invocar de la siguiente forma: | ||
//view.getBtnTablaCarreras().addActionListener(e -> getListaCarreras()); | ||
//ademas invoco el metodo que responde al listener en el exceptionWrapper para que se encargue de las excepciones | ||
view.getBtnApuntarClub().addActionListener(e -> SwingUtil.exceptionWrapper(() -> actualizar())); | ||
|
||
//En el caso del mouse listener (para detectar seleccion de una fila) no es un interfaz funcional puesto que tiene varios metodos | ||
//ver discusion: https://stackoverflow.com/questions/21833537/java-8-lambda-expressions-what-about-multiple-methods-in-nested-class | ||
// view.getTablaCarreras().addMouseListener(new MouseAdapter() { | ||
// @Override | ||
// public void mouseReleased(MouseEvent e) { | ||
// //no usa mouseClicked porque al establecer seleccion simple en la tabla de carreras | ||
// //el usuario podria arrastrar el raton por varias filas e interesa solo la ultima | ||
// SwingUtil.exceptionWrapper(() -> actualizar()); | ||
// } | ||
// }); | ||
} | ||
|
||
public void initView() { | ||
this.getListaCarreras(); | ||
|
||
//Abre la ventana (sustituye al main generado por WindowBuilder) | ||
view.getFrame().setVisible(true); | ||
} | ||
/** | ||
* La obtencion de la lista de carreras solo necesita obtener la lista de objetos del modelo | ||
* y usar metodo de SwingUtil para crear un tablemodel que se asigna finalmente a la tabla. | ||
*/ | ||
public void getListaCarreras() { | ||
|
||
List<CarreraDisplayDTO> carreras=model.getListaCarreras(); | ||
TableModel tmodel=SwingUtil.getTableModelFromPojos(carreras, new String[] {"id", "nombre_c", "descr","distancia", "nPlazas"}); | ||
view.getTablaCarreras().setModel(tmodel); | ||
SwingUtil.autoAdjustColumns(view.getTablaCarreras()); | ||
|
||
//Como se guarda la clave del ultimo elemento seleccionado, restaura la seleccion de los detalles | ||
this.restoreDetail(); | ||
|
||
//A modo de demo, se muestra tambien la misma informacion en forma de lista en un combobox | ||
// List<Object[]> carrerasList=model.getListaCarrerasArray(Util.isoStringToDate(view.getFechaHoy())); | ||
// ComboBoxModel<Object> lmodel=SwingUtil.getComboModelFromList(carrerasList); | ||
// view.getListaCarreras().setModel(lmodel); | ||
} | ||
/** | ||
* Restaura la informacion del detalle de la carrera para visualizar los valores correspondientes | ||
* a la ultima clave almacenada. | ||
*/ | ||
public void restoreDetail() { | ||
//Utiliza la ultimo valor de la clave (que se reiniciara si ya no existe en la tabla) | ||
this.lastSelectedKey=SwingUtil.selectAndGetSelectedKey(view.getTablaCarreras(), this.lastSelectedKey); | ||
//Si hay clave para seleccionar en la tabla muestra el detalle, si no, lo reinicia | ||
// if ("".equals(this.lastSelectedKey)) { | ||
// view.setDescuentoNoAplicable(); | ||
// view.getDetalleCarrera().setModel(new DefaultTableModel()); | ||
// } else { | ||
// this.updateDetail(); | ||
// } | ||
} | ||
/** | ||
* Al seleccionar un item de la tabla muestra el detalle con el valor del porcentaje de descuento | ||
* de la carrera seleccinada y los valores de esta entidad | ||
*/ | ||
public void actualizar() { | ||
//Obtiene la clave seleccinada y la guarda para recordar la seleccion en futuras interacciones | ||
this.lastSelectedKey=SwingUtil.getSelectedKey(view.getTablaCarreras()); | ||
if (lastSelectedKey == "") | ||
JOptionPane.showMessageDialog(null, "No hay ninguna competición seleccionada"); | ||
else { | ||
if (!model.compruebaClub(view.getTfClub().getText(),lastSelectedKey)) { | ||
JOptionPane.showMessageDialog(null, "Este club ya está apuntado a esta competición"); | ||
} else { | ||
model.insertarClub(lastSelectedKey, view.getTfClub().getText()); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package giis.demo.tkrun; | ||
|
||
public class ClubDisplayDTO { | ||
private String id_comp; | ||
private String id_club; | ||
private String nombre; | ||
private int numAtletas; | ||
public ClubDisplayDTO() {} | ||
public ClubDisplayDTO(String rowcomp, String rowclub, String rownom, int rownum) { | ||
this.id_comp = rowcomp; | ||
this.id_club = rowclub; | ||
this.nombre = rownom; | ||
this.numAtletas = rownum; | ||
} | ||
public String getIdComp() { return this.id_comp; } | ||
public String getIdClub() { return this.id_club; } | ||
public String getNombre() { return this.nombre; } | ||
public int getNumAtletas() { return this.numAtletas; } | ||
public void setIdComp(String value) { this.id_comp=value; } | ||
public void setIdClub(String value) { this.id_club=value; } | ||
public void setNombre(String value) { this.nombre=value; } | ||
public void setNumAtletas(int value) { this.numAtletas=value; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package giis.demo.tkrun; | ||
|
||
public class ClubEntity { | ||
private String id_comp; | ||
private String id_club; | ||
private String nombre; | ||
private int numAtletas; | ||
public ClubEntity(String rowcomp, String rowclub, String rownom, int rownum) { | ||
this.id_comp = rowcomp; | ||
this.id_club = rowclub; | ||
this.nombre = rownom; | ||
this.numAtletas = rownum; | ||
} | ||
public String getIdComp() { return this.id_comp; } | ||
public String getIdClub() { return this.id_club; } | ||
public String getNombre() { return this.nombre; } | ||
public int getNumAtletas() { return this.numAtletas; } | ||
public void setIdComp(String value) { this.id_comp=value; } | ||
public void setIdClub(String value) { this.id_club=value; } | ||
public void setNombre(String value) { this.nombre=value; } | ||
public void setNumAtletas(int value) { this.numAtletas=value; } | ||
} |
Oops, something went wrong.