Final, todo aprobado
This commit is contained in:
@@ -9,6 +9,7 @@ public class Gestion implements Serializable{
|
||||
private float total;
|
||||
private boolean isPositivo;
|
||||
private String nombre;
|
||||
private boolean isModified;
|
||||
|
||||
/**
|
||||
* Constructor principal de gestion
|
||||
@@ -22,6 +23,7 @@ public class Gestion implements Serializable{
|
||||
this.total = 0;
|
||||
this.nombre = nombre;
|
||||
this.isPositivo = isPositivo;
|
||||
this.isModified = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,6 +37,7 @@ public class Gestion implements Serializable{
|
||||
|
||||
public void setNombre(String nombre) {
|
||||
this.nombre = nombre;
|
||||
this.isModified = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,6 +96,12 @@ public class Gestion implements Serializable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite editar una transaccion por nombre para cambiarselo
|
||||
*
|
||||
* @param nombreViejo nombre de la transaccion a cambiar
|
||||
* @param nombreNuevo nuevo nombre
|
||||
*/
|
||||
public void editarTransaccion(String nombreViejo, String nombreNuevo) {
|
||||
for(Transaccion elemento:this.gestiones) {
|
||||
if(elemento.getNombre().equals(nombreViejo)) {
|
||||
@@ -102,6 +111,12 @@ public class Gestion implements Serializable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edita la fecha de una transaccion dada su fecha
|
||||
*
|
||||
* @param nombreViejo nombre de la trasnaccion a editar
|
||||
* @param fecha nueva fecha
|
||||
*/
|
||||
public void editarTransaccionFecha(String nombreViejo, LocalDate fecha) {
|
||||
for(Transaccion elemento:this.gestiones) {
|
||||
if(elemento.getNombre().equals(nombreViejo)) {
|
||||
@@ -111,6 +126,12 @@ public class Gestion implements Serializable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edita la transaccion con el nombre indicado alterando el dinero que cuesta
|
||||
*
|
||||
* @param nombreViejo nombre de la transaccion a editar
|
||||
* @param dinero nueva cantidad de dinero;
|
||||
*/
|
||||
public void editarTransaccionDiero(String nombreViejo, float dinero) {
|
||||
for(Transaccion elemento:this.gestiones) {
|
||||
if(elemento.getNombre().equals(nombreViejo)) {
|
||||
@@ -153,9 +174,7 @@ public class Gestion implements Serializable{
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String ret = "";
|
||||
ret += this.nombre + " " + this.suma + " " + this.isPositivo;
|
||||
return ret;
|
||||
return this.nombre + " " + this.suma + " Gastos:" + this.isPositivo + " Modificado:"+ this.isModified;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ public class Transaccion implements Serializable{
|
||||
private boolean visible;
|
||||
private LocalDate dia;
|
||||
private Gestion gestion;
|
||||
private boolean isModified;
|
||||
|
||||
/**
|
||||
* Constructor de transaccion
|
||||
@@ -26,12 +27,28 @@ public class Transaccion implements Serializable{
|
||||
this.visible = true;
|
||||
this.dia = dia;
|
||||
this.gestion=gestion;
|
||||
this.isModified = false;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
/**
|
||||
* Devuelve los datos importantes de la transaccion
|
||||
*
|
||||
* @return cadena los datos principales a mostrar
|
||||
*/
|
||||
public String toStringCorto() {
|
||||
return this.nombre + " " + this.dinero;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve todos los datos de la transaccion
|
||||
*
|
||||
* @return cadena con todos los datos
|
||||
*/
|
||||
public String toString() {
|
||||
return this.nombre + " " + this.dinero + " " + this.dia.toString() + " Modificado:" + this.isModified +
|
||||
" Visible:" + this.visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* devuelve si la transaccion se contara en la gestion o no
|
||||
*
|
||||
@@ -94,15 +111,33 @@ public class Transaccion implements Serializable{
|
||||
return this.nombre;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edita el nombre de la transaccion
|
||||
*
|
||||
* @param nombre nuevo nombre
|
||||
*/
|
||||
public void setName(String nombre) {
|
||||
this.nombre = nombre;
|
||||
this.isModified = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* edita la fecha de la transaccion
|
||||
*
|
||||
* @param fecha nueva fecha
|
||||
*/
|
||||
public void setFecha(LocalDate fecha) {
|
||||
this.dia = fecha;
|
||||
this.isModified = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edita el precio de la nueva transaccion
|
||||
*
|
||||
* @param nuevo nuevo precio
|
||||
*/
|
||||
public void setPrecio(float nuevo) {
|
||||
this.dinero = nuevo;
|
||||
this.isModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ public class Menu extends JFrame{
|
||||
this.pestanias.add(vista);
|
||||
this.controladores.add(new ControladorAniadirVisualizar(vista));
|
||||
this.pestania.addTab(vista.getName(),vista);
|
||||
this.meses.getGestionesActuales().add(gestion);
|
||||
//this.meses.getGestionesActuales().add(gestion);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,14 +47,6 @@ public class VistaAniadirVisualizar extends JPanel{
|
||||
this.add(panel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Establece cual es el panel lateral
|
||||
*
|
||||
* @param panel panel lateral que gestionara este panel
|
||||
*/
|
||||
/*public static void setPanelLateral(VistaPanelGestion panel) {
|
||||
VistaAniadirVisualizar.panelLateral = panel;
|
||||
}*/
|
||||
|
||||
public String getName() {
|
||||
return this.gestiones.getNombre();
|
||||
@@ -79,7 +71,7 @@ public class VistaAniadirVisualizar extends JPanel{
|
||||
public void aniadirElemento(String nombre, float dinero, ControladorAniadirVisualizar controlador) {
|
||||
Transaccion transaccion = new Transaccion(nombre, dinero,this.menu.elegirMes.getDate(),this.gestiones);
|
||||
this.gestiones.aniadirGasto(transaccion);
|
||||
JCheckBox check = new JCheckBox(transaccion.toString());
|
||||
JCheckBox check = new JCheckBox(transaccion.toStringCorto());
|
||||
check.setSelected(true);
|
||||
check.setSize(new Dimension(x,VistaAniadirVisualizar.altoCheck));
|
||||
check.addActionListener(controlador);
|
||||
@@ -107,16 +99,21 @@ public class VistaAniadirVisualizar extends JPanel{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edita el nombre de una transacccion dado el nombre de esta
|
||||
*
|
||||
* @param nombreViejo nombre de la transaccion
|
||||
* @param nombreNuevo nuevo nombre
|
||||
*/
|
||||
void editarTransaccion(String nombreViejo, String nombreNuevo){
|
||||
for(Transaccion transaccion:this.gestiones.getElementos()) {
|
||||
if(transaccion.getNombre().equals(nombreViejo)) {
|
||||
for(JCheckBox check:this.transacciones) {
|
||||
if(check.getText().equals(transaccion.toString())) {
|
||||
if(check.getText().equals(transaccion.toStringCorto())) {
|
||||
transaccion.setName(nombreNuevo);
|
||||
check.setText(transaccion.toString());
|
||||
check.setText(transaccion.toStringCorto());
|
||||
check.revalidate();
|
||||
check.repaint();
|
||||
//this.gestiones.editarTransaccion(nombreViejo, nombreNuevo);
|
||||
this.menu.panelGestion.actualizarDatos(this.gestiones);
|
||||
this.cuadro.revalidate();
|
||||
this.cuadro.repaint();
|
||||
@@ -126,13 +123,19 @@ public class VistaAniadirVisualizar extends JPanel{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edita el coste de una transaccion dado su nombre
|
||||
*
|
||||
* @param nombreViejo nombre de la transaccion
|
||||
* @param dinero costo de la transaccion
|
||||
*/
|
||||
void editarTransaccionDinero(String nombreViejo, float dinero){
|
||||
for(Transaccion transaccion:this.gestiones.getElementos()) {
|
||||
if(transaccion.getNombre().equals(nombreViejo)) {
|
||||
for(JCheckBox check:this.transacciones) {
|
||||
if(check.getText().equals(transaccion.toString())) {
|
||||
if(check.getText().equals(transaccion.toStringCorto())) {
|
||||
transaccion.setPrecio(dinero);
|
||||
check.setText(transaccion.toString());
|
||||
check.setText(transaccion.toStringCorto());
|
||||
check.revalidate();
|
||||
check.repaint();
|
||||
//this.gestiones.editarTransaccion(nombreViejo, nombreNuevo);
|
||||
@@ -145,13 +148,19 @@ public class VistaAniadirVisualizar extends JPanel{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edita la fecha de una transaccion dado su nombre
|
||||
*
|
||||
* @param nombreViejo nombre de la transaccion
|
||||
* @param fecha nueva fecha
|
||||
*/
|
||||
void editarTransaccionFecha(String nombreViejo, LocalDate fecha){
|
||||
for(Transaccion transaccion:this.gestiones.getElementos()) {
|
||||
if(transaccion.getNombre().equals(nombreViejo)) {
|
||||
for(JCheckBox check:this.transacciones) {
|
||||
if(check.getText().equals(transaccion.toString())) {
|
||||
if(check.getText().equals(transaccion.toStringCorto())) {
|
||||
transaccion.setFecha(fecha);
|
||||
check.setText(transaccion.toString());
|
||||
check.setText(transaccion.toStringCorto());
|
||||
check.revalidate();
|
||||
check.repaint();
|
||||
//this.gestiones.editarTransaccion(nombreViejo, nombreNuevo);
|
||||
@@ -168,7 +177,7 @@ public class VistaAniadirVisualizar extends JPanel{
|
||||
* aniade una nueva transaccion
|
||||
*/
|
||||
private void aniadirElemento(Transaccion transaccion, ControladorAniadirVisualizar controlador) {
|
||||
JCheckBox check = new JCheckBox(transaccion.toString());
|
||||
JCheckBox check = new JCheckBox(transaccion.toStringCorto());
|
||||
check.setSelected(true);
|
||||
check.setSize(new Dimension(x,VistaAniadirVisualizar.altoCheck));
|
||||
check.addActionListener(controlador);
|
||||
|
||||
Reference in New Issue
Block a user