Java tutorial
/** * 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.ProgramaBO; 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.TextArea; import com.vaadin.ui.TextField; public class PanelCrearPrograma extends CustomComponent { /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */ @AutoGenerated private AbsoluteLayout mainLayout; @AutoGenerated private TextField txtCodigo; @AutoGenerated private TextArea txt_descripcion; @AutoGenerated private TextField txt_nombre; @AutoGenerated private Button btn_guardar; /** * */ 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 PanelCrearPrograma() { buildMainLayout(); setCompositionRoot(mainLayout); // TODO add user code here btn_guardar.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { String nombre = txt_nombre.getValue(); String descripcion = txt_descripcion.getValue(); int cod = Integer.parseInt(txtCodigo.getValue()); ProgramaBO prog = new ProgramaBO(); prog.setDescripcion(descripcion); prog.setCodigo(cod); prog.setNombre(nombre); ControladorAdministrador.getInstance().crearPrograma(prog); ControladorAdministrador.getInstance().cargarProgramas(); } }); } @AutoGenerated private AbsoluteLayout buildMainLayout() { // common part: create layout mainLayout = new AbsoluteLayout(); mainLayout.setImmediate(false); mainLayout.setWidth("440px"); mainLayout.setHeight("300px"); // top-level component properties setWidth("440px"); setHeight("300px"); // btn_guardar btn_guardar = new Button(); btn_guardar.setCaption("Guardar"); btn_guardar.setImmediate(true); btn_guardar.setWidth("320px"); btn_guardar.setHeight("-1px"); mainLayout.addComponent(btn_guardar, "top:240.0px;left:60.0px;"); // txt_nombre txt_nombre = new TextField(); txt_nombre.setCaption("Nombre"); txt_nombre.setImmediate(false); txt_nombre.setWidth("320px"); txt_nombre.setHeight("-1px"); mainLayout.addComponent(txt_nombre, "top:40.0px;left:60.0px;"); // txt_descripcion txt_descripcion = new TextArea(); txt_descripcion.setCaption("Descripcin"); txt_descripcion.setImmediate(false); txt_descripcion.setWidth("320px"); txt_descripcion.setHeight("108px"); mainLayout.addComponent(txt_descripcion, "top:120.0px;right:60.0px;"); // txtCodigo txtCodigo = new TextField(); txtCodigo.setCaption("Cdigo"); txtCodigo.setImmediate(false); txtCodigo.setWidth("320px"); txtCodigo.setHeight("-1px"); mainLayout.addComponent(txtCodigo, "top:80.0px;left:60.0px;"); return mainLayout; } }