List of usage examples for com.vaadin.ui Window setWidthUndefined
@Override public void setWidthUndefined()
From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java
License:Open Source License
public static Window showConfirmationPopup(String caption, Component content, String confirmCaption, String cancelCaption, Integer width, Consumer<Boolean> resultConsumer) { Window popupWindow = VaadinUiUtil.createPopupWindow(); if (width != null) { popupWindow.setWidth(width, Unit.PIXELS); } else {//from w ww . ja v a 2s. c o m popupWindow.setWidthUndefined(); } popupWindow.setCaption(caption); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); content.setWidth(100, Unit.PERCENTAGE); layout.addComponent(content); ConfirmationComponent confirmationComponent = new ConfirmationComponent(false) { private static final long serialVersionUID = 1L; @Override protected void onConfirm() { popupWindow.close(); resultConsumer.accept(true); } @Override protected void onCancel() { popupWindow.close(); resultConsumer.accept(false); } }; confirmationComponent.getConfirmButton().setCaption(confirmCaption); confirmationComponent.getCancelButton().setCaption(cancelCaption); popupWindow.addCloseListener(new CloseListener() { private static final long serialVersionUID = 1L; @Override public void windowClose(CloseEvent e) { confirmationComponent.getCancelButton().click(); } }); layout.addComponent(confirmationComponent); layout.setComponentAlignment(confirmationComponent, Alignment.BOTTOM_RIGHT); layout.setWidth(100, Unit.PERCENTAGE); layout.setSpacing(true); popupWindow.setContent(layout); UI.getCurrent().addWindow(popupWindow); return popupWindow; }