91 lines
2.5 KiB
Java
91 lines
2.5 KiB
Java
package VistaControlador;
|
|
|
|
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;
|
|
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;
|
|
}
|
|
this.menu.rutaGuardado = ruta;
|
|
Configuracion.guardarConfiguracion(this.menu);
|
|
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":{
|
|
menu.setTheme(0);
|
|
break;
|
|
}
|
|
case "Modo rosa":{
|
|
menu.setTheme(1);
|
|
break;
|
|
}
|
|
case "Modo oscuro":{
|
|
menu.setTheme(2);
|
|
break;
|
|
}
|
|
case "Mostrar todo":{
|
|
MostrarTodo mostrar = new MostrarTodo(this.menu.meses);
|
|
mostrar.setVisible(true);
|
|
break;
|
|
}
|
|
case "Exportar XLM":{
|
|
this.menu.meses.exportarXML();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
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");
|
|
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);
|
|
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");
|
|
}
|
|
|
|
}
|