Terminado soporte aniadir gestion nueva
This commit is contained in:
@@ -26,38 +26,29 @@ public class Menu extends JFrame{
|
||||
protected VistaPanelLateral panel;
|
||||
Meses meses;
|
||||
ArrayList<VistaAniadirVisualizar> pestanias;
|
||||
ArrayList<ControladorAniadirVisualizar> controladores;
|
||||
protected Gestion datosGastos;
|
||||
protected Gestion datosIngresos;
|
||||
public Menu() {
|
||||
this.meses=new Meses();
|
||||
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.pestania = new JTabbedPane();
|
||||
this.cargarGestiones(LocalDate.now().getYear(), LocalDate.now().getMonth());
|
||||
this.cargarPestanias();
|
||||
this.setLayout(new GridBagLayout());
|
||||
GridBagConstraints constrain = new GridBagConstraints();
|
||||
this.panel = new VistaPanelLateral(constrain);
|
||||
this.ingresos = new VistaAniadirVisualizar(this,meses.getGestionesActuales().get(0),true);
|
||||
this.gastos = new VistaAniadirVisualizar(this,meses.getGestionesActuales().get(1),false);
|
||||
this.panelCentral = new JPanel();
|
||||
this.pestania = new JTabbedPane();
|
||||
|
||||
constrain.fill = GridBagConstraints.VERTICAL;
|
||||
constrain.gridx = 0;
|
||||
constrain.gridy = 0;
|
||||
constrain.weightx = 2;
|
||||
this.panelCentral.add(pestania,constrain);
|
||||
this.pestania.addTab("Ingresos", ingresos);
|
||||
this.pestania.addTab("Gastos", gastos);
|
||||
getContentPane().add(pestania);
|
||||
setTitle("Titulo");
|
||||
setSize(new Dimension(420,320));
|
||||
setDefaultCloseOperation(3);
|
||||
setLocationRelativeTo(null);
|
||||
ControladorAniadirVisualizar controlador = new ControladorAniadirVisualizar(this.ingresos);
|
||||
ControladorAniadirVisualizar controlador2 = new ControladorAniadirVisualizar(this.gastos);
|
||||
ControladorPanelLateral controlador3 = new ControladorPanelLateral(this.panel);
|
||||
//this.panel.actualizarDatos(datosIngresos);
|
||||
ControladorPanelLateral controlador3 = new ControladorPanelLateral(this.panel, this);
|
||||
this.pestania.addChangeListener((ChangeListener)->{
|
||||
if(this.pestania.getSelectedIndex() == 0) {
|
||||
this.panel.actualizarDatos(meses.getGestionesActuales().get(0));
|
||||
@@ -68,28 +59,52 @@ 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=new ArrayList<VistaAniadirVisualizar>();
|
||||
this.pestanias.add(new VistaAniadirVisualizar(this,meses.getGestionesActuales().get(0),true));
|
||||
this.pestanias.add(new VistaAniadirVisualizar(this,meses.getGestionesActuales().get(1),false));
|
||||
this.controladores=new ArrayList<ControladorAniadirVisualizar>();
|
||||
this.controladores.add(new ControladorAniadirVisualizar(this.pestanias.get(0)));
|
||||
this.controladores.add(new ControladorAniadirVisualizar(this.pestanias.get(1)));
|
||||
}
|
||||
|
||||
private void cargarGestiones(int anio, Month mes) {
|
||||
if(this.meses==null) {
|
||||
this.meses=new Meses();
|
||||
}
|
||||
this.meses.elegirMes(anio, mes);
|
||||
if(this.meses.getGestionesActuales().size() == 0) {
|
||||
this.iniciarMes(anio, mes);
|
||||
}else {
|
||||
this.cargarMes();
|
||||
}
|
||||
}
|
||||
|
||||
private void cargarPestanias() {
|
||||
private void cargarMes() {
|
||||
this.pestanias=new ArrayList<VistaAniadirVisualizar>();
|
||||
this.controladores=new ArrayList<ControladorAniadirVisualizar>();
|
||||
for(Gestion gestion:this.meses.getGestionesActuales()) {
|
||||
VistaAniadirVisualizar vista = new VistaAniadirVisualizar(this, gestion, true);
|
||||
this.pestania.add(vista);
|
||||
this.controladores.add(new ControladorAniadirVisualizar(vista));
|
||||
}
|
||||
}
|
||||
|
||||
void cargarPestanias() {
|
||||
this.pestania.removeAll();
|
||||
for(VistaAniadirVisualizar vista:this.pestanias) {
|
||||
this.pestania.add(vista);
|
||||
this.pestania.addTab(vista.getName(),vista);
|
||||
}
|
||||
}
|
||||
|
||||
void aniadirGestion(String nombre, boolean sumaOResta) {
|
||||
Gestion gestion=this.meses.aniadirGestion(nombre, VistaPanelLateral.getDate().getYear(), VistaPanelLateral.getDate().getMonth());
|
||||
VistaAniadirVisualizar vista = new VistaAniadirVisualizar(this, gestion, sumaOResta);
|
||||
this.pestanias.add(vista);
|
||||
this.controladores.add(new ControladorAniadirVisualizar(vista));
|
||||
this.pestania.addTab(vista.getName(),vista);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user