Aniadido exportar xml

This commit is contained in:
roche
2019-11-16 21:05:09 +01:00
parent 8bfab6a9dc
commit 1e46c48068
8 changed files with 243 additions and 83 deletions

View File

@@ -10,6 +10,7 @@ public class BarraOpciones extends JMenuBar{
JMenu menuAr;
JMenuItem cambiarRuta;
JMenuItem guardarIns;
JMenuItem exportarXML;
JMenu interfaz;
JMenuItem modoOscuro;
JMenuItem modoRosa;
@@ -23,6 +24,8 @@ public class BarraOpciones extends JMenuBar{
this.menuAr.add(this.guardarIns);
this.cambiarRuta = new JMenuItem("Cambiar ruta de guardado");
this.menuAr.add(this.cambiarRuta);
this.exportarXML = new JMenuItem("Exportar en un XML");
this.menuAr.add(this.exportarXML);
this.interfaz = new JMenu("Interfaz");
this.add(this.interfaz);
this.modoClaro = new JMenuItem("Modo claro");

View File

@@ -1,12 +1,13 @@
package VistaControlador;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.JOptionPane;
import Ficheros.Configuracion;
public class ControladorBarra implements ActionListener{
private BarraOpciones barra;
private Menu menu;
@@ -26,7 +27,8 @@ public class ControladorBarra implements ActionListener{
JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE);
return;
}
this.menu.nombreDatos = ruta;
this.menu.rutaGuardado = ruta;
Configuracion.guardarConfiguracion(this.menu);
break;
}
case "Guardar instantanea":{
@@ -45,46 +47,15 @@ public class ControladorBarra implements ActionListener{
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();
menu.setTheme(0);
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();
menu.setTheme(1);
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();
menu.setTheme(2);
break;
}
case "Mostrar todo":{
@@ -92,6 +63,9 @@ public class ControladorBarra implements ActionListener{
mostrar.setVisible(true);
break;
}
case "Exportar XLM":{
this.menu.meses.exportarXML();
}
}
}
@@ -101,6 +75,8 @@ public class ControladorBarra implements ActionListener{
this.barra.cambiarRuta.setActionCommand("Cambiar ruta");
this.barra.guardarIns.addActionListener(this);
this.barra.guardarIns.setActionCommand("Guardar instantanea");
this.barra.exportarXML.addActionListener(this);
this.barra.exportarXML.setActionCommand("Exportar XLM");
this.barra.modoClaro.addActionListener(this);
this.barra.modoClaro.setActionCommand("Modo claro");
this.barra.modoRosa.addActionListener(this);

View File

@@ -1,5 +1,6 @@
package VistaControlador;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
@@ -18,6 +19,7 @@ import javax.swing.JTextArea;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import Ficheros.Configuracion;
import Logica.Gestion;
import Logica.Meses;
import Logica.Transaccion;
@@ -28,7 +30,8 @@ public class Menu extends JFrame{
protected VistaAniadirVisualizar ingresos;
protected VistaAniadirVisualizar gastos;
protected VistaPanelLateral panel;
String nombreDatos;
String rutaGuardado;
int tema;
Meses meses;
ArrayList<VistaAniadirVisualizar> pestanias;
ArrayList<ControladorAniadirVisualizar> controladores;
@@ -36,9 +39,11 @@ public class Menu extends JFrame{
protected Gestion datosGastos;
protected Gestion datosIngresos;
public Menu() {
this.rutaGuardado = ".mes";
this.tema = 0;
this.barra = new BarraOpciones();
ControladorBarra controladorBarra = new ControladorBarra(barra, this);
this.nombreDatos = ".mes";
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
@@ -79,13 +84,19 @@ public class Menu extends JFrame{
constrain.weightx = 0.25;
this.panelCentral.add(this.panel,constrain);
this.add(this.panelCentral);
try {
Configuracion.cargarConfiguracion(this);
} catch (IOException e) {
e.printStackTrace();
}
}
private void close(){
if (JOptionPane.showConfirmDialog(rootPane, "¿Desea guardar el estado?",
"Salir del sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
try {
this.meses.guardarMeses(this.nombreDatos);
this.meses.guardarMeses(this.rutaGuardado);
Configuracion.guardarConfiguracion(this);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -112,7 +123,7 @@ public class Menu extends JFrame{
if(this.meses==null) {
this.meses=new Meses();
try {
meses.cargarMeses(this.nombreDatos);
meses.cargarMeses(this.rutaGuardado);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -180,8 +191,70 @@ public class Menu extends JFrame{
}
}
});
}
}
public String getRuta() {
return this.rutaGuardado;
}
public void setRuta(String ruta) {
this.rutaGuardado=ruta;
}
public int getTema() {
return this.tema;
}
public void setTheme(int tema) {
switch(tema) {
case 0:{
this.tema = 0;
this.setBackground(Color.WHITE);
this.setOpacity(1);
this.repaint();
this.revalidate();
this.panelCentral.setOpaque(true);
this.panelCentral.setBackground(Color.WHITE);
this.panelCentral.repaint();
this.panelCentral.revalidate();
this.panel.setBackground(Color.WHITE);
this.panel.repaint();
this.panel.revalidate();
break;
}
case 1:{
this.tema = 1;
this.setBackground(Color.PINK);
this.setOpacity(1);
this.repaint();
this.revalidate();
this.panelCentral.setOpaque(true);
this.panelCentral.setBackground(Color.PINK);
this.panelCentral.repaint();
this.panelCentral.revalidate();
this.panel.setBackground(Color.PINK);
this.panel.repaint();
this.panel.revalidate();
break;
}
case 2:{
this.tema = 2;
this.setBackground(Color.BLACK);
this.setOpacity(1);
this.repaint();
this.revalidate();
this.panelCentral.setOpaque(true);
this.panelCentral.setBackground(Color.BLACK);
this.panelCentral.repaint();
this.panelCentral.revalidate();
this.panel.setBackground(Color.BLACK);
this.panel.repaint();
this.panel.revalidate();
break;
}
default: return;
}
}
}