Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.save.client.promodeals; import com.vaadin.server.FontAwesome; import com.vaadin.shared.ui.MarginInfo; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.themes.ValoTheme; /** * * @author jetdario */ public class PromoUI extends VerticalLayout { private int clientId; public PromoUI(int clientId) { this.clientId = clientId; setWidth("90%"); setHeight("100%"); setMargin(new MarginInfo(true, true, false, false)); PDDataGridProperties dataGrid = new PDDataGridProperties(getClientId()); Button button = new Button("Acknowledgement Form"); button.setWidthUndefined(); button.setIcon(FontAwesome.OPENID); button.addStyleName(ValoTheme.BUTTON_LINK); button.addStyleName(ValoTheme.BUTTON_SMALL); button.addClickListener((Button.ClickEvent event) -> { Window sub = new com.save.clients.AcknowledgementPromoForm(getClientId()); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub); } sub.addCloseListener((Window.CloseEvent e) -> { dataGrid.getContainerDataSource().removeAllItems(); dataGrid.setContainerDataSource(new PDDataContainer(getClientId())); }); }); addComponent(button); setComponentAlignment(button, Alignment.TOP_RIGHT); addComponent(dataGrid); setExpandRatio(dataGrid, 2); } private int getClientId() { return clientId; } }