Aniadido soporte cambio de nombre
This commit is contained in:
		
							parent
							
								
									a379ac104e
								
							
						
					
					
						commit
						c759f93fea
					
				
							
								
								
									
										6
									
								
								bin/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								bin/.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,3 +1,5 @@ | |||||||
| /Logica/ | /Fichero/ | ||||||
| /VistaControlador/ |  | ||||||
| /Ficheros/ | /Ficheros/ | ||||||
|  | /Logica/ | ||||||
|  | /Main.class | ||||||
|  | /VistaControlador/ | ||||||
|  | |||||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -32,6 +32,10 @@ public class Gestion implements Serializable{ | |||||||
| 		return this.nombre; | 		return this.nombre; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	public void setNombre(String nombre) { | ||||||
|  | 		this.nombre = nombre; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	/** | 	/** | ||||||
| 	 * Aniade una transaccion a la gestion | 	 * Aniade una transaccion a la gestion | ||||||
| 	 *  | 	 *  | ||||||
| @ -88,6 +92,15 @@ public class Gestion implements Serializable{ | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	public void editarTransaccion(String nombreViejo, String nombreNuevo) { | ||||||
|  | 		for(Transaccion elemento:this.gestiones) { | ||||||
|  | 			if(elemento.getNombre().equals(nombreViejo)) { | ||||||
|  | 				elemento.setName(nombreNuevo); | ||||||
|  | 				return; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	/** | 	/** | ||||||
| 	 * Devuelve verdadero si es un ingerso y falso si es un gasto | 	 * Devuelve verdadero si es un ingerso y falso si es un gasto | ||||||
| 	 *  | 	 *  | ||||||
|  | |||||||
| @ -92,4 +92,8 @@ public class Transaccion implements Serializable{ | |||||||
| 	public String getNombre() { | 	public String getNombre() { | ||||||
| 		return this.nombre; | 		return this.nombre; | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
|  | 	public void setName(String nombre) { | ||||||
|  | 		this.nombre = nombre; | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -18,6 +18,9 @@ public class BarraOpciones extends JMenuBar{ | |||||||
| 	JMenuItem modoClaro; | 	JMenuItem modoClaro; | ||||||
| 	JMenu mostrar; | 	JMenu mostrar; | ||||||
| 	JMenuItem mostrarTodo; | 	JMenuItem mostrarTodo; | ||||||
|  | 	JMenu vistas; | ||||||
|  | 	JMenuItem gestion; | ||||||
|  | 	JMenuItem modificacion; | ||||||
| 	 | 	 | ||||||
| 	/** | 	/** | ||||||
| 	 * Inicializa labarra con los datos por defecto | 	 * Inicializa labarra con los datos por defecto | ||||||
| @ -45,5 +48,11 @@ public class BarraOpciones extends JMenuBar{ | |||||||
| 		this.mostrarTodo = new JMenuItem("Mostrar todo"); | 		this.mostrarTodo = new JMenuItem("Mostrar todo"); | ||||||
| 		this.mostrar.add(this.mostrarTodo); | 		this.mostrar.add(this.mostrarTodo); | ||||||
| 		this.add(this.mostrar); | 		this.add(this.mostrar); | ||||||
|  | 		this.vistas = new JMenu("Vista"); | ||||||
|  | 		this.add(this.vistas); | ||||||
|  | 		this.gestion = new JMenuItem("Gestion"); | ||||||
|  | 		this.vistas.add(this.gestion); | ||||||
|  | 		this.modificacion = new JMenuItem("Modificacion"); | ||||||
|  | 		this.vistas.add(this.modificacion); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -35,9 +35,9 @@ public class ControladorAniadirVisualizar implements ActionListener{ | |||||||
| 				 | 				 | ||||||
| 				try { | 				try { | ||||||
| 					this.vista.aniadirElemento(nombre, Float.parseFloat(dinero),this); | 					this.vista.aniadirElemento(nombre, Float.parseFloat(dinero),this); | ||||||
| 					this.vista.menu.panel.actualizarDatos(this.vista.gestiones); | 					this.vista.menu.panelGestion.actualizarDatos(this.vista.gestiones); | ||||||
| 					this.vista.menu.panel.revalidate(); | 					this.vista.menu.panelGestion.revalidate(); | ||||||
| 					this.vista.menu.panel.repaint(); | 					this.vista.menu.panelGestion.repaint(); | ||||||
| 				}catch (NumberFormatException ex) { | 				}catch (NumberFormatException ex) { | ||||||
| 					JOptionPane.showMessageDialog(null, "Debe introducir un numero", "error", JOptionPane.WARNING_MESSAGE); | 					JOptionPane.showMessageDialog(null, "Debe introducir un numero", "error", JOptionPane.WARNING_MESSAGE); | ||||||
| 				} | 				} | ||||||
| @ -48,9 +48,9 @@ public class ControladorAniadirVisualizar implements ActionListener{ | |||||||
| 				for(int i = 0; i < vista.gestiones.getElementos().size();i++) { | 				for(int i = 0; i < vista.gestiones.getElementos().size();i++) { | ||||||
| 					if(vista.gestiones.getElementos().get(i).toString().equals(pulsado.getText())) { | 					if(vista.gestiones.getElementos().get(i).toString().equals(pulsado.getText())) { | ||||||
| 						vista.gestiones.alterarVisibilidad(i); | 						vista.gestiones.alterarVisibilidad(i); | ||||||
| 						this.vista.menu.panel.actualizarDatos(this.vista.gestiones); | 						this.vista.menu.panelGestion.actualizarDatos(this.vista.gestiones); | ||||||
| 						this.vista.menu.panel.revalidate(); | 						this.vista.menu.panelGestion.revalidate(); | ||||||
| 						this.vista.menu.panel.repaint(); | 						this.vista.menu.panelGestion.repaint(); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  | |||||||
| @ -81,6 +81,14 @@ public class ControladorBarra implements ActionListener{ | |||||||
| 				this.menu.cargarPestanias(); | 				this.menu.cargarPestanias(); | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
|  | 			case "Cambiar Gestion":{ | ||||||
|  | 				this.menu.cambiarVista(this.menu.VISTA_GESTION); | ||||||
|  | 				break; | ||||||
|  | 			} | ||||||
|  | 			case "Cambiar Modificar":{ | ||||||
|  | 				this.menu.cambiarVista(this.menu.VISTA_MODIFICAR); | ||||||
|  | 			} | ||||||
|  | 			 | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 	} | 	} | ||||||
| @ -105,6 +113,10 @@ public class ControladorBarra implements ActionListener{ | |||||||
| 		this.barra.modoOscuro.setActionCommand("Modo oscuro"); | 		this.barra.modoOscuro.setActionCommand("Modo oscuro"); | ||||||
| 		this.barra.mostrarTodo.addActionListener(this); | 		this.barra.mostrarTodo.addActionListener(this); | ||||||
| 		this.barra.mostrarTodo.setActionCommand("Mostrar todo"); | 		this.barra.mostrarTodo.setActionCommand("Mostrar todo"); | ||||||
|  | 		this.barra.gestion.addActionListener(this); | ||||||
|  | 		this.barra.gestion.setActionCommand("Cambiar Gestion"); | ||||||
|  | 		this.barra.modificacion.addActionListener(this); | ||||||
|  | 		this.barra.modificacion.setActionCommand("Cambiar Modificar"); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -23,10 +23,8 @@ import com.github.lgooddatepicker.zinternaltools.DemoPanel; | |||||||
| 
 | 
 | ||||||
| import Logica.Gestion; | import Logica.Gestion; | ||||||
| import Logica.Transaccion; | import Logica.Transaccion; | ||||||
| public class ControladorPanelLateral implements ActionListener, DateChangeListener{ | public class ControladorPanelGestion implements ActionListener{ | ||||||
| 	private VistaPanelLateral vista; | 	private VistaPanelGestion vista; | ||||||
| 	private java.time.Month mes; |  | ||||||
| 	private int anio; |  | ||||||
| 	private Menu menu; | 	private Menu menu; | ||||||
| 	 | 	 | ||||||
| 	/** | 	/** | ||||||
| @ -35,7 +33,7 @@ public class ControladorPanelLateral implements ActionListener, DateChangeListen | |||||||
| 	 * @param vista	Vista que usa el controlador | 	 * @param vista	Vista que usa el controlador | ||||||
| 	 * @param menu	Menu que contiene la vista que usa este controlador | 	 * @param menu	Menu que contiene la vista que usa este controlador | ||||||
| 	 */ | 	 */ | ||||||
| 	public ControladorPanelLateral(VistaPanelLateral vista, Menu menu) { | 	public ControladorPanelGestion(VistaPanelGestion vista, Menu menu) { | ||||||
| 		this.vista = vista; | 		this.vista = vista; | ||||||
| 		this.menu = menu; | 		this.menu = menu; | ||||||
| 		this.aniadirElementos(); | 		this.aniadirElementos(); | ||||||
| @ -102,23 +100,8 @@ public class ControladorPanelLateral implements ActionListener, DateChangeListen | |||||||
| 		this.vista.mostrarEstadisticas.setActionCommand("Mostrar estadisticas"); | 		this.vista.mostrarEstadisticas.setActionCommand("Mostrar estadisticas"); | ||||||
| 		this.vista.aniadirGestion.addActionListener(this); | 		this.vista.aniadirGestion.addActionListener(this); | ||||||
| 		this.vista.aniadirGestion.setActionCommand("Aniadir una nueva gestion"); | 		this.vista.aniadirGestion.setActionCommand("Aniadir una nueva gestion"); | ||||||
| 		if(VistaPanelLateral.elegirMes.getDateChangeListeners().size() == 0) { |  | ||||||
| 			VistaPanelLateral.elegirMes.addDateChangeListener(this); |  | ||||||
| 			this.mes=VistaPanelLateral.elegirMes.getDate().getMonth(); |  | ||||||
| 			this.anio=VistaPanelLateral.elegirMes.getDate().getYear(); |  | ||||||
| 		} |  | ||||||
| 		this.vista.eliminarTransaccion.addActionListener(this); | 		this.vista.eliminarTransaccion.addActionListener(this); | ||||||
| 		this.vista.eliminarTransaccion.setActionCommand("Eliminar Transacciones"); | 		this.vista.eliminarTransaccion.setActionCommand("Eliminar Transacciones"); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public void dateChanged(DateChangeEvent arg0) { |  | ||||||
| 		if(this.mes!=VistaPanelLateral.elegirMes.getDate().getMonth() ||  |  | ||||||
| 				this.anio!=VistaPanelLateral.elegirMes.getDate().getYear()) { |  | ||||||
| 			this.menu.cargarGestiones(VistaPanelLateral.elegirMes.getDate().getYear(), VistaPanelLateral.elegirMes.getDate().getMonth()); |  | ||||||
| 			this.mes=VistaPanelLateral.elegirMes.getDate().getMonth(); |  | ||||||
| 			this.anio=VistaPanelLateral.elegirMes.getDate().getYear(); |  | ||||||
| 		} |  | ||||||
| 		 |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| } | } | ||||||
							
								
								
									
										41
									
								
								src/VistaControlador/ControladorPanelModificar.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								src/VistaControlador/ControladorPanelModificar.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | |||||||
|  | package VistaControlador; | ||||||
|  | 
 | ||||||
|  | import java.awt.event.ActionEvent; | ||||||
|  | import java.awt.event.ActionListener; | ||||||
|  | 
 | ||||||
|  | import Logica.Gestion; | ||||||
|  | 
 | ||||||
|  | public class ControladorPanelModificar implements ActionListener{ | ||||||
|  | 	VistaPanelModificar vista; | ||||||
|  | 	Menu menu; | ||||||
|  | 	 | ||||||
|  | 	ControladorPanelModificar(VistaPanelModificar vista, Menu menu) { | ||||||
|  | 		this.menu = menu; | ||||||
|  | 		this.vista = vista; | ||||||
|  | 		this.aniadirListeners(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void aniadirListeners() { | ||||||
|  | 		this.vista.editarGestion.addActionListener(this); | ||||||
|  | 		this.vista.editarGestion.setActionCommand("Editar gestion"); | ||||||
|  | 		this.vista.editarTransaccion.addActionListener(this); | ||||||
|  | 		this.vista.editarTransaccion.setActionCommand("Editar transaccion"); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public void actionPerformed(ActionEvent arg0) { | ||||||
|  | 		switch(arg0.getActionCommand()) { | ||||||
|  | 		case "Editar gestion":{ | ||||||
|  | 			this.menu.pestanias.get(this.menu.pestania.getSelectedIndex()).gestiones.setNombre(this.vista.nuevoEditar.getText()); | ||||||
|  | 			this.menu.cargarPestanias(); | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		case "Editar transaccion":{ | ||||||
|  | 			this.menu.pestanias.get(this.menu.pestania.getSelectedIndex()).editarTransaccion(this.vista.viejoEditar.getText(), this.vista.nuevoEditar.getText()); | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -19,25 +19,36 @@ import javax.swing.JTextArea; | |||||||
| import javax.swing.event.ChangeEvent; | import javax.swing.event.ChangeEvent; | ||||||
| import javax.swing.event.ChangeListener; | import javax.swing.event.ChangeListener; | ||||||
| 
 | 
 | ||||||
|  | import com.github.lgooddatepicker.components.DatePicker; | ||||||
|  | import com.github.lgooddatepicker.optionalusertools.DateChangeListener; | ||||||
|  | 
 | ||||||
| import Ficheros.Configuracion; | import Ficheros.Configuracion; | ||||||
| import Logica.Gestion; | import Logica.Gestion; | ||||||
| import Logica.Meses; | import Logica.Meses; | ||||||
| import Logica.Transaccion; | import Logica.Transaccion; | ||||||
| 
 | 
 | ||||||
| public class Menu extends JFrame{ | public class Menu extends JFrame{ | ||||||
| 	protected JPanel panelCentral; | 	static final int VISTA_MODIFICAR = 0; | ||||||
| 	protected JTabbedPane pestania; | 	static final int VISTA_GESTION = 1; | ||||||
| 	protected VistaAniadirVisualizar ingresos; | 	 | ||||||
| 	protected VistaAniadirVisualizar gastos; | 	JPanel panelCentral; | ||||||
| 	protected VistaPanelLateral panel; | 	JTabbedPane pestania; | ||||||
|  | 	VistaAniadirVisualizar ingresos; | ||||||
|  | 	VistaAniadirVisualizar gastos; | ||||||
|  | 	VistaPanelGestion panelGestion; | ||||||
|  | 	VistaPanelModificar panelModificar; | ||||||
|  | 	VistaPanel panel; | ||||||
| 	String rutaGuardado; | 	String rutaGuardado; | ||||||
| 	int tema; | 	int tema; | ||||||
| 	Meses meses; | 	Meses meses; | ||||||
| 	ArrayList<VistaAniadirVisualizar> pestanias; | 	ArrayList<VistaAniadirVisualizar> pestanias; | ||||||
| 	ArrayList<ControladorAniadirVisualizar> controladores; | 	ArrayList<ControladorAniadirVisualizar> controladores; | ||||||
| 	BarraOpciones barra; | 	BarraOpciones barra; | ||||||
| 	protected Gestion datosGastos; | 	Gestion datosGastos; | ||||||
| 	protected Gestion datosIngresos; | 	Gestion datosIngresos; | ||||||
|  | 	DatePicker elegirMes; | ||||||
|  | 	int anio; | ||||||
|  | 	Month mes; | ||||||
| 	 | 	 | ||||||
| 	/** | 	/** | ||||||
| 	 * Constructor que carga los datos del menu | 	 * Constructor que carga los datos del menu | ||||||
| @ -62,7 +73,9 @@ public class Menu extends JFrame{ | |||||||
| 		this.cargarPestanias(); | 		this.cargarPestanias(); | ||||||
| 		this.panelCentral = new JPanel(); | 		this.panelCentral = new JPanel(); | ||||||
| 		this.panelCentral.setLayout(new GridBagLayout()); | 		this.panelCentral.setLayout(new GridBagLayout()); | ||||||
| 		this.panel = new VistaPanelLateral(this.meses); | 		this.panelGestion = new VistaPanelGestion(this.meses); | ||||||
|  | 		this.panelModificar = new VistaPanelModificar(); | ||||||
|  | 		this.panel = this.panelGestion; | ||||||
| 		 | 		 | ||||||
| 		constrain.fill = GridBagConstraints.HORIZONTAL; | 		constrain.fill = GridBagConstraints.HORIZONTAL; | ||||||
| 		constrain.gridx = 0; | 		constrain.gridx = 0; | ||||||
| @ -70,21 +83,41 @@ public class Menu extends JFrame{ | |||||||
| 		constrain.gridy = 0; | 		constrain.gridy = 0; | ||||||
| 		constrain.weightx = 0; | 		constrain.weightx = 0; | ||||||
| 		this.panelCentral.add(this.barra,constrain); | 		this.panelCentral.add(this.barra,constrain); | ||||||
|  | 		 | ||||||
| 		constrain.fill = GridBagConstraints.HORIZONTAL; | 		constrain.fill = GridBagConstraints.HORIZONTAL; | ||||||
| 		constrain.gridwidth = 1; | 		constrain.gridwidth = 1; | ||||||
| 		constrain.gridx = 0; | 		constrain.gridx = 0; | ||||||
| 		constrain.gridy = 1; | 		constrain.gridy = 1; | ||||||
|  | 		constrain.gridheight = 2; | ||||||
| 		constrain.weightx = 0.25; | 		constrain.weightx = 0.25; | ||||||
| 		this.panelCentral.add(pestania,constrain); | 		this.panelCentral.add(pestania,constrain); | ||||||
| 		setTitle("Titulo"); | 		setTitle("Titulo"); | ||||||
| 		setSize(new Dimension(420,320)); | 		setSize(new Dimension(420,320)); | ||||||
| 		setDefaultCloseOperation(3); | 		setDefaultCloseOperation(3); | ||||||
| 		setLocationRelativeTo(null); | 		setLocationRelativeTo(null); | ||||||
| 		ControladorPanelLateral controlador3 = new ControladorPanelLateral(this.panel, this); | 		ControladorPanelGestion controlador3 = new ControladorPanelGestion(this.panelGestion, this); | ||||||
|  | 		ControladorPanelModificar controlador4 = new ControladorPanelModificar(this.panelModificar, this); | ||||||
| 		this.listenerPestania(); | 		this.listenerPestania(); | ||||||
|  | 		 | ||||||
|  | 		this.elegirMes = new DatePicker(); | ||||||
|  | 		this.elegirMes.setDate(LocalDate.now()); | ||||||
|  | 		this.elegirMes.addDateChangeListener((DateChangeListener)->{ | ||||||
|  | 			if(!this.elegirMes.getDate().getMonth().equals(this.mes) || !(this.elegirMes.getDate().getYear() == this.anio) ) { | ||||||
|  | 				this.mes = this.elegirMes.getDate().getMonth(); | ||||||
|  | 				this.anio = this.elegirMes.getDate().getYear(); | ||||||
|  | 				this.cargarGestiones(this.anio, this.mes); | ||||||
|  | 			} | ||||||
|  | 		}); | ||||||
| 		constrain.fill = GridBagConstraints.HORIZONTAL; | 		constrain.fill = GridBagConstraints.HORIZONTAL; | ||||||
| 		constrain.gridx = 1; | 		constrain.gridx = 1; | ||||||
| 		constrain.gridy = 1; | 		constrain.gridy = 1; | ||||||
|  | 		constrain.gridheight = 1; | ||||||
|  | 		constrain.weightx = 0.25; | ||||||
|  | 		this.panelCentral.add(this.elegirMes, constrain); | ||||||
|  | 		 | ||||||
|  | 		constrain.fill = GridBagConstraints.HORIZONTAL; | ||||||
|  | 		constrain.gridx = 1; | ||||||
|  | 		constrain.gridy = 2; | ||||||
| 		constrain.weightx = 0.25; | 		constrain.weightx = 0.25; | ||||||
| 		this.panelCentral.add(this.panel,constrain); | 		this.panelCentral.add(this.panel,constrain); | ||||||
| 		this.add(this.panelCentral); | 		this.add(this.panelCentral); | ||||||
| @ -204,7 +237,7 @@ public class Menu extends JFrame{ | |||||||
| 	 * @param sumaOResta	tipo de 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, this.anio, this.mes, sumaOResta); | ||||||
| 		VistaAniadirVisualizar vista = new VistaAniadirVisualizar(this, gestion); | 		VistaAniadirVisualizar vista = new VistaAniadirVisualizar(this, gestion); | ||||||
| 		this.pestanias.add(vista); | 		this.pestanias.add(vista); | ||||||
| 		this.controladores.add(new ControladorAniadirVisualizar(vista)); | 		this.controladores.add(new ControladorAniadirVisualizar(vista)); | ||||||
| @ -219,7 +252,7 @@ public class Menu extends JFrame{ | |||||||
| 			this.pestania.addChangeListener((ChangeListener)->{ | 			this.pestania.addChangeListener((ChangeListener)->{ | ||||||
| 				if(this.pestania.getTabCount()>0) { | 				if(this.pestania.getTabCount()>0) { | ||||||
| 					try { | 					try { | ||||||
| 						this.panel.actualizarDatos(meses.getGestionesActuales().get(this.pestania.getSelectedIndex())); | 						this.panelGestion.actualizarDatos(meses.getGestionesActuales().get(this.pestania.getSelectedIndex())); | ||||||
| 					}catch (Exception e) { | 					}catch (Exception e) { | ||||||
| 						// TODO: handle exception | 						// TODO: handle exception | ||||||
| 					} | 					} | ||||||
| @ -272,7 +305,8 @@ public class Menu extends JFrame{ | |||||||
| 			this.panelCentral.setBackground(Color.WHITE); | 			this.panelCentral.setBackground(Color.WHITE); | ||||||
| 			this.panelCentral.repaint(); | 			this.panelCentral.repaint(); | ||||||
| 			this.panelCentral.revalidate(); | 			this.panelCentral.revalidate(); | ||||||
| 			this.panel.setBackground(Color.WHITE); | 			this.panelGestion.setBackground(Color.WHITE); | ||||||
|  | 			this.panelModificar.setBackground(Color.WHITE); | ||||||
| 			this.panel.repaint(); | 			this.panel.repaint(); | ||||||
| 			this.panel.revalidate(); | 			this.panel.revalidate(); | ||||||
| 			break; | 			break; | ||||||
| @ -287,7 +321,8 @@ public class Menu extends JFrame{ | |||||||
| 			this.panelCentral.setBackground(Color.PINK); | 			this.panelCentral.setBackground(Color.PINK); | ||||||
| 			this.panelCentral.repaint(); | 			this.panelCentral.repaint(); | ||||||
| 			this.panelCentral.revalidate(); | 			this.panelCentral.revalidate(); | ||||||
| 			this.panel.setBackground(Color.PINK); | 			this.panelGestion.setBackground(Color.PINK); | ||||||
|  | 			this.panelModificar.setBackground(Color.PINK); | ||||||
| 			this.panel.repaint(); | 			this.panel.repaint(); | ||||||
| 			this.panel.revalidate(); | 			this.panel.revalidate(); | ||||||
| 			break; | 			break; | ||||||
| @ -302,7 +337,8 @@ public class Menu extends JFrame{ | |||||||
| 			this.panelCentral.setBackground(Color.BLACK); | 			this.panelCentral.setBackground(Color.BLACK); | ||||||
| 			this.panelCentral.repaint(); | 			this.panelCentral.repaint(); | ||||||
| 			this.panelCentral.revalidate(); | 			this.panelCentral.revalidate(); | ||||||
| 			this.panel.setBackground(Color.BLACK); | 			this.panelGestion.setBackground(Color.BLACK); | ||||||
|  | 			this.panelModificar.setBackground(Color.BLACK); | ||||||
| 			this.panel.repaint(); | 			this.panel.repaint(); | ||||||
| 			this.panel.revalidate(); | 			this.panel.revalidate(); | ||||||
| 			break; | 			break; | ||||||
| @ -311,4 +347,30 @@ public class Menu extends JFrame{ | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	void cambiarVista(int vista) { | ||||||
|  | 		GridBagConstraints constrain = new GridBagConstraints(); | ||||||
|  | 		this.panelCentral.remove(this.panel); | ||||||
|  | 		constrain = new GridBagConstraints(); | ||||||
|  | 		constrain.fill = GridBagConstraints.HORIZONTAL; | ||||||
|  | 		constrain.gridx = 1; | ||||||
|  | 		constrain.gridy = 2; | ||||||
|  | 		constrain.weightx = 0.25; | ||||||
|  | 		switch(vista) { | ||||||
|  | 		case Menu.VISTA_GESTION:{ | ||||||
|  | 			this.panel = this.panelGestion; | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		case Menu.VISTA_MODIFICAR:{ | ||||||
|  | 			this.panel = this.panelModificar; | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		} | ||||||
|  | 		this.panelCentral.add(this.panel,constrain); | ||||||
|  | 		this.panel.repaint(); | ||||||
|  | 		this.panel.revalidate(); | ||||||
|  | 		this.panelCentral.repaint(); | ||||||
|  | 		this.panelCentral.revalidate(); | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| } | } | ||||||
|  | |||||||
| @ -20,6 +20,7 @@ public class MostrarTodo extends JFrame{ | |||||||
| 	public MostrarTodo(Meses meses) { | 	public MostrarTodo(Meses meses) { | ||||||
| 		super(); | 		super(); | ||||||
| 		this.elementos=new JList<String>(meses.salidaTodo()); | 		this.elementos=new JList<String>(meses.salidaTodo()); | ||||||
|  | 		this.setSize(400, 400); | ||||||
| 		this.add(elementos); | 		this.add(elementos); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -20,8 +20,8 @@ public class VistaAniadirVisualizar extends JPanel{ | |||||||
| 	JPanel cuadro; | 	JPanel cuadro; | ||||||
| 	JScrollPane panel; | 	JScrollPane panel; | ||||||
| 	Menu menu; | 	Menu menu; | ||||||
| 	private ControladorAniadirVisualizar controlador; | 	//private ControladorAniadirVisualizar controlador; | ||||||
| 	private static VistaPanelLateral panelLateral; | 	//private static VistaPanelGestion panelLateral; | ||||||
| 	 | 	 | ||||||
| 	/** | 	/** | ||||||
| 	 * Constructor de la ventana que contendra las pestanias | 	 * Constructor de la ventana que contendra las pestanias | ||||||
| @ -51,9 +51,9 @@ public class VistaAniadirVisualizar extends JPanel{ | |||||||
| 	 *  | 	 *  | ||||||
| 	 * @param panel	panel lateral que gestionara este panel | 	 * @param panel	panel lateral que gestionara este panel | ||||||
| 	 */ | 	 */ | ||||||
| 	public static void setPanelLateral(VistaPanelLateral panel) { | 	/*public static void setPanelLateral(VistaPanelGestion panel) { | ||||||
| 		VistaAniadirVisualizar.panelLateral = panel; | 		VistaAniadirVisualizar.panelLateral = panel; | ||||||
| 	} | 	}*/ | ||||||
| 	 | 	 | ||||||
| 	public String getName() { | 	public String getName() { | ||||||
| 		return this.gestiones.getNombre(); | 		return this.gestiones.getNombre(); | ||||||
| @ -76,7 +76,7 @@ public class VistaAniadirVisualizar extends JPanel{ | |||||||
| 	 * @param controlador	controlador de la casilla que de aniadira | 	 * @param 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,this.menu.elegirMes.getDate(),this.gestiones); | ||||||
| 		this.gestiones.aniadirGasto(transaccion); | 		this.gestiones.aniadirGasto(transaccion); | ||||||
| 		JCheckBox check = new JCheckBox(transaccion.toString()); | 		JCheckBox check = new JCheckBox(transaccion.toString()); | ||||||
| 		check.setSelected(true); | 		check.setSelected(true); | ||||||
| @ -99,13 +99,33 @@ public class VistaAniadirVisualizar extends JPanel{ | |||||||
| 			if(!check.isSelected()) { | 			if(!check.isSelected()) { | ||||||
| 				this.cuadro.remove(check); | 				this.cuadro.remove(check); | ||||||
| 				this.gestiones.eliminarTransaccion(check.getText()); | 				this.gestiones.eliminarTransaccion(check.getText()); | ||||||
| 				this.menu.panel.actualizarDatos(this.gestiones); | 				this.menu.panelGestion.actualizarDatos(this.gestiones); | ||||||
| 				this.cuadro.revalidate(); | 				this.cuadro.revalidate(); | ||||||
| 				this.cuadro.repaint(); | 				this.cuadro.repaint(); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	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())) { | ||||||
|  | 						transaccion.setName(nombreNuevo); | ||||||
|  | 						check.setText(transaccion.toString()); | ||||||
|  | 						check.revalidate(); | ||||||
|  | 						check.repaint(); | ||||||
|  | 						//this.gestiones.editarTransaccion(nombreViejo, nombreNuevo); | ||||||
|  | 						this.menu.panelGestion.actualizarDatos(this.gestiones); | ||||||
|  | 						this.cuadro.revalidate(); | ||||||
|  | 						this.cuadro.repaint(); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	/** | 	/** | ||||||
| 	 * aniade una nueva transaccion | 	 * aniade una nueva transaccion | ||||||
| 	 */ | 	 */ | ||||||
|  | |||||||
							
								
								
									
										7
									
								
								src/VistaControlador/VistaPanel.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/VistaControlador/VistaPanel.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | |||||||
|  | package VistaControlador; | ||||||
|  | 
 | ||||||
|  | import javax.swing.JPanel; | ||||||
|  | 
 | ||||||
|  | public class VistaPanel extends JPanel{ | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -1,12 +1,10 @@ | |||||||
| package VistaControlador; | package VistaControlador; | ||||||
| 
 | 
 | ||||||
| import java.awt.Dimension; | import java.awt.Dimension; | ||||||
| import java.awt.GridBagConstraints; |  | ||||||
| import java.time.LocalDate; | import java.time.LocalDate; | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
| 
 | 
 | ||||||
| import javax.swing.JButton; | import javax.swing.JButton; | ||||||
| import javax.swing.JPanel; |  | ||||||
| import javax.swing.JTextArea; | import javax.swing.JTextArea; | ||||||
| 
 | 
 | ||||||
| import com.github.lgooddatepicker.components.DatePicker; | import com.github.lgooddatepicker.components.DatePicker; | ||||||
| @ -14,10 +12,10 @@ import com.github.lgooddatepicker.components.DatePicker; | |||||||
| import Logica.Gestion; | import Logica.Gestion; | ||||||
| import Logica.Meses; | import Logica.Meses; | ||||||
| 
 | 
 | ||||||
| public class VistaPanelLateral extends JPanel{ | public class VistaPanelGestion extends VistaPanel{ | ||||||
| 	protected JTextArea total; | 	protected JTextArea total; | ||||||
| 	protected JTextArea gastoEnvio; | 	protected JTextArea gastoEnvio; | ||||||
| 	protected static DatePicker elegirMes = inicializarCalendario(); | 	//protected static DatePicker elegirMes = inicializarCalendario(); | ||||||
| 	protected JButton mostrarEstadisticas; | 	protected JButton mostrarEstadisticas; | ||||||
| 	JButton aniadirGestion; | 	JButton aniadirGestion; | ||||||
| 	JButton eliminarTransaccion; | 	JButton eliminarTransaccion; | ||||||
| @ -27,7 +25,8 @@ public class VistaPanelLateral extends JPanel{ | |||||||
| 	 *  | 	 *  | ||||||
| 	 * @param meses	datos a gestionar | 	 * @param meses	datos a gestionar | ||||||
| 	 */ | 	 */ | ||||||
| 	VistaPanelLateral(Meses meses){ | 	VistaPanelGestion(Meses meses){ | ||||||
|  | 		super(); | ||||||
| 		this.setPreferredSize(new Dimension(200,200)); | 		this.setPreferredSize(new Dimension(200,200)); | ||||||
| 		this.meses=meses; | 		this.meses=meses; | ||||||
| 		this.total = new JTextArea(String.valueOf(meses.getTotal())); | 		this.total = new JTextArea(String.valueOf(meses.getTotal())); | ||||||
| @ -35,7 +34,7 @@ public class VistaPanelLateral extends JPanel{ | |||||||
| 		this.mostrarEstadisticas = new JButton("Mostrar grafico del mes"); | 		this.mostrarEstadisticas = new JButton("Mostrar grafico del mes"); | ||||||
| 		this.aniadirGestion = new JButton("Aniadir nueva gestión"); | 		this.aniadirGestion = new JButton("Aniadir nueva gestión"); | ||||||
| 		this.add(this.mostrarEstadisticas); | 		this.add(this.mostrarEstadisticas); | ||||||
| 		this.add(VistaPanelLateral.elegirMes); | 		//this.add(VistaPanelGestion.elegirMes); | ||||||
| 		this.add(this.total); | 		this.add(this.total); | ||||||
| 		this.add(this.gastoEnvio); | 		this.add(this.gastoEnvio); | ||||||
| 		this.add(this.aniadirGestion); | 		this.add(this.aniadirGestion); | ||||||
| @ -56,19 +55,9 @@ public class VistaPanelLateral extends JPanel{ | |||||||
| 	 *  | 	 *  | ||||||
| 	 * @return	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() { |  | ||||||
| 		DatePicker ret = new DatePicker(); |  | ||||||
| 		ret.setDate(LocalDate.now()); |  | ||||||
| 		return ret; |  | ||||||
| 	} |  | ||||||
| 	 | 	 | ||||||
| } | } | ||||||
							
								
								
									
										57
									
								
								src/VistaControlador/VistaPanelModificar.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								src/VistaControlador/VistaPanelModificar.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | |||||||
|  | package VistaControlador; | ||||||
|  | 
 | ||||||
|  | import java.awt.Dimension; | ||||||
|  | import java.awt.GridBagConstraints; | ||||||
|  | import java.awt.GridBagLayout; | ||||||
|  | 
 | ||||||
|  | import javax.swing.JButton; | ||||||
|  | import javax.swing.JTextField; | ||||||
|  | 
 | ||||||
|  | public class VistaPanelModificar extends VistaPanel{ | ||||||
|  | 	JTextField viejoNombre; | ||||||
|  | 	JTextField nuevoNombre; | ||||||
|  | 	JTextField viejoEditar; | ||||||
|  | 	JTextField nuevoEditar; | ||||||
|  | 	JButton editarTransaccion; | ||||||
|  | 	JButton editarGestion; | ||||||
|  | 	VistaPanelModificar() { | ||||||
|  | 		GridBagConstraints constrain = new GridBagConstraints(); | ||||||
|  | 		this.setLayout(new GridBagLayout()); | ||||||
|  | 		 | ||||||
|  | 		//this.add(VistaPanelGestion.elegirMes); | ||||||
|  | 		 | ||||||
|  | 		this.viejoNombre = new JTextField("Nombre"); | ||||||
|  | 		this.viejoNombre.setEditable(false); | ||||||
|  | 		constrain.gridx = 0; | ||||||
|  | 		constrain.gridy = 0; | ||||||
|  | 		this.add(this.viejoNombre, constrain); | ||||||
|  | 		 | ||||||
|  | 		this.nuevoNombre = new JTextField("Nombre nuevo"); | ||||||
|  | 		this.nuevoNombre.setEditable(false); | ||||||
|  | 		constrain.gridx = 0; | ||||||
|  | 		constrain.gridy = 1; | ||||||
|  | 		this.add(this.nuevoNombre, constrain); | ||||||
|  | 		 | ||||||
|  | 		this.viejoEditar = new JTextField(); | ||||||
|  | 		this.viejoEditar.setPreferredSize(new Dimension(80, 17)); | ||||||
|  | 		constrain.gridx = 1; | ||||||
|  | 		constrain.gridy = 0; | ||||||
|  | 		this.add(this.viejoEditar, constrain); | ||||||
|  | 		 | ||||||
|  | 		this.nuevoEditar = new JTextField(); | ||||||
|  | 		this.nuevoEditar.setPreferredSize(new Dimension(80, 17)); | ||||||
|  | 		constrain.gridx = 1; | ||||||
|  | 		constrain.gridy = 1; | ||||||
|  | 		this.add(this.nuevoEditar, constrain); | ||||||
|  | 		 | ||||||
|  | 		this.editarGestion = new JButton("Gestion"); | ||||||
|  | 		constrain.gridx = 0; | ||||||
|  | 		constrain.gridy = 2; | ||||||
|  | 		this.add(this.editarGestion, constrain); | ||||||
|  | 		 | ||||||
|  | 		this.editarTransaccion = new JButton("Transaccion"); | ||||||
|  | 		constrain.gridx = 1; | ||||||
|  | 		constrain.gridy = 2; | ||||||
|  | 		this.add(this.editarTransaccion, constrain); | ||||||
|  | 	} | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user