Package practica1.actions

Source Code of practica1.actions.ActionPropiedadesPoblacion

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package practica1.actions;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import practica1.Practica1;
import practica1.controller.Controller;
import practica1.language.Language;
import practica1.language.LanguageEvent;
import practica1.language.LanguageListener;
import practica1.logic.LogicPoblacion;
import practica1.ui.dialog.DialogPropiedadesPoblacion;

/**
* Clase que implementa la acción de mostrar las propiedades de la población
* @author Miguel González - Ceura
*/
public class ActionPropiedadesPoblacion extends AbstractAction implements LanguageListener {

    /**
     * Constructor de la clase
     */
    public ActionPropiedadesPoblacion() {
        super(Language.getI().getP("PROPIEDADES"), null);

        Language.getI().addLanguageListener(this);
       
        putValue(SHORT_DESCRIPTION, Language.getI().getP("PROPIEDADES_POBLACION"));
        putValue(NAME, Language.getI().getP("PROPIEDADES"));

        //Se establece el estado seleccionado del action
        putValue(SELECTED_KEY, Boolean.TRUE);
    }
   
    /**
     * Cuando sucede la acción nos encargamos de cerrar el experimento seleccionado
     * @param e ActionEvent Evento producido
     */
    @Override
    public void actionPerformed(ActionEvent e) {
        LogicPoblacion pob = Controller.getInstance().
                getPoblacionSeleccionada();
       
        DialogPropiedadesPoblacion dialog = new DialogPropiedadesPoblacion(
                Practica1.getInstance(), pob);
       
        dialog.setVisible(true);

        if(dialog.getAction() == DialogPropiedadesPoblacion.ACEPTAR) {
            pob.setNombrePoblacion(dialog.getNombrePoblacion());
        }
    }

    /**
     * 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("PROPIEDADES_POBLACION"));
        putValue(NAME, Language.getI().getP("PROPIEDADES"));
    }
}
TOP

Related Classes of practica1.actions.ActionPropiedadesPoblacion

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.