Package practica1.actions

Source Code of practica1.actions.ActionExportarExcel

package practica1.actions;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import practica1.Practica1;
import practica1.controller.Controller;
import practica1.language.Language;
import practica1.language.LanguageEvent;
import practica1.language.LanguageListener;
import practica1.logic.LogicExperimento;
import practica1.manejoExperimento.ExperimentoInvalidoException;
import practica1.manejoExperimento.ExportarExperimentoExcel;

/**
* Clase que implementa la acción para exportar a access un experimento
* @author Miguel González - Ceura
*/
public class ActionExportarExcel extends AbstractAction implements LanguageListener {
   
    /**
     * Constructor de la clase
     */
    public ActionExportarExcel() {
        super(Language.getI().getP("EXPORTAR_EXCEL"), null);

        Language.getI().addLanguageListener(this);
       
        putValue(SHORT_DESCRIPTION, Language.getI().getP("EXPORTAR_EXCEL"));
        putValue(NAME, Language.getI().getP("EXPORTAR_EXCEL"));
        putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_E));
        putValue(SELECTED_KEY, Boolean.TRUE);
    }
   
    /**
     * Cuando sucede la acción nos encargamos de exportar a access el
     * experimento princpal
     * @param e ActionEvent Evento producido
     */
    @Override
    public void actionPerformed(ActionEvent e) {
        LogicExperimento exp = Controller.getInstance().getExperimentoPrincipal();
       
        if(exp != null) {
            try {
                ExportarExperimentoExcel.ExportarExcel (exp);
            } catch (ExperimentoInvalidoException ex) {
                Practica1.log.error(Language.getI().getP("ERROR"), ex);
                JOptionPane.showMessageDialog(Practica1.getInstance(),
                            Language.getI().getP("PROBLEMA_EXPORTAR"),
                            Language.getI().getP("ERROR"), JOptionPane.ERROR_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(Practica1.getInstance(),
                        Language.getI().getP("SELECCIONA_EXPERIMENTO_COMO"
                    + "_PRINCIPAL"), Language.getI().getP("CERRAR"),
                                JOptionPane.WARNING_MESSAGE);
        }
    }

    /**
     * Al cambiar el idioma actualizamos el nombre y la descripción
     * @param evt LanguageEvent
     */
    @Override
    public void idiomaChange(LanguageEvent evt) {
        putValue(SHORT_DESCRIPTION, Language.getI().getP("EXPORTAR_EXCEL"));
        putValue(NAME, Language.getI().getP("EXPORTAR_EXCEL"));
    }
}
TOP

Related Classes of practica1.actions.ActionExportarExcel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.