2019-11-15 17:18:58 +01:00
|
|
|
package VistaControlador;
|
|
|
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
|
2019-11-16 21:05:09 +01:00
|
|
|
import Ficheros.Configuracion;
|
|
|
|
|
2019-11-15 17:18:58 +01:00
|
|
|
public class ControladorBarra implements ActionListener{
|
|
|
|
private BarraOpciones barra;
|
|
|
|
private Menu menu;
|
|
|
|
public ControladorBarra(BarraOpciones barra, Menu menu) {
|
|
|
|
this.barra = barra;
|
|
|
|
this.menu = menu;
|
|
|
|
this.aniadirListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
switch(e.getActionCommand()) {
|
|
|
|
case "Cambiar ruta":{
|
|
|
|
String ruta = JOptionPane.showInputDialog("Introduce la nuev a ruta");
|
|
|
|
if(ruta == null) return;
|
|
|
|
if(ruta.equals("")) {
|
|
|
|
JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE);
|
|
|
|
return;
|
|
|
|
}
|
2019-11-16 21:05:09 +01:00
|
|
|
this.menu.rutaGuardado = ruta;
|
|
|
|
Configuracion.guardarConfiguracion(this.menu);
|
2019-11-15 17:18:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "Guardar instantanea":{
|
|
|
|
String ruta = JOptionPane.showInputDialog("Introduce la ruta de la instantanea");
|
|
|
|
if(ruta == null) return;
|
|
|
|
if(ruta.equals("")) {
|
|
|
|
JOptionPane.showMessageDialog(null, "Debe introducir algo", "error", JOptionPane.WARNING_MESSAGE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
this.menu.meses.guardarMeses(ruta);
|
|
|
|
} catch (IOException e1) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
System.out.println("Fichero invalido");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "Modo claro":{
|
2019-11-16 21:05:09 +01:00
|
|
|
menu.setTheme(0);
|
2019-11-15 17:18:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "Modo rosa":{
|
2019-11-16 21:05:09 +01:00
|
|
|
menu.setTheme(1);
|
2019-11-15 17:18:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "Modo oscuro":{
|
2019-11-16 21:05:09 +01:00
|
|
|
menu.setTheme(2);
|
2019-11-15 17:18:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "Mostrar todo":{
|
|
|
|
MostrarTodo mostrar = new MostrarTodo(this.menu.meses);
|
|
|
|
mostrar.setVisible(true);
|
|
|
|
break;
|
|
|
|
}
|
2019-11-16 21:05:09 +01:00
|
|
|
case "Exportar XLM":{
|
|
|
|
this.menu.meses.exportarXML();
|
|
|
|
}
|
2019-11-15 17:18:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void aniadirListeners() {
|
|
|
|
this.barra.cambiarRuta.addActionListener(this);
|
|
|
|
this.barra.cambiarRuta.setActionCommand("Cambiar ruta");
|
|
|
|
this.barra.guardarIns.addActionListener(this);
|
|
|
|
this.barra.guardarIns.setActionCommand("Guardar instantanea");
|
2019-11-16 21:05:09 +01:00
|
|
|
this.barra.exportarXML.addActionListener(this);
|
|
|
|
this.barra.exportarXML.setActionCommand("Exportar XLM");
|
2019-11-15 17:18:58 +01:00
|
|
|
this.barra.modoClaro.addActionListener(this);
|
|
|
|
this.barra.modoClaro.setActionCommand("Modo claro");
|
|
|
|
this.barra.modoRosa.addActionListener(this);
|
|
|
|
this.barra.modoRosa.setActionCommand("Modo rosa");
|
|
|
|
this.barra.modoOscuro.addActionListener(this);
|
|
|
|
this.barra.modoOscuro.setActionCommand("Modo oscuro");
|
|
|
|
this.barra.mostrarTodo.addActionListener(this);
|
|
|
|
this.barra.mostrarTodo.setActionCommand("Mostrar todo");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|