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.propietario; import java.util.List; import co.edu.icesi.academ.bo.CompetenciaBO; import co.edu.icesi.academ.bo.TemaBO; import com.sun.faces.facelets.tag.jsf.core.ValueChangeListenerHandler; import com.vaadin.annotations.AutoGenerated; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.ListSelect; import com.vaadin.ui.Button.ClickEvent; public class Competencias extends CustomComponent { /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */ /** * default serial version UID */ private static final long serialVersionUID = 1L; @AutoGenerated private AbsoluteLayout mainLayout; @AutoGenerated private ListSelect listSelect_1; @AutoGenerated private Button butEditarCompetencia; @AutoGenerated private Button butCrearCompetencia; /** * 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 Competencias() { buildMainLayout(); setCompositionRoot(mainLayout); // TODO add user code here butCrearCompetencia.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { crearCompetencia(); } }); butEditarCompetencia.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { editarCompetencia((CompetenciaBO) listSelect_1.getValue()); } }); } protected void editarCompetencia(CompetenciaBO value) { if (value != null) ControladorPropietario.getInstance().mostrarPanelCrearCompetencia(value); else ControladorPropietario.getInstance().getAcademUI().mostrarNotificacion("Error!", "Debe seleccionar una competencia"); } public void habilitarEditar() { butEditarCompetencia.setEnabled(true); } protected void crearCompetencia() { ControladorPropietario.getInstance().mostrarPanelCrearCompetencia(); } public void cargarCompetencias() { ControladorPropietario.getInstance().cargarCompentencias(); } public void refescarCompetencias(List<CompetenciaBO> competencias) { listSelect_1.removeAllItems(); for (CompetenciaBO competencia : competencias) { listSelect_1.addItem(competencia); } } @AutoGenerated private AbsoluteLayout buildMainLayout() { // common part: create layout mainLayout = new AbsoluteLayout(); mainLayout.setImmediate(false); mainLayout.setWidth("100%"); mainLayout.setHeight("100%"); // top-level component properties setWidth("100.0%"); setHeight("100.0%"); // butCrearCompetencia butCrearCompetencia = new Button(); butCrearCompetencia.setCaption("Crear Competencia"); butCrearCompetencia.setImmediate(false); butCrearCompetencia.setWidth("-1px"); butCrearCompetencia.setHeight("-1px"); mainLayout.addComponent(butCrearCompetencia, "top:40.0px;left:80.0px;"); // butEditarCompetencia butEditarCompetencia = new Button(); butEditarCompetencia.setCaption("Editar Competencia"); butEditarCompetencia.setImmediate(false); butEditarCompetencia.setWidth("-1px"); butEditarCompetencia.setHeight("-1px"); mainLayout.addComponent(butEditarCompetencia, "top:40.0px;left:240.0px;"); // listSelect_1 listSelect_1 = new ListSelect(); listSelect_1.setImmediate(false); listSelect_1.setWidth("500px"); listSelect_1.setHeight("200px"); mainLayout.addComponent(listSelect_1, "top:100.0px;left:80.0px;"); return mainLayout; } }