Aniadida barra y funcionalidades extra
This commit is contained in:
		
							parent
							
								
									18238bd6b8
								
							
						
					
					
						commit
						cc5f59b5aa
					
				
										
											Binary file not shown.
										
									
								
							@ -73,5 +73,11 @@ public class Gestion implements Serializable{
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public String toString() {
 | 
				
			||||||
 | 
							String ret = "";
 | 
				
			||||||
 | 
							ret += this.nombre + " " + this.suma + " " + this.isPositivo;
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -10,9 +10,10 @@ import java.io.ObjectOutputStream;
 | 
				
			|||||||
import java.io.Serializable;
 | 
					import java.io.Serializable;
 | 
				
			||||||
import java.time.Month;
 | 
					import java.time.Month;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.Vector;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Meses {
 | 
					public class Meses {
 | 
				
			||||||
private ArrayList<Mes> meses;
 | 
						private ArrayList<Mes> meses;
 | 
				
			||||||
	private int mesActual=0;
 | 
						private int mesActual=0;
 | 
				
			||||||
	public Meses() {
 | 
						public Meses() {
 | 
				
			||||||
		this.meses = new ArrayList<Mes>();
 | 
							this.meses = new ArrayList<Mes>();
 | 
				
			||||||
@ -109,16 +110,33 @@ private ArrayList<Mes> meses;
 | 
				
			|||||||
		}		
 | 
							}		
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						public Vector<String> salidaTodo(){
 | 
				
			||||||
 | 
							Vector<String> ret = new Vector<String>();
 | 
				
			||||||
 | 
							for(Mes mes:this.meses) {
 | 
				
			||||||
 | 
								ret.add(mes.toString());
 | 
				
			||||||
 | 
								for(Gestion gestion:mes.getGestiones()) {
 | 
				
			||||||
 | 
									ret.add("  "+gestion.toString());
 | 
				
			||||||
 | 
									for(Transaccion transaccion:gestion.getElementos()) {
 | 
				
			||||||
 | 
										ret.add("    "+transaccion.toString());
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Mes implements Serializable{
 | 
					class Mes implements Serializable{
 | 
				
			||||||
	private int anio;
 | 
						private int anio;
 | 
				
			||||||
	private Month mes;
 | 
						private Month mes;
 | 
				
			||||||
 | 
						float total;
 | 
				
			||||||
 | 
						int nGestiones;
 | 
				
			||||||
	ArrayList<Gestion> gestiones;
 | 
						ArrayList<Gestion> gestiones;
 | 
				
			||||||
	Mes(ArrayList<Gestion> gestiones, int anio, Month mes){
 | 
						Mes(ArrayList<Gestion> gestiones, int anio, Month mes){
 | 
				
			||||||
		this.gestiones = gestiones;
 | 
							this.gestiones = gestiones;
 | 
				
			||||||
		this.anio=anio;
 | 
							this.anio = anio;
 | 
				
			||||||
		this.mes=mes;
 | 
							this.mes = mes;
 | 
				
			||||||
 | 
							this.nGestiones = this.gestiones.size(); 
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	void aniadirTransaccion(Transaccion transaccion, String nombre, boolean isPositivo) {
 | 
						void aniadirTransaccion(Transaccion transaccion, String nombre, boolean isPositivo) {
 | 
				
			||||||
@ -129,6 +147,7 @@ class Mes implements Serializable{
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		gestiones.add(new Gestion(nombre, isPositivo));
 | 
							gestiones.add(new Gestion(nombre, isPositivo));
 | 
				
			||||||
 | 
							this.nGestiones++;
 | 
				
			||||||
		gestiones.get(this.gestiones.size()-1).aniadirGasto(transaccion);
 | 
							gestiones.get(this.gestiones.size()-1).aniadirGasto(transaccion);
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -146,10 +165,16 @@ class Mes implements Serializable{
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	float getTotal() {
 | 
						float getTotal() {
 | 
				
			||||||
		float ret = 0;
 | 
							this.total = 0;
 | 
				
			||||||
		for(Gestion gestion:this.gestiones) {
 | 
							for(Gestion gestion:this.gestiones) {
 | 
				
			||||||
			ret += gestion.getTotal();
 | 
								this.total += gestion.getTotal();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							return this.total;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public String toString() {
 | 
				
			||||||
 | 
							String ret = "";
 | 
				
			||||||
 | 
							ret += this.mes.toString() + "/" + this.anio + ":" + this.getTotal();
 | 
				
			||||||
		return ret;
 | 
							return ret;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										39
									
								
								src/VistaControlador/BarraOpciones.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/VistaControlador/BarraOpciones.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					package VistaControlador;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.swing.JMenu;
 | 
				
			||||||
 | 
					import javax.swing.JMenuBar;
 | 
				
			||||||
 | 
					import javax.swing.JMenuItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class BarraOpciones extends JMenuBar{
 | 
				
			||||||
 | 
						JMenu menuAr;
 | 
				
			||||||
 | 
						JMenuItem cambiarRuta;
 | 
				
			||||||
 | 
						JMenuItem guardarIns;
 | 
				
			||||||
 | 
						JMenu interfaz;
 | 
				
			||||||
 | 
						JMenuItem modoOscuro;
 | 
				
			||||||
 | 
						JMenuItem modoRosa;
 | 
				
			||||||
 | 
						JMenuItem modoClaro;
 | 
				
			||||||
 | 
						JMenu mostrar;
 | 
				
			||||||
 | 
						JMenuItem mostrarTodo;
 | 
				
			||||||
 | 
						public BarraOpciones() {
 | 
				
			||||||
 | 
							this.menuAr = new JMenu("Archivo");
 | 
				
			||||||
 | 
							this.add(this.menuAr);
 | 
				
			||||||
 | 
							this.guardarIns = new JMenuItem("Guardar instantanea");
 | 
				
			||||||
 | 
							this.menuAr.add(this.guardarIns);
 | 
				
			||||||
 | 
							this.cambiarRuta = new JMenuItem("Cambiar ruta de guardado");
 | 
				
			||||||
 | 
							this.menuAr.add(this.cambiarRuta);
 | 
				
			||||||
 | 
							this.interfaz = new JMenu("Interfaz");
 | 
				
			||||||
 | 
							this.add(this.interfaz);
 | 
				
			||||||
 | 
							this.modoClaro = new JMenuItem("Modo claro");
 | 
				
			||||||
 | 
							this.interfaz.add(this.modoClaro);
 | 
				
			||||||
 | 
							this.modoOscuro = new JMenuItem("Modo Oscuro");
 | 
				
			||||||
 | 
							this.interfaz.add(this.modoOscuro);
 | 
				
			||||||
 | 
							this.modoRosa = new JMenuItem("Modo Rosa");
 | 
				
			||||||
 | 
							this.interfaz.add(this.modoRosa);
 | 
				
			||||||
 | 
							this.mostrar=new JMenu("Mostrar");
 | 
				
			||||||
 | 
							this.mostrarTodo = new JMenuItem("Mostrar todo");
 | 
				
			||||||
 | 
							this.mostrar.add(this.mostrarTodo);
 | 
				
			||||||
 | 
							this.add(this.mostrar);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										114
									
								
								src/VistaControlador/ControladorBarra.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								src/VistaControlador/ControladorBarra.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,114 @@
 | 
				
			|||||||
 | 
					package VistaControlador;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.awt.Color;
 | 
				
			||||||
 | 
					import java.awt.event.ActionEvent;
 | 
				
			||||||
 | 
					import java.awt.event.ActionListener;
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.swing.JOptionPane;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ControladorBarra implements ActionListener{
 | 
				
			||||||
 | 
						private BarraOpciones barra;
 | 
				
			||||||
 | 
						private Menu menu;
 | 
				
			||||||
 | 
						public ControladorBarra(BarraOpciones barra, Menu menu) {
 | 
				
			||||||
 | 
							this.barra = barra;
 | 
				
			||||||
 | 
							this.menu = menu;
 | 
				
			||||||
 | 
							this.aniadirListeners();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void actionPerformed(ActionEvent e) {
 | 
				
			||||||
 | 
							switch(e.getActionCommand()) {
 | 
				
			||||||
 | 
								case "Cambiar ruta":{
 | 
				
			||||||
 | 
									String ruta = JOptionPane.showInputDialog("Introduce la nuev a ruta");
 | 
				
			||||||
 | 
									if(ruta == null) return;
 | 
				
			||||||
 | 
									if(ruta.equals("")) {
 | 
				
			||||||
 | 
										JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE);
 | 
				
			||||||
 | 
										return;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									this.menu.nombreDatos = ruta;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								case "Guardar instantanea":{
 | 
				
			||||||
 | 
									String ruta = JOptionPane.showInputDialog("Introduce la ruta de la instantanea");
 | 
				
			||||||
 | 
									if(ruta == null) return;
 | 
				
			||||||
 | 
									if(ruta.equals("")) {
 | 
				
			||||||
 | 
										JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE);
 | 
				
			||||||
 | 
										return;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									try {
 | 
				
			||||||
 | 
										this.menu.meses.guardarMeses(ruta);
 | 
				
			||||||
 | 
									} catch (IOException e1) {
 | 
				
			||||||
 | 
										// TODO Auto-generated catch block
 | 
				
			||||||
 | 
										System.out.println("Fichero invalido");
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								case "Modo claro":{
 | 
				
			||||||
 | 
									this.menu.setBackground(Color.WHITE);
 | 
				
			||||||
 | 
									this.menu.setOpacity(1);
 | 
				
			||||||
 | 
									this.menu.repaint();
 | 
				
			||||||
 | 
									this.menu.revalidate();
 | 
				
			||||||
 | 
									this.menu.panelCentral.setOpaque(true);
 | 
				
			||||||
 | 
									this.menu.panelCentral.setBackground(Color.WHITE);
 | 
				
			||||||
 | 
									this.menu.panelCentral.repaint();
 | 
				
			||||||
 | 
									this.menu.panelCentral.revalidate();
 | 
				
			||||||
 | 
									this.menu.panel.setBackground(Color.WHITE);
 | 
				
			||||||
 | 
									this.menu.panel.repaint();
 | 
				
			||||||
 | 
									this.menu.panel.revalidate();
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								case "Modo rosa":{
 | 
				
			||||||
 | 
									this.menu.setBackground(Color.PINK);
 | 
				
			||||||
 | 
									this.menu.setOpacity(1);
 | 
				
			||||||
 | 
									this.menu.repaint();
 | 
				
			||||||
 | 
									this.menu.revalidate();
 | 
				
			||||||
 | 
									this.menu.panelCentral.setOpaque(true);
 | 
				
			||||||
 | 
									this.menu.panelCentral.setBackground(Color.PINK);
 | 
				
			||||||
 | 
									this.menu.panelCentral.repaint();
 | 
				
			||||||
 | 
									this.menu.panelCentral.revalidate();
 | 
				
			||||||
 | 
									this.menu.panel.setOpaque(true);
 | 
				
			||||||
 | 
									this.menu.panel.setBackground(Color.PINK);
 | 
				
			||||||
 | 
									this.menu.panel.repaint();
 | 
				
			||||||
 | 
									this.menu.panel.revalidate();
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								case "Modo oscuro":{
 | 
				
			||||||
 | 
									this.menu.setBackground(Color.BLACK);
 | 
				
			||||||
 | 
									this.menu.repaint();
 | 
				
			||||||
 | 
									this.menu.revalidate();
 | 
				
			||||||
 | 
									this.menu.panelCentral.setOpaque(true);
 | 
				
			||||||
 | 
									this.menu.panelCentral.setBackground(Color.BLACK);
 | 
				
			||||||
 | 
									this.menu.panelCentral.repaint();
 | 
				
			||||||
 | 
									this.menu.panelCentral.revalidate();
 | 
				
			||||||
 | 
									this.menu.panel.setOpaque(true);
 | 
				
			||||||
 | 
									this.menu.panel.setBackground(Color.BLACK);
 | 
				
			||||||
 | 
									this.menu.panel.repaint();
 | 
				
			||||||
 | 
									this.menu.panel.revalidate();
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								case "Mostrar todo":{
 | 
				
			||||||
 | 
									MostrarTodo mostrar = new MostrarTodo(this.menu.meses);
 | 
				
			||||||
 | 
									mostrar.setVisible(true);
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						private void aniadirListeners() {
 | 
				
			||||||
 | 
							this.barra.cambiarRuta.addActionListener(this);
 | 
				
			||||||
 | 
							this.barra.cambiarRuta.setActionCommand("Cambiar ruta");
 | 
				
			||||||
 | 
							this.barra.guardarIns.addActionListener(this);
 | 
				
			||||||
 | 
							this.barra.guardarIns.setActionCommand("Guardar instantanea");
 | 
				
			||||||
 | 
							this.barra.modoClaro.addActionListener(this);
 | 
				
			||||||
 | 
							this.barra.modoClaro.setActionCommand("Modo claro");
 | 
				
			||||||
 | 
							this.barra.modoRosa.addActionListener(this);
 | 
				
			||||||
 | 
							this.barra.modoRosa.setActionCommand("Modo rosa");
 | 
				
			||||||
 | 
							this.barra.modoOscuro.addActionListener(this);
 | 
				
			||||||
 | 
							this.barra.modoOscuro.setActionCommand("Modo oscuro");
 | 
				
			||||||
 | 
							this.barra.mostrarTodo.addActionListener(this);
 | 
				
			||||||
 | 
							this.barra.mostrarTodo.setActionCommand("Mostrar todo");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -10,6 +10,7 @@ import java.util.ArrayList;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import javax.swing.JButton;
 | 
					import javax.swing.JButton;
 | 
				
			||||||
import javax.swing.JFrame;
 | 
					import javax.swing.JFrame;
 | 
				
			||||||
 | 
					import javax.swing.JMenuItem;
 | 
				
			||||||
import javax.swing.JOptionPane;
 | 
					import javax.swing.JOptionPane;
 | 
				
			||||||
import javax.swing.JPanel;
 | 
					import javax.swing.JPanel;
 | 
				
			||||||
import javax.swing.JTabbedPane;
 | 
					import javax.swing.JTabbedPane;
 | 
				
			||||||
@ -31,9 +32,12 @@ public class Menu extends JFrame{
 | 
				
			|||||||
	Meses meses;
 | 
						Meses meses;
 | 
				
			||||||
	ArrayList<VistaAniadirVisualizar> pestanias;
 | 
						ArrayList<VistaAniadirVisualizar> pestanias;
 | 
				
			||||||
	ArrayList<ControladorAniadirVisualizar> controladores;
 | 
						ArrayList<ControladorAniadirVisualizar> controladores;
 | 
				
			||||||
 | 
						BarraOpciones barra;
 | 
				
			||||||
	protected Gestion datosGastos;
 | 
						protected Gestion datosGastos;
 | 
				
			||||||
	protected Gestion datosIngresos;
 | 
						protected Gestion datosIngresos;
 | 
				
			||||||
	public Menu() {
 | 
						public Menu() {
 | 
				
			||||||
 | 
							this.barra = new BarraOpciones();
 | 
				
			||||||
 | 
							ControladorBarra controladorBarra = new ControladorBarra(barra, this);
 | 
				
			||||||
		this.nombreDatos = ".mes";
 | 
							this.nombreDatos = ".mes";
 | 
				
			||||||
		setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
 | 
							setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
 | 
				
			||||||
		 
 | 
							 
 | 
				
			||||||
@ -50,10 +54,14 @@ public class Menu extends JFrame{
 | 
				
			|||||||
		this.setLayout(new GridBagLayout());
 | 
							this.setLayout(new GridBagLayout());
 | 
				
			||||||
		this.panel = new VistaPanelLateral(constrain, this.meses);
 | 
							this.panel = new VistaPanelLateral(constrain, this.meses);
 | 
				
			||||||
		this.panelCentral = new JPanel();
 | 
							this.panelCentral = new JPanel();
 | 
				
			||||||
 | 
							constrain.fill = GridBagConstraints.HORIZONTAL;
 | 
				
			||||||
		constrain.fill = GridBagConstraints.VERTICAL;
 | 
					 | 
				
			||||||
		constrain.gridx = 0;
 | 
							constrain.gridx = 0;
 | 
				
			||||||
		constrain.gridy = 0;
 | 
							constrain.gridy = 0;
 | 
				
			||||||
 | 
							constrain.weightx = 10;
 | 
				
			||||||
 | 
							this.add(this.barra);
 | 
				
			||||||
 | 
							constrain.fill = GridBagConstraints.VERTICAL;
 | 
				
			||||||
 | 
							constrain.gridx = 1;
 | 
				
			||||||
 | 
							constrain.gridy = 1;
 | 
				
			||||||
		constrain.weightx = 2;
 | 
							constrain.weightx = 2;
 | 
				
			||||||
		this.panelCentral.add(pestania,constrain);
 | 
							this.panelCentral.add(pestania,constrain);
 | 
				
			||||||
		getContentPane().add(pestania);
 | 
							getContentPane().add(pestania);
 | 
				
			||||||
@ -63,6 +71,10 @@ public class Menu extends JFrame{
 | 
				
			|||||||
		setLocationRelativeTo(null);
 | 
							setLocationRelativeTo(null);
 | 
				
			||||||
		ControladorPanelLateral controlador3 = new ControladorPanelLateral(this.panel, this);
 | 
							ControladorPanelLateral controlador3 = new ControladorPanelLateral(this.panel, this);
 | 
				
			||||||
		this.listenerPestania();
 | 
							this.listenerPestania();
 | 
				
			||||||
 | 
							constrain.fill = GridBagConstraints.VERTICAL;
 | 
				
			||||||
 | 
							constrain.gridx = 2;
 | 
				
			||||||
 | 
							constrain.gridy = 1;
 | 
				
			||||||
 | 
							constrain.weightx = 2;
 | 
				
			||||||
		this.add(this.panel);
 | 
							this.add(this.panel);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										21
									
								
								src/VistaControlador/MostrarTodo.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/VistaControlador/MostrarTodo.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package VistaControlador;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Vector;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.swing.JFrame;
 | 
				
			||||||
 | 
					import javax.swing.JLabel;
 | 
				
			||||||
 | 
					import javax.swing.JList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import Logica.Gestion;
 | 
				
			||||||
 | 
					import Logica.Meses;
 | 
				
			||||||
 | 
					import Logica.Transaccion;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MostrarTodo extends JFrame{
 | 
				
			||||||
 | 
						JList<String> elementos;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public MostrarTodo(Meses meses) {
 | 
				
			||||||
 | 
							super();
 | 
				
			||||||
 | 
							this.elementos=new JList<String>(meses.salidaTodo());
 | 
				
			||||||
 | 
							this.add(elementos);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user