Corregir bugs y aniadir la opcion de eliminar transacciones

This commit is contained in:
2019-11-15 01:10:55 +01:00
parent 86c642dba9
commit 0d6d20001f
7 changed files with 57 additions and 31 deletions

View File

@@ -74,21 +74,12 @@ public class ControladorPanelLateral implements ActionListener, DateChangeListen
}
break;
}
case "Eliminar Transacciones":{
this.menu.pestanias.get(this.menu.pestania.getSelectedIndex()).eliminarDeseleccionados();
}
}
/*if(e.getActionCommand().equals(this.vista.mostrarEstadisticas.getActionCommand())) {
XYSeries serie = new XYSeries("Mes");
serie.add(10,1);
serie.add(4,2);
serie.add(90,10);
XYSeriesCollection dataset = new XYSeriesCollection(serie);
JFreeChart chart = ChartFactory.createXYLineChart("Mes", "Dias", "Gastos", dataset);
ChartFrame frame = new ChartFrame("Estadisricas", chart);
frame.setVisible(true);
frame.setSize(700,500);
}
*/
}
private void aniadirElementos() {
@@ -101,6 +92,8 @@ public class ControladorPanelLateral implements ActionListener, DateChangeListen
this.mes=VistaPanelLateral.elegirMes.getDate().getMonth();
this.anio=VistaPanelLateral.elegirMes.getDate().getYear();
}
this.vista.eliminarTransaccion.addActionListener(this);
this.vista.eliminarTransaccion.setActionCommand("Eliminar Transacciones");
}
public void dateChanged(DateChangeEvent arg0) {

View File

@@ -35,7 +35,7 @@ public class Menu extends JFrame{
this.cargarPestanias();
this.setLayout(new GridBagLayout());
GridBagConstraints constrain = new GridBagConstraints();
this.panel = new VistaPanelLateral(constrain);
this.panel = new VistaPanelLateral(constrain, this.meses);
this.panelCentral = new JPanel();
constrain.fill = GridBagConstraints.VERTICAL;
@@ -77,7 +77,6 @@ public class Menu extends JFrame{
this.meses.elegirMes(anio, mes);
if(this.meses.getGestionesActuales().size() == 0) {
this.iniciarMes(anio, mes);
System.out.println("entra");
}else {
this.cargarMes();
}

View File

@@ -21,7 +21,7 @@ public class VistaAniadirVisualizar extends JPanel{
JScrollPane panel;
Menu menu;
private ControladorAniadirVisualizar controlador;
static VistaPanelLateral panelLateral;
private static VistaPanelLateral panelLateral;
public VistaAniadirVisualizar(Menu menu, Gestion gestion) {
this.gestiones = gestion;
this.transacciones = new LinkedList<JCheckBox>();
@@ -68,6 +68,16 @@ public class VistaAniadirVisualizar extends JPanel{
this.repaint();
}
void eliminarDeseleccionados(){
for(JCheckBox check:this.transacciones) {
if(!check.isSelected()) {
this.cuadro.remove(check);
this.gestiones.eliminarTransaccion(check.getText());
this.cuadro.revalidate();
this.cuadro.repaint();
}
}
}
private void aniadirElemento(Transaccion transaccion) {
JCheckBox check = new JCheckBox(transaccion.toString());

View File

@@ -12,16 +12,19 @@ import javax.swing.JTextArea;
import com.github.lgooddatepicker.components.DatePicker;
import Logica.Gestion;
import Logica.Meses;
public class VistaPanelLateral extends JPanel{
protected JTextArea total;
protected JTextArea gastoEnvio;
//protected JButton elegirMes;
protected static DatePicker elegirMes = inicializarCalendario();
protected JButton mostrarEstadisticas;
JButton aniadirGestion;
VistaPanelLateral(GridBagConstraints constrain){
JButton eliminarTransaccion;
Meses meses;
VistaPanelLateral(GridBagConstraints constrain, Meses meses){
this.setPreferredSize(new Dimension(200,200));
this.meses=meses;
this.total = new JTextArea();
this.gastoEnvio = new JTextArea();
this.mostrarEstadisticas = new JButton("Mostrar grafico del mes");
@@ -40,10 +43,12 @@ public class VistaPanelLateral extends JPanel{
constrain.weightx = 2;
this.add(this.gastoEnvio);
this.add(this.aniadirGestion);
this.eliminarTransaccion = new JButton("Eliminar Deseleccionados");
this.add(this.eliminarTransaccion);
}
void actualizarDatos(Gestion gestion) {
this.total.setText("Total: " + String.valueOf(Gestion.getTotal()) + "");
this.total.setText("Total: " + String.valueOf(this.meses.getTotal()) + "");
this.gastoEnvio.setText("Suma: " + String.valueOf(gestion.getSuma()) + "");
}