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.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 PanelEditarBloque extends CustomComponent { /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */ @AutoGenerated private AbsoluteLayout mainLayout; @AutoGenerated private Button btn_guardar; @AutoGenerated private TextField textField_1; private BloqueBO bloqueBO; /** * */ 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 PanelEditarBloque(final BloqueBO bloqueBO) { buildMainLayout(); setCompositionRoot(mainLayout); // TODO add user code here this.setBloqueBO(bloqueBO); this.textField_1.setValue(bloqueBO.getNombre()); btn_guardar.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (textField_1.getValue().toString() != null && textField_1.getValue().toString() != "") { BloqueBO bo = new BloqueBO(); bo.setNombre(textField_1.getValue()); ControladorAdministrador.getInstance().editarBloque(bloqueBO, bo.getNombre()); ControladorAdministrador.getInstance().getAcademUI().cerrarVentanaEmergente(); ControladorAdministrador.getInstance().cargarBloques(); } else ControladorAdministrador.getInstance().getAcademUI().mostrarNotificacion("Cuidado", "debe ingresar un nombre para el bloque"); } }); } public BloqueBO getBloqueBO() { return bloqueBO; } public void setBloqueBO(BloqueBO bloqueBO) { this.bloqueBO = bloqueBO; } @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"); // textField_1 textField_1 = new TextField(); textField_1.setCaption("Nombre"); textField_1.setImmediate(false); textField_1.setWidth("241px"); textField_1.setHeight("-1px"); mainLayout.addComponent(textField_1, "top:40.0px;left:60.0px;"); // btn_guardar btn_guardar = new Button(); btn_guardar.setCaption("guardar"); btn_guardar.setImmediate(true); btn_guardar.setWidth("240px"); btn_guardar.setHeight("-1px"); mainLayout.addComponent(btn_guardar, "top:80.0px;left:60.0px;"); return mainLayout; } }