List of usage examples for com.vaadin.ui HorizontalLayout getWidth
@Override public float getWidth()
From source file:org.vaadin.addons.core.window.DialogWindow.java
License:Apache License
private VerticalLayout buildContent(String title, VaadinIcons type, Component content, ButtonType[] buttonTypes) {// ww w . j ava 2 s .c om VerticalLayout root = new VerticalLayout(); root.setMargin(false); root.setSpacing(false); float width = -1; float height = 0; if (title != null) { HorizontalLayout header = new HorizontalLayout(); header.setMargin(true); header.setHeightUndefined(); header.setWidth("100%"); header.addStyleName(ValoTheme.WINDOW_TOP_TOOLBAR); Label l = new Label("<font size=\"4\">" + title + "</font>", ContentMode.HTML); width = l.getWidth(); header.addComponent(l); header.setComponentAlignment(l, Alignment.MIDDLE_LEFT); if (type != null) { Label i = new Label(type.getHtml(), ContentMode.HTML); header.addComponent(i); header.setComponentAlignment(i, Alignment.MIDDLE_RIGHT); } height = header.getHeight(); root.addComponent(header); } if (content != null) { content.setSizeFull(); HorizontalLayout contentRoot = new HorizontalLayout(content); contentRoot.setMargin(true); root.addComponent(contentRoot); height = height + contentRoot.getHeight(); } HorizontalLayout footer = new HorizontalLayout(); footer.setHeightUndefined(); footer.setWidth("100%"); footer.setMargin(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); HorizontalLayout buttons = new HorizontalLayout(); if (buttonTypes != null) { Stream.of(buttonTypes).forEach(buttonType -> { Button b = new Button(buttonType.getCaption()); if (buttonType.getIcon() != null) { b.setIcon(buttonType.getIcon()); } if (buttonType.getDescription() != null) { b.setDescription(buttonType.getDescription()); } if (buttonType.getStyle() != null) { b.addStyleName(buttonType.getStyle()); } b.addClickListener(event -> buttonType.getActions().forEach(buttonAction -> { ButtonTypeClickEvent event1 = new ButtonTypeClickEvent(buttonType, DialogWindow.this); buttonAction.getListener().buttonClick(event1); })); buttons.addComponent(b); }); } buttons.setSizeUndefined(); buttons.setMargin(false); buttons.setSpacing(true); footer.addComponent(buttons); footer.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT); if (buttons.getWidth() > width) { width = buttons.getWidth(); } root.addComponent(footer); root.setComponentAlignment(footer, Alignment.BOTTOM_LEFT); height = height + footer.getHeight(); root.setHeight(height, Unit.PIXELS); root.setWidth(width, Unit.PIXELS); return root; }