Java tutorial
/* * Copyright (C) 2013 ernst_sgv * * This program 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. * * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */ package net.gvcc.jgoffice.wgsys.roles; import com.vaadin.addon.jpacontainer.JPAContainer; import com.vaadin.addon.jpacontainer.JPAContainerFactory; import com.vaadin.data.fieldgroup.FieldGroup; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; import com.vaadin.ui.Field; import com.vaadin.ui.FormLayout; import com.vaadin.ui.TextField; import net.gvcc.jgoffice.dbnavigatorbar.NavigatorButtons; import net.gvcc.jgoffice.dbnavigatorbar.interfaces.IDBNavigatorForm; import net.gvcc.jgoffice.templates.SingleForm; import net.gvcc.jgoffice.templates.interfaces.IGlobalConst; import static net.gvcc.jgoffice.templates.interfaces.IGlobalConst.PG_PERSISTENCE_NAME; import net.gvcc.wgsys.dao.entities.WgTSyRoles; /** * * @author ernst_sgv */ public class RoleForm extends SingleForm implements View, IGlobalConst, IDBNavigatorForm { public final static String VIEW_NAME = "ROLE"; private Field<String> roleDescDE; private Field<String> roleDescIT; /* * JPAContainer for the master */ private final JPAContainer<WgTSyRoles> masterContainer = JPAContainerFactory.make(WgTSyRoles.class, PG_PERSISTENCE_NAME); private final FieldGroup masterFormFieldGroup = new FieldGroup( masterContainer.getItem(masterContainer.firstItemId())); public RoleForm() { setMainForm(new MainForm()); mainFormHasNavigationBar(true); initializeForm(); } @Override public void enter(ViewChangeListener.ViewChangeEvent event) { } @Override public void handleButtonEvents(NavigatorButtons button) { } @Override public void detach() { super.detach(); //To change body of generated methods, choose Tools | Templates. } @Override public void attach() { super.attach(); //To change body of generated methods, choose Tools | Templates. } private class MainForm extends FormLayout { public MainForm() { roleDescDE = masterFormFieldGroup.buildAndBind("Beschreibung:", "roleDescDe", TextField.class); roleDescIT = masterFormFieldGroup.buildAndBind("Lastname:", "roleDescIt", TextField.class); this.addComponent(roleDescDE); this.addComponent(roleDescIT); roleDescDE.setWidth("100%"); roleDescIT.setWidth("100%"); getNavigationBar().setDatasource(masterContainer, masterFormFieldGroup); } } }