co.edu.icesi.academ.client.perfiles.administrador.PanelEditarMateria.java Source code

Java tutorial

Introduction

Here is the source code for co.edu.icesi.academ.client.perfiles.administrador.PanelEditarMateria.java

Source

/**
* Copyright  2013 Universidad Icesi
* 
* This file is part of ACADEM.
* 
* ACADEM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* ACADEM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with ACADEM.  If not, see <http://www.gnu.org/licenses/>.
**/

package co.edu.icesi.academ.client.perfiles.administrador;

import co.edu.icesi.academ.bo.BloqueBO;
import co.edu.icesi.academ.bo.MateriaBO;

import com.vaadin.annotations.AutoGenerated;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Notification;
import com.vaadin.ui.TextField;

public class PanelEditarMateria extends CustomComponent {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

    @AutoGenerated
    private AbsoluteLayout mainLayout;
    @AutoGenerated
    private TextField txt_nombre;
    @AutoGenerated
    private TextField txt_codigo;
    @AutoGenerated
    private Button btn_guardar;
    private static final long serialVersionUID = 1L;

    private MateriaBO materia;

    private BloqueBO bloqueBO;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     */
    public PanelEditarMateria(MateriaBO materiaBO, BloqueBO bloqueBO) {
        this.setMateria(materiaBO);
        buildMainLayout();
        setCompositionRoot(mainLayout);

        // TODO add user code here

        this.bloqueBO = bloqueBO;
        txt_codigo.setValue(materiaBO.getCodigo());
        txt_codigo.setEnabled(false);
        txt_nombre.setValue(materiaBO.getNombre());

        btn_guardar.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                Notification.show("listo pa guaradar :P");
                MateriaBO materiaBO = new MateriaBO();
                materiaBO.setCodigo(txt_codigo.getValue().toString());
                materiaBO.setNombre(txt_nombre.getValue().toString());
                ControladorAdministrador.getInstance().editarMateria(materiaBO);
                actualizaMateriasVistas();
                actualizaListaMaterias();
            }
        });

    }

    public void actualizaMateriasVistas() {
        ControladorAdministrador.getInstance().cargarMateriasBlqoue(bloqueBO);
    }

    public void actualizaListaMaterias() {
        ControladorAdministrador.getInstance().getAcademUI().cerrarVentanaEmergente();
        ControladorAdministrador.getInstance().mostrarPanelListaMateriasParaEditar(this.bloqueBO);
    }

    public MateriaBO getMateria() {
        return materia;
    }

    public void setMateria(MateriaBO materia) {
        this.materia = materia;
    }

    @AutoGenerated
    private AbsoluteLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new AbsoluteLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("340px");
        mainLayout.setHeight("180px");

        // top-level component properties
        setWidth("340px");
        setHeight("180px");

        // btn_guardar
        btn_guardar = new Button();
        btn_guardar.setCaption("Guardar");
        btn_guardar.setImmediate(true);
        btn_guardar.setWidth("220px");
        btn_guardar.setHeight("-1px");
        mainLayout.addComponent(btn_guardar, "top:120.0px;left:60.0px;");

        // txt_codigo
        txt_codigo = new TextField();
        txt_codigo.setStyleName("Cdigo");
        txt_codigo.setCaption("Cdigo");
        txt_codigo.setImmediate(false);
        txt_codigo.setWidth("220px");
        txt_codigo.setHeight("-1px");
        mainLayout.addComponent(txt_codigo, "top:36.0px;left:60.0px;");

        // txt_nombre
        txt_nombre = new TextField();
        txt_nombre.setCaption("Nombre");
        txt_nombre.setImmediate(false);
        txt_nombre.setWidth("220px");
        txt_nombre.setHeight("-1px");
        mainLayout.addComponent(txt_nombre, "top:80.0px;left:60.0px;");

        return mainLayout;
    }
}