Inicio soporte interfaz cambio mes y aniadir gestiones

This commit is contained in:
roche 2019-11-14 13:56:47 +01:00
parent cde3dec2f5
commit cbace53701
3 changed files with 34 additions and 4 deletions

View File

@ -46,9 +46,11 @@ private ArrayList<Mes> meses;
public void elegirMes(int anio, Month mes) {
for(int i = 0; i < this.meses.size(); i++) {
if(this.meses.get(i).getAnio()==anio && this.meses.get(i).getMes().equals(mes)) {
this.mesActual = 0;
this.mesActual = i;
return;
}
}
this.meses.add(new Mes(new ArrayList<Gestion>(), anio, mes));
}
public ArrayList<Gestion> getGestionesActuales(){

View File

@ -4,6 +4,8 @@ import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.time.LocalDate;
import java.time.Month;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JFrame;
@ -23,6 +25,7 @@ public class Menu extends JFrame{
protected VistaAniadirVisualizar gastos;
protected VistaPanelLateral panel;
Meses meses;
ArrayList<VistaAniadirVisualizar> pestanias;
protected Gestion datosGastos;
protected Gestion datosIngresos;
public Menu() {
@ -30,8 +33,8 @@ public class Menu extends JFrame{
meses.aniadirGestion("Ingresos", LocalDate.now().getYear(), LocalDate.now().getMonth());
meses.aniadirGestion("Gastos", LocalDate.now().getYear(), LocalDate.now().getMonth());
VistaAniadirVisualizar.setPanelLateral(panel);
this.datosGastos = new Gestion();
this.datosIngresos = new Gestion();
//this.datosGastos = new Gestion();
//this.datosIngresos = new Gestion();
this.setLayout(new GridBagLayout());
GridBagConstraints constrain = new GridBagConstraints();
this.panel = new VistaPanelLateral(constrain);
@ -65,4 +68,28 @@ public class Menu extends JFrame{
this.add(this.panel);
}
private void iniciarMes(int anio, Month mes) {
this.meses=new Meses();
meses.aniadirGestion("Ingresos", anio, mes);
meses.aniadirGestion("Gastos", anio, mes);
this.pestanias.add(new VistaAniadirVisualizar(this,meses.getGestionesActuales().get(0),true));
this.pestanias.add(new VistaAniadirVisualizar(this,meses.getGestionesActuales().get(1),false));
}
private void cargarGestiones(int anio, Month mes) {
this.meses.elegirMes(anio, mes);
if(this.meses.getGestionesActuales().size() == 0) {
this.iniciarMes(anio, mes);
}
}
private void cargarPestanias() {
this.pestania.removeAll();
for(VistaAniadirVisualizar vista:this.pestanias) {
this.pestania.add(vista);
}
}
}

View File

@ -19,12 +19,13 @@ public class VistaPanelLateral extends JPanel{
//protected JButton elegirMes;
protected static DatePicker elegirMes = inicializarCalendario();
protected JButton mostrarEstadisticas;
JButton aniadirGestion;
VistaPanelLateral(GridBagConstraints constrain){
this.setPreferredSize(new Dimension(200,200));
this.total = new JTextArea();
this.gastoEnvio = new JTextArea();
this.mostrarEstadisticas = new JButton("Mostrar grafico del mes");
this.aniadirGestion = new JButton("Aniadir nueva gestión");
this.add(this.mostrarEstadisticas);
constrain.gridx = 1;
constrain.gridy = 0;