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

Java tutorial

Introduction

Here is the source code for co.edu.icesi.academ.client.perfiles.administrador.PanelCrearBloque.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 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.TextField;

public class PanelCrearBloque extends CustomComponent {

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

    @AutoGenerated
    private AbsoluteLayout mainLayout;
    @AutoGenerated
    private TextField textNombreBloque;
    @AutoGenerated
    private Button btnCrearBloque;
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    /**
     * 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 PanelCrearBloque() {
        buildMainLayout();
        setCompositionRoot(mainLayout);

        // TODO add user code here

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

            @Override
            public void buttonClick(ClickEvent event) {
                crearBloque();
            }
        });
    }

    public void crearBloque() {
        if (textNombreBloque.getValue() != null && textNombreBloque.getValue() != "") {
            BloqueBO bloqueBO = new BloqueBO();
            bloqueBO.setNombre(textNombreBloque.getValue());
            ControladorAdministrador.getInstance().crearBloque(bloqueBO);
            ControladorAdministrador.getInstance().getAcademUI().cerrarVentanaEmergente();
        } else
            ControladorAdministrador.getInstance().getAcademUI().mostrarNotificacion("cuidado",
                    "Debe ingresar un nombre para bloque");
    }

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

        // top-level component properties
        setWidth("360px");
        setHeight("140px");

        // btnCrearBloque
        btnCrearBloque = new Button();
        btnCrearBloque.setCaption("Crear bloque");
        btnCrearBloque.setImmediate(true);
        btnCrearBloque.setWidth("238px");
        btnCrearBloque.setHeight("-1px");
        mainLayout.addComponent(btnCrearBloque, "top:80.0px;left:62.0px;");

        // textNombreBloque
        textNombreBloque = new TextField();
        textNombreBloque.setCaption("Nombre bloque");
        textNombreBloque.setImmediate(false);
        textNombreBloque.setWidth("100.0%");
        textNombreBloque.setHeight("-1px");
        mainLayout.addComponent(textNombreBloque, "top:40.0px;right:52.0px;left:60.0px;");

        return mainLayout;
    }

}