Comentarios
This commit is contained in:
		
							parent
							
								
									78837d32b3
								
							
						
					
					
						commit
						953ecd6ce0
					
				
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -10,7 +10,11 @@ import java.util.Properties; | |||||||
| 
 | 
 | ||||||
| public class Configuracion { | public class Configuracion { | ||||||
| 	private static String direccion=".config"; | 	private static String direccion=".config"; | ||||||
| 	 | 	/* | ||||||
|  | 	 * Guarda la configuracion del menu en un fichero oculto | ||||||
|  | 	 *  | ||||||
|  | 	 * @param menu	Menu del que se guardan los datos | ||||||
|  | 	 */ | ||||||
| 	public static void guardarConfiguracion(Menu menu) { | 	public static void guardarConfiguracion(Menu menu) { | ||||||
| 		Properties configuracion = new Properties(); | 		Properties configuracion = new Properties(); | ||||||
| 		configuracion.setProperty("ruta", menu.getRuta()); | 		configuracion.setProperty("ruta", menu.getRuta()); | ||||||
| @ -22,6 +26,11 @@ public class Configuracion { | |||||||
|         } |         } | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Carga la configuracion del menu | ||||||
|  | 	 *  | ||||||
|  | 	 * @param menu	menu en el que carga la configuracio | ||||||
|  | 	 */ | ||||||
| 	public static void cargarConfiguracion(Menu menu) throws IOException { | 	public static void cargarConfiguracion(Menu menu) throws IOException { | ||||||
| 		Properties configuracion = new Properties(); | 		Properties configuracion = new Properties(); | ||||||
| 		try { | 		try { | ||||||
|  | |||||||
| @ -9,6 +9,12 @@ public class Gestion implements Serializable{ | |||||||
| 	private boolean isPositivo; | 	private boolean isPositivo; | ||||||
| 	private String nombre; | 	private String nombre; | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Constructor principal de gestion | ||||||
|  | 	 *  | ||||||
|  | 	 * @param nombre		nombre de la gestion | ||||||
|  | 	 * @param isPositive	si es verdadero la gestion sera de beneficios, si es falsa sera de gastos | ||||||
|  | 	 */ | ||||||
| 	public Gestion(String nombre, boolean isPositivo) { | 	public Gestion(String nombre, boolean isPositivo) { | ||||||
| 		this.gestiones = new Vector<Transaccion>(); | 		this.gestiones = new Vector<Transaccion>(); | ||||||
| 		this.suma = 0; | 		this.suma = 0; | ||||||
| @ -17,10 +23,20 @@ public class Gestion implements Serializable{ | |||||||
| 		this.isPositivo = isPositivo; | 		this.isPositivo = isPositivo; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve el nombre de la gestion | ||||||
|  | 	 *  | ||||||
|  | 	 * @return	nombre de la gestion | ||||||
|  | 	 */ | ||||||
| 	public String getNombre() { | 	public String getNombre() { | ||||||
| 		return this.nombre; | 		return this.nombre; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Aniade una transaccion a la gestion | ||||||
|  | 	 *  | ||||||
|  | 	 * @param transaccion	transaccion que sera aniadida a la gestion | ||||||
|  | 	 */ | ||||||
| 	public void aniadirGasto(Transaccion transaccion) { | 	public void aniadirGasto(Transaccion transaccion) { | ||||||
| 		this.gestiones.add(transaccion); | 		this.gestiones.add(transaccion); | ||||||
| 		this.suma += transaccion.getDinero(); | 		this.suma += transaccion.getDinero(); | ||||||
| @ -31,18 +47,38 @@ public class Gestion implements Serializable{ | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve la suma (sin tener e cuenta si es gasto o ingreso) de la gestion | ||||||
|  | 	 *  | ||||||
|  | 	 * @return	suma de las transacciones de la gestion | ||||||
|  | 	 */ | ||||||
| 	public float getSuma() { | 	public float getSuma() { | ||||||
| 		return this.suma; | 		return this.suma; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve la suma de todos sus datos, esta vez teniendo en cuenta si debe sumar o restar | ||||||
|  | 	 *  | ||||||
|  | 	 * @return	suma correcta de los datos | ||||||
|  | 	 */ | ||||||
| 	public float getTotal() { | 	public float getTotal() { | ||||||
| 		return this.total; | 		return this.total; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve todas las transacciones que tiene | ||||||
|  | 	 *  | ||||||
|  | 	 * @return	Transacciones que contiene | ||||||
|  | 	 */ | ||||||
| 	public Vector<Transaccion> getElementos(){ | 	public Vector<Transaccion> getElementos(){ | ||||||
| 		return this.gestiones; | 		return this.gestiones; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Elimina una transaccion | ||||||
|  | 	 *  | ||||||
|  | 	 * @param transaccion	transaccion a eliminar | ||||||
|  | 	 */ | ||||||
| 	public void eliminarTransaccion(String transaccion) { | 	public void eliminarTransaccion(String transaccion) { | ||||||
| 		for(Transaccion elemento:this.gestiones) { | 		for(Transaccion elemento:this.gestiones) { | ||||||
| 			if(elemento.toString().equals(transaccion)) { | 			if(elemento.toString().equals(transaccion)) { | ||||||
| @ -52,10 +88,20 @@ public class Gestion implements Serializable{ | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve verdadero si es un ingerso y falso si es un gasto | ||||||
|  | 	 *  | ||||||
|  | 	 * @return verdadero si es ingersos y falso si sin gastos | ||||||
|  | 	 */ | ||||||
| 	public boolean esIngreso() { | 	public boolean esIngreso() { | ||||||
| 		return this.isPositivo; | 		return this.isPositivo; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Permite alterar la visibilidad de un elemento | ||||||
|  | 	 *  | ||||||
|  | 	 * @param elemento	indice del elemento a alterar | ||||||
|  | 	 */ | ||||||
| 	public void alterarVisibilidad(int elemento) { | 	public void alterarVisibilidad(int elemento) { | ||||||
| 		if(this.gestiones.get(elemento).alterarVisivilidad()) { | 		if(this.gestiones.get(elemento).alterarVisivilidad()) { | ||||||
| 			this.suma += this.gestiones.get(elemento).getDinero(); | 			this.suma += this.gestiones.get(elemento).getDinero(); | ||||||
|  | |||||||
| @ -44,6 +44,14 @@ public class Meses { | |||||||
| 		this.meses = new ArrayList<Mes>(); | 		this.meses = new ArrayList<Mes>(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Aniade una gestion vacia a la lista de meses | ||||||
|  | 	 *  | ||||||
|  | 	 * @param nombre		nombre de la gestion | ||||||
|  | 	 * @param anio			anio de la gestion | ||||||
|  | 	 * @param mes			mes de la transaccion | ||||||
|  | 	 * @param isPositivo	tipo de la gestion | ||||||
|  | 	 */ | ||||||
| 	public Gestion aniadirGestion(String nombre, int anio, Month mes, boolean isPositivo) { | 	public Gestion aniadirGestion(String nombre, int anio, Month mes, boolean isPositivo) { | ||||||
| 		Gestion ret; | 		Gestion ret; | ||||||
| 		try { | 		try { | ||||||
| @ -68,6 +76,13 @@ public class Meses { | |||||||
| 		return ret; | 		return ret; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Aniade una transaccion y la coloca en el mes y gestion que le corresponde, creandolos si no existen todavia | ||||||
|  | 	 *  | ||||||
|  | 	 * @param transaccion	transaccion a aniadir | ||||||
|  | 	 * @param nombree		nombre de la gestion a la que pertenece | ||||||
|  | 	 * @param isPositivo	tipo de gestion a la que pertenece | ||||||
|  | 	 */ | ||||||
| 	public void aniadirTransaccion(Transaccion transaccion, String nombre, boolean isPositivo) { | 	public void aniadirTransaccion(Transaccion transaccion, String nombre, boolean isPositivo) { | ||||||
| 		for(Mes mes:this.meses) { | 		for(Mes mes:this.meses) { | ||||||
| 			if(transaccion.getDia().getMonth().equals(mes.getMes()) && | 			if(transaccion.getDia().getMonth().equals(mes.getMes()) && | ||||||
| @ -81,6 +96,12 @@ public class Meses { | |||||||
| 		this.meses.get(this.meses.size()-1).aniadirTransaccion(transaccion, nombre, isPositivo); | 		this.meses.get(this.meses.size()-1).aniadirTransaccion(transaccion, nombre, isPositivo); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Define el mes en que nos encontramos a la hora de devolver objetos | ||||||
|  | 	 *  | ||||||
|  | 	 * @param anio	anio en el que queremos situarnos | ||||||
|  | 	 * @param mes	mes en el que queremos situarnos | ||||||
|  | 	 */ | ||||||
| 	public void elegirMes(int anio, Month mes) { | 	public void elegirMes(int anio, Month mes) { | ||||||
| 		for(int i = 0; i < this.meses.size(); i++) { | 		for(int i = 0; i < this.meses.size(); i++) { | ||||||
| 			if(this.meses.get(i).getAnio()==anio && this.meses.get(i).getMes().equals(mes)) { | 			if(this.meses.get(i).getAnio()==anio && this.meses.get(i).getMes().equals(mes)) { | ||||||
| @ -92,14 +113,29 @@ public class Meses { | |||||||
| 		this.mesActual = this.meses.size()-1; | 		this.mesActual = this.meses.size()-1; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve la lista de gestiones en la que nos encontramos | ||||||
|  | 	 *  | ||||||
|  | 	 * @return	Lista de gestiones en la que nos encontramos | ||||||
|  | 	 */ | ||||||
| 	public ArrayList<Gestion> getGestionesActuales(){ | 	public ArrayList<Gestion> getGestionesActuales(){ | ||||||
| 		return this.meses.get(this.mesActual).getGestiones(); | 		return this.meses.get(this.mesActual).getGestiones(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * devuelve el dinero que nos queda este mes (o el que debemos) | ||||||
|  | 	 *  | ||||||
|  | 	 * @return	dinero que nos queda o debemos este mes | ||||||
|  | 	 */ | ||||||
| 	public float getTotal() { | 	public float getTotal() { | ||||||
| 		return this.meses.get(this.mesActual).getTotal(); | 		return this.meses.get(this.mesActual).getTotal(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * guarda las gestiones que hemos introducido en un fichero para garantizar la persistencia de los datos | ||||||
|  | 	 *  | ||||||
|  | 	 * @param nombre	nombre del fichero donde se guardaran los datos | ||||||
|  | 	 */ | ||||||
| 	public void guardarMeses(String nombre) throws IOException { | 	public void guardarMeses(String nombre) throws IOException { | ||||||
| 		FileOutputStream fichero = new FileOutputStream(nombre); | 		FileOutputStream fichero = new FileOutputStream(nombre); | ||||||
| 		ObjectOutputStream escritor = new ObjectOutputStream(fichero); | 		ObjectOutputStream escritor = new ObjectOutputStream(fichero); | ||||||
| @ -115,6 +151,11 @@ public class Meses { | |||||||
| 		fichero.close(); | 		fichero.close(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Carga los datos que hemos guardado en el fichero de persistencia | ||||||
|  | 	 *  | ||||||
|  | 	 * @param nombre	nombre del fichero | ||||||
|  | 	 */ | ||||||
| 	public void cargarMeses(String nombre) throws IOException, ClassNotFoundException { | 	public void cargarMeses(String nombre) throws IOException, ClassNotFoundException { | ||||||
| 		FileInputStream fichero; | 		FileInputStream fichero; | ||||||
| 		try { | 		try { | ||||||
| @ -135,6 +176,11 @@ public class Meses { | |||||||
| 		}		 | 		}		 | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * devuelve todas las transacciones del mes actual | ||||||
|  | 	 *  | ||||||
|  | 	 * @return transacciones del mes actual | ||||||
|  | 	 */ | ||||||
| 	public Vector<String> salidaTodo(){ | 	public Vector<String> salidaTodo(){ | ||||||
| 		Vector<String> ret = new Vector<String>(); | 		Vector<String> ret = new Vector<String>(); | ||||||
| 		for(Mes mes:this.meses) { | 		for(Mes mes:this.meses) { | ||||||
| @ -149,6 +195,10 @@ public class Meses { | |||||||
| 		return ret; | 		return ret; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Exporta todos un esquema de toda la estructura de datos a un xml almacenado en la carpeta donde nos encontramos. | ||||||
|  | 	 * El fichero se llamara gestiones.xml | ||||||
|  | 	 */ | ||||||
| 	public void exportarXML() { | 	public void exportarXML() { | ||||||
| 		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | 		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | ||||||
| 		DocumentBuilder builder; | 		DocumentBuilder builder; | ||||||
| @ -245,10 +295,16 @@ public class Meses { | |||||||
| 		 | 		 | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Importa el xml cogiendolo de la ruta donde se guarda por defecto | ||||||
|  | 	 */ | ||||||
| 	public void importarXML() { | 	public void importarXML() { | ||||||
| 		this.importarXML("gestiones.xml"); | 		this.importarXML("gestiones.xml"); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Importa un xml de la ruta donde le indiquemos | ||||||
|  | 	 */ | ||||||
| 	public void importarXML(String nombreFichero) { | 	public void importarXML(String nombreFichero) { | ||||||
| 		File fichero = new File(nombreFichero); | 		File fichero = new File(nombreFichero); | ||||||
| 		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | 		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | ||||||
| @ -311,6 +367,13 @@ class Mes implements Serializable{ | |||||||
| 		this.nGestiones = this.gestiones.size();  | 		this.nGestiones = this.gestiones.size();  | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Aniade una transaccion al mes | ||||||
|  | 	 *  | ||||||
|  | 	 * @param transaccion	Transaccion a aniadir | ||||||
|  | 	 * @param nombre		nombre de la gestion a la que pertenece | ||||||
|  | 	 * @param isPositivo	Tipo de gestion a la que pertenece | ||||||
|  | 	 */ | ||||||
| 	void aniadirTransaccion(Transaccion transaccion, String nombre, boolean isPositivo) { | 	void aniadirTransaccion(Transaccion transaccion, String nombre, boolean isPositivo) { | ||||||
| 		for(Gestion gestion:this.gestiones) { | 		for(Gestion gestion:this.gestiones) { | ||||||
| 			if(gestion.getNombre().equals(nombre)) { | 			if(gestion.getNombre().equals(nombre)) { | ||||||
| @ -324,18 +387,37 @@ class Mes implements Serializable{ | |||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve el mes que gestione | ||||||
|  | 	 *  | ||||||
|  | 	 * @return mes que gestiona | ||||||
|  | 	 */ | ||||||
| 	Month getMes() { | 	Month getMes() { | ||||||
| 		return this.mes; | 		return this.mes; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve el anio que gestiona | ||||||
|  | 	 *  | ||||||
|  | 	 * @return anio que gestiona | ||||||
|  | 	 */ | ||||||
| 	int getAnio() { | 	int getAnio() { | ||||||
| 		return this.anio; | 		return this.anio; | ||||||
| 	} | 	} | ||||||
| 	 | 	/* | ||||||
|  | 	 * devuelve las gestionaes que contiene | ||||||
|  | 	 *  | ||||||
|  | 	 * @return gestiones que contiene | ||||||
|  | 	 */ | ||||||
| 	ArrayList<Gestion> getGestiones(){ | 	ArrayList<Gestion> getGestiones(){ | ||||||
| 		return this.gestiones; | 		return this.gestiones; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * devuelve el dinero que quedo ese mes (o que debe) | ||||||
|  | 	 *  | ||||||
|  | 	 * @return dinero que queda o debe ese mes | ||||||
|  | 	 */ | ||||||
| 	float getTotal() { | 	float getTotal() { | ||||||
| 		this.total = 0; | 		this.total = 0; | ||||||
| 		for(Gestion gestion:this.gestiones) { | 		for(Gestion gestion:this.gestiones) { | ||||||
|  | |||||||
| @ -18,36 +18,69 @@ public class Transaccion implements Serializable{ | |||||||
| 		this.dia = dia; | 		this.dia = dia; | ||||||
| 		this.gestion=gestion; | 		this.gestion=gestion; | ||||||
| 	} | 	} | ||||||
| 	 | 
 | ||||||
| 	public String toString() { | 	public String toString() { | ||||||
| 		return this.nombre + " " + this.dinero; | 		return this.nombre + " " + this.dinero; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * devuelve si la transaccion se contara en la gestion o no | ||||||
|  | 	 *  | ||||||
|  | 	 * @return visibilidad de la transaccion | ||||||
|  | 	 */ | ||||||
| 	public boolean getVisivilidad() { | 	public boolean getVisivilidad() { | ||||||
| 		return this.visible; | 		return this.visible; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * invierte la visibilidad de la transaccion y la devuelve | ||||||
|  | 	 *  | ||||||
|  | 	 * @return	nueva visibilidad  | ||||||
|  | 	 */ | ||||||
| 	public boolean alterarVisivilidad() { | 	public boolean alterarVisivilidad() { | ||||||
| 		this.visible =! this.visible; | 		this.visible =! this.visible; | ||||||
| 		return this.visible; | 		return this.visible; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve la cantidad de dinero que contiene | ||||||
|  | 	 *  | ||||||
|  | 	 * @return dinero de la transaccion | ||||||
|  | 	 */ | ||||||
| 	public float getDinero() { | 	public float getDinero() { | ||||||
| 		return this.dinero; | 		return this.dinero; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve la fecha de la transaccion | ||||||
|  | 	 *  | ||||||
|  | 	 * @return Fecha de la transaccion | ||||||
|  | 	 */ | ||||||
| 	public LocalDate getDia() { | 	public LocalDate getDia() { | ||||||
| 		return this.dia; | 		return this.dia; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Se aniade al gasto al que pertenece; | ||||||
|  | 	 */ | ||||||
| 	public void aniadirse() { | 	public void aniadirse() { | ||||||
| 		this.gestion.aniadirGasto(this); | 		this.gestion.aniadirGasto(this); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve la gestion a la que pertenece | ||||||
|  | 	 *  | ||||||
|  | 	 * @return	gestion a la que pertenece | ||||||
|  | 	 */ | ||||||
| 	public Gestion getGestion() { | 	public Gestion getGestion() { | ||||||
| 		return this.gestion; | 		return this.gestion; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * devuelve el nombre de la transaccion | ||||||
|  | 	 *  | ||||||
|  | 	 * @return	nombre de la transaccion | ||||||
|  | 	 */ | ||||||
| 	public String getNombre() { | 	public String getNombre() { | ||||||
| 		return this.nombre; | 		return this.nombre; | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ import javax.swing.event.ChangeListener; | |||||||
| 
 | 
 | ||||||
| import Logica.Gestion; | import Logica.Gestion; | ||||||
| 
 | 
 | ||||||
| public class ControladorAniadirVisualizar implements ActionListener,ChangeListener{ | public class ControladorAniadirVisualizar implements ActionListener{ | ||||||
| 
 | 
 | ||||||
| 	private VistaAniadirVisualizar vista; | 	private VistaAniadirVisualizar vista; | ||||||
| 	public ControladorAniadirVisualizar(VistaAniadirVisualizar vista) { | 	public ControladorAniadirVisualizar(VistaAniadirVisualizar vista) { | ||||||
| @ -58,6 +58,9 @@ public class ControladorAniadirVisualizar implements ActionListener,ChangeListen | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Aniade los listeners a la lista de objetos | ||||||
|  | 	 */ | ||||||
| 	private void aniadirListeners() { | 	private void aniadirListeners() { | ||||||
| 		vista.boton.addActionListener(this); | 		vista.boton.addActionListener(this); | ||||||
| 		vista.boton.setActionCommand("Aniadir"); | 		vista.boton.setActionCommand("Aniadir"); | ||||||
| @ -66,11 +69,5 @@ public class ControladorAniadirVisualizar implements ActionListener,ChangeListen | |||||||
| 			check.setActionCommand("pulsar"); | 			check.setActionCommand("pulsar"); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 |  | ||||||
| 	@Override |  | ||||||
| 	public void stateChanged(ChangeEvent e) { |  | ||||||
| 		// TODO Auto-generated method stub |  | ||||||
| 		 |  | ||||||
| 	} |  | ||||||
| 	 | 	 | ||||||
| } | } | ||||||
|  | |||||||
| @ -78,6 +78,9 @@ public class ControladorBarra implements ActionListener{ | |||||||
| 		 | 		 | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Aniade los listeners a la lista de objetos | ||||||
|  | 	 */ | ||||||
| 	private void aniadirListeners() { | 	private void aniadirListeners() { | ||||||
| 		this.barra.cambiarRuta.addActionListener(this); | 		this.barra.cambiarRuta.addActionListener(this); | ||||||
| 		this.barra.cambiarRuta.setActionCommand("Cambiar ruta"); | 		this.barra.cambiarRuta.setActionCommand("Cambiar ruta"); | ||||||
|  | |||||||
| @ -81,7 +81,9 @@ public class ControladorPanelLateral implements ActionListener, DateChangeListen | |||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 	} | 	} | ||||||
| 	 | 	/* | ||||||
|  | 	 * Aniade los listeners a la lista de objetos | ||||||
|  | 	 */ | ||||||
| 	private void aniadirElementos() { | 	private void aniadirElementos() { | ||||||
| 		this.vista.mostrarEstadisticas.addActionListener(this); | 		this.vista.mostrarEstadisticas.addActionListener(this); | ||||||
| 		this.vista.mostrarEstadisticas.setActionCommand("Mostrar estadisticas"); | 		this.vista.mostrarEstadisticas.setActionCommand("Mostrar estadisticas"); | ||||||
|  | |||||||
| @ -91,6 +91,9 @@ public class Menu extends JFrame{ | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Cierra la ventana | ||||||
|  | 	 */ | ||||||
| 	private void close(){ | 	private void close(){ | ||||||
|         if (JOptionPane.showConfirmDialog(rootPane, "¿Desea guardar el estado?", |         if (JOptionPane.showConfirmDialog(rootPane, "¿Desea guardar el estado?", | ||||||
|                 "Salir del sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { |                 "Salir del sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { | ||||||
| @ -105,6 +108,12 @@ public class Menu extends JFrame{ | |||||||
|             System.exit(0); |             System.exit(0); | ||||||
|     }    |     }    | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Inicia las listas de elementos graficos pertenecientes a el mes correspondiente | ||||||
|  | 	 *  | ||||||
|  | 	 * @param anio	anio del que cargaremos los datos | ||||||
|  | 	 * @param mes	mes del que cargaremos los datos | ||||||
|  | 	 */ | ||||||
| 	private void iniciarMes(int anio, Month mes) { | 	private void iniciarMes(int anio, Month mes) { | ||||||
| 		this.pestania.removeAll(); | 		this.pestania.removeAll(); | ||||||
| 		this.listenerPestania(); | 		this.listenerPestania(); | ||||||
| @ -119,6 +128,12 @@ public class Menu extends JFrame{ | |||||||
| 		this.cargarPestanias(); | 		this.cargarPestanias(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Carga los datos de las gestiones en caso de cambio de mes | ||||||
|  | 	 *  | ||||||
|  | 	 * @param nio	anio del que cargaremos los datos | ||||||
|  | 	 * @param mes	mes del que cargaremos los datos | ||||||
|  | 	 */ | ||||||
| 	void cargarGestiones(int anio, Month mes) { | 	void cargarGestiones(int anio, Month mes) { | ||||||
| 		if(this.meses==null) { | 		if(this.meses==null) { | ||||||
| 			this.meses=new Meses(); | 			this.meses=new Meses(); | ||||||
| @ -140,6 +155,9 @@ public class Menu extends JFrame{ | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Carga la parte grafica de ese mes | ||||||
|  | 	 */ | ||||||
| 	private void cargarMes() { | 	private void cargarMes() { | ||||||
| 		this.pestania.removeAll(); | 		this.pestania.removeAll(); | ||||||
| 		this.listenerPestania(); | 		this.listenerPestania(); | ||||||
| @ -163,6 +181,9 @@ public class Menu extends JFrame{ | |||||||
| 		this.cargarPestanias(); | 		this.cargarPestanias(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Carga todas las pestanias nuevas | ||||||
|  | 	 */ | ||||||
| 	void cargarPestanias() { | 	void cargarPestanias() { | ||||||
| 		this.pestania.removeAll(); | 		this.pestania.removeAll(); | ||||||
| 		this.listenerPestania(); | 		this.listenerPestania(); | ||||||
| @ -172,6 +193,12 @@ public class Menu extends JFrame{ | |||||||
| 		this.pestania.setSelectedIndex(0); | 		this.pestania.setSelectedIndex(0); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * aniade una nueva gestion | ||||||
|  | 	 *  | ||||||
|  | 	 * @param nombre		nombre de la gestion | ||||||
|  | 	 * @param sumaOResta	tipo de gestion | ||||||
|  | 	 */ | ||||||
| 	void aniadirGestion(String nombre, boolean sumaOResta) { | 	void aniadirGestion(String nombre, boolean sumaOResta) { | ||||||
| 		Gestion gestion=this.meses.aniadirGestion(nombre, VistaPanelLateral.getDate().getYear(), VistaPanelLateral.getDate().getMonth(), sumaOResta); | 		Gestion gestion=this.meses.aniadirGestion(nombre, VistaPanelLateral.getDate().getYear(), VistaPanelLateral.getDate().getMonth(), sumaOResta); | ||||||
| 		VistaAniadirVisualizar vista = new VistaAniadirVisualizar(this, gestion); | 		VistaAniadirVisualizar vista = new VistaAniadirVisualizar(this, gestion); | ||||||
| @ -180,6 +207,9 @@ public class Menu extends JFrame{ | |||||||
| 		this.pestania.addTab(vista.getName(),vista); | 		this.pestania.addTab(vista.getName(),vista); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Carga el listener de las pestanias en caso de que no lo tengan | ||||||
|  | 	 */ | ||||||
| 	void listenerPestania(){ | 	void listenerPestania(){ | ||||||
| 		if(this.pestania.getChangeListeners().length == 1) { | 		if(this.pestania.getChangeListeners().length == 1) { | ||||||
| 			this.pestania.addChangeListener((ChangeListener)->{ | 			this.pestania.addChangeListener((ChangeListener)->{ | ||||||
| @ -194,18 +224,38 @@ public class Menu extends JFrame{ | |||||||
| 		}	 | 		}	 | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Devuelve la ruta en la que se guardan los datos de persistencia | ||||||
|  | 	 *  | ||||||
|  | 	 * @return	ruta de los datos de persistencia | ||||||
|  | 	 */ | ||||||
| 	public String getRuta() { | 	public String getRuta() { | ||||||
| 		return this.rutaGuardado; | 		return this.rutaGuardado; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Estabece ula ruta de los datos de persistencia | ||||||
|  | 	 *  | ||||||
|  | 	 * @param ruta	ruta de los datos de persistencia | ||||||
|  | 	 */ | ||||||
| 	public void setRuta(String ruta) { | 	public void setRuta(String ruta) { | ||||||
| 		this.rutaGuardado=ruta; | 		this.rutaGuardado=ruta; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * devuelve el tema seleccionado | ||||||
|  | 	 *  | ||||||
|  | 	 * @return id del teme | ||||||
|  | 	 */ | ||||||
| 	public int getTema() { | 	public int getTema() { | ||||||
| 		return this.tema; | 		return this.tema; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Cambia el tema | ||||||
|  | 	 *  | ||||||
|  | 	 * @param	id del tema | ||||||
|  | 	 */ | ||||||
| 	public void setTheme(int tema) { | 	public void setTheme(int tema) { | ||||||
| 		switch(tema) { | 		switch(tema) { | ||||||
| 		case 0:{ | 		case 0:{ | ||||||
|  | |||||||
| @ -12,7 +12,11 @@ import Logica.Transaccion; | |||||||
| 
 | 
 | ||||||
| public class MostrarTodo extends JFrame{ | public class MostrarTodo extends JFrame{ | ||||||
| 	JList<String> elementos; | 	JList<String> elementos; | ||||||
| 	 | 	/* | ||||||
|  | 	 * Clase que muestra todos los datos que se almacenan | ||||||
|  | 	 *  | ||||||
|  | 	 * @param meses	datos a mostrar | ||||||
|  | 	 */ | ||||||
| 	public MostrarTodo(Meses meses) { | 	public MostrarTodo(Meses meses) { | ||||||
| 		super(); | 		super(); | ||||||
| 		this.elementos=new JList<String>(meses.salidaTodo()); | 		this.elementos=new JList<String>(meses.salidaTodo()); | ||||||
|  | |||||||
| @ -22,6 +22,13 @@ public class VistaAniadirVisualizar extends JPanel{ | |||||||
| 	Menu menu; | 	Menu menu; | ||||||
| 	private ControladorAniadirVisualizar controlador; | 	private ControladorAniadirVisualizar controlador; | ||||||
| 	private static VistaPanelLateral panelLateral; | 	private static VistaPanelLateral panelLateral; | ||||||
|  | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Constructor de la ventana que contendra las pestanias | ||||||
|  | 	 *  | ||||||
|  | 	 * @param menu		menu donde se guardaran | ||||||
|  | 	 * @param gestion	gestion de la pestania | ||||||
|  | 	 */ | ||||||
| 	public VistaAniadirVisualizar(Menu menu, Gestion gestion) { | 	public VistaAniadirVisualizar(Menu menu, Gestion gestion) { | ||||||
| 		this.gestiones = gestion; | 		this.gestiones = gestion; | ||||||
| 		this.transacciones = new LinkedList<JCheckBox>(); | 		this.transacciones = new LinkedList<JCheckBox>(); | ||||||
| @ -39,6 +46,11 @@ public class VistaAniadirVisualizar extends JPanel{ | |||||||
| 		this.add(panel); | 		this.add(panel); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Establece cual es el panel lateral | ||||||
|  | 	 *  | ||||||
|  | 	 * @param panel	panel lateral que gestionara este panel | ||||||
|  | 	 */ | ||||||
| 	public static void setPanelLateral(VistaPanelLateral panel) { | 	public static void setPanelLateral(VistaPanelLateral panel) { | ||||||
| 		VistaAniadirVisualizar.panelLateral = panel; | 		VistaAniadirVisualizar.panelLateral = panel; | ||||||
| 	} | 	} | ||||||
| @ -47,12 +59,22 @@ public class VistaAniadirVisualizar extends JPanel{ | |||||||
| 		return this.gestiones.getNombre(); | 		return this.gestiones.getNombre(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Inicia la gestion | ||||||
|  | 	 */ | ||||||
| 	void iniciarGestion() { | 	void iniciarGestion() { | ||||||
| 		for(Transaccion transaccion:this.gestiones.getElementos()) { | 		for(Transaccion transaccion:this.gestiones.getElementos()) { | ||||||
| 			 this.aniadirElemento(transaccion); | 			 this.aniadirElemento(transaccion); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Aniade una nueva transaccion introduciendo sus datos | ||||||
|  | 	 *  | ||||||
|  | 	 * @param nombre		nombre de la transaccion | ||||||
|  | 	 * @param dinero		dinero de la transaccion | ||||||
|  | 	 * @para controlador	controlador de la casilla que de aniadira | ||||||
|  | 	 */ | ||||||
| 	public void aniadirElemento(String nombre, float dinero, ControladorAniadirVisualizar controlador) { | 	public void aniadirElemento(String nombre, float dinero, ControladorAniadirVisualizar controlador) { | ||||||
| 		Transaccion transaccion = new Transaccion(nombre, dinero,panelLateral.getDate(),this.gestiones); | 		Transaccion transaccion = new Transaccion(nombre, dinero,panelLateral.getDate(),this.gestiones); | ||||||
| 		this.gestiones.aniadirGasto(transaccion); | 		this.gestiones.aniadirGasto(transaccion); | ||||||
| @ -68,6 +90,9 @@ public class VistaAniadirVisualizar extends JPanel{ | |||||||
| 		this.repaint(); | 		this.repaint(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Elimina las casillas deseleccionadas | ||||||
|  | 	 */ | ||||||
| 	void eliminarDeseleccionados(){ | 	void eliminarDeseleccionados(){ | ||||||
| 		for(JCheckBox check:this.transacciones) { | 		for(JCheckBox check:this.transacciones) { | ||||||
| 			if(!check.isSelected()) { | 			if(!check.isSelected()) { | ||||||
| @ -79,6 +104,9 @@ public class VistaAniadirVisualizar extends JPanel{ | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * aniade una nueva transaccion | ||||||
|  | 	 */ | ||||||
| 	private void aniadirElemento(Transaccion transaccion) { | 	private void aniadirElemento(Transaccion transaccion) { | ||||||
| 		JCheckBox check = new JCheckBox(transaccion.toString()); | 		JCheckBox check = new JCheckBox(transaccion.toString()); | ||||||
| 		check.setSelected(true); | 		check.setSelected(true); | ||||||
|  | |||||||
| @ -22,6 +22,11 @@ public class VistaPanelLateral extends JPanel{ | |||||||
| 	JButton aniadirGestion; | 	JButton aniadirGestion; | ||||||
| 	JButton eliminarTransaccion; | 	JButton eliminarTransaccion; | ||||||
| 	Meses meses; | 	Meses meses; | ||||||
|  | 	/* | ||||||
|  | 	 * Constructor del panel lateral que gestiona las pestanias | ||||||
|  | 	 *  | ||||||
|  | 	 * @param meses	datos a gestionar | ||||||
|  | 	 */ | ||||||
| 	VistaPanelLateral(Meses meses){ | 	VistaPanelLateral(Meses meses){ | ||||||
| 		this.setPreferredSize(new Dimension(200,200)); | 		this.setPreferredSize(new Dimension(200,200)); | ||||||
| 		this.meses=meses; | 		this.meses=meses; | ||||||
| @ -38,15 +43,28 @@ public class VistaPanelLateral extends JPanel{ | |||||||
| 		this.add(this.eliminarTransaccion); | 		this.add(this.eliminarTransaccion); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Actualiza los datos que se deben mostrar | ||||||
|  | 	 */ | ||||||
| 	void actualizarDatos(Gestion gestion) { | 	void actualizarDatos(Gestion gestion) { | ||||||
| 		this.total.setText("Total: " + String.valueOf(this.meses.getTotal()) + "€"); | 		this.total.setText("Total: " + String.valueOf(this.meses.getTotal()) + "€"); | ||||||
| 		this.gastoEnvio.setText("Suma: " + String.valueOf(gestion.getSuma()) + "€"); | 		this.gastoEnvio.setText("Suma: " + String.valueOf(gestion.getSuma()) + "€"); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * devuelve la fecha en la que se encuentra | ||||||
|  | 	 *  | ||||||
|  | 	 * @return	fecha en la que se encuentra | ||||||
|  | 	 */ | ||||||
| 	static LocalDate getDate() { | 	static LocalDate getDate() { | ||||||
| 		return elegirMes.getDate(); | 		return elegirMes.getDate(); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	/* | ||||||
|  | 	 * Inicializa el calendario | ||||||
|  | 	 *  | ||||||
|  | 	 * @return calendario que inicializa | ||||||
|  | 	 */ | ||||||
| 	static DatePicker inicializarCalendario() { | 	static DatePicker inicializarCalendario() { | ||||||
| 		DatePicker ret = new DatePicker(); | 		DatePicker ret = new DatePicker(); | ||||||
| 		ret.setDate(LocalDate.now()); | 		ret.setDate(LocalDate.now()); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user