List of usage examples for com.vaadin.ui VerticalLayout setExpandRatio
public void setExpandRatio(Component component, float ratio)
This method is used to control how excess space in layout is distributed among components.
From source file:com.haulmont.cuba.web.log.LogWindow.java
License:Apache License
private void initUI() { ClientConfig clientConfig = AppBeans.<Configuration>get(Configuration.NAME).getConfig(ClientConfig.class); String closeShortcut = clientConfig.getCloseShortcut(); KeyCombination closeCombination = KeyCombination.create(closeShortcut); com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction( "closeShortcutAction", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers())); addActionHandler(new com.vaadin.event.Action.Handler() { @Override/* ww w.j a va 2 s .c om*/ public com.vaadin.event.Action[] getActions(Object target, Object sender) { return new com.vaadin.event.Action[] { closeShortcutAction }; } @Override public void handleAction(com.vaadin.event.Action action, Object sender, Object target) { if (Objects.equals(action, closeShortcutAction)) { close(); } } }); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setSizeFull(); setContent(layout); Panel scrollablePanel = new Panel(); scrollablePanel.setSizeFull(); VerticalLayout scrollContent = new VerticalLayout(); scrollContent.setSizeUndefined(); scrollablePanel.setContent(scrollContent); final Label label = new Label(); label.setContentMode(ContentMode.HTML); label.setValue(writeLog()); label.setSizeUndefined(); label.setStyleName("c-log-content"); ((Layout) scrollablePanel.getContent()).addComponent(label); HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setWidth("100%"); topLayout.setHeightUndefined(); Messages messages = AppBeans.get(Messages.NAME); Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"), (Button.ClickListener) event -> label.setValue(writeLog())); topLayout.addComponent(refreshBtn); layout.addComponent(topLayout); layout.addComponent(scrollablePanel); layout.setExpandRatio(scrollablePanel, 1.0f); }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
@Override public void showOptionDialog(String title, String message, MessageType messageType, Action[] actions) { backgroundWorker.checkUIAccess();//from w ww . j a v a 2 s . c o m final com.vaadin.ui.Window window = new CubaWindow(title); if (ui.isTestMode()) { window.setCubaId("optionDialog"); window.setId(ui.getTestIdManager().getTestId("optionDialog")); } window.setClosable(false); Label messageLab = new CubaLabel(); messageLab.setValue(message); if (MessageType.isHTML(messageType)) { messageLab.setContentMode(ContentMode.HTML); } else { messageLab.setContentMode(ContentMode.TEXT); } if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { messageLab.setWidthUndefined(); } float width; SizeUnit unit; if (messageType.getWidth() != null) { width = messageType.getWidth(); unit = messageType.getWidthUnit(); } else if (getDialogParams().getWidth() != null) { width = getDialogParams().getWidth(); unit = getDialogParams().getWidthUnit(); } else { SizeWithUnit size = SizeWithUnit .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.optionDialog.width")); width = size.getSize(); unit = size.getUnit(); } if (messageType.getModal() != null) { log.warn("MessageType.modal is not supported for showOptionDialog"); } getDialogParams().reset(); window.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS); window.setResizable(false); window.setModal(true); boolean closeOnClickOutside = false; if (window.isModal()) { if (messageType.getCloseOnClickOutside() != null) { closeOnClickOutside = messageType.getCloseOnClickOutside(); } } ((CubaWindow) window).setCloseOnClickOutside(closeOnClickOutside); if (messageType.getMaximized() != null) { if (messageType.getMaximized()) { window.setWindowMode(WindowMode.MAXIMIZED); } else { window.setWindowMode(WindowMode.NORMAL); } } VerticalLayout layout = new VerticalLayout(); layout.setStyleName("c-app-option-dialog"); layout.setSpacing(true); if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { layout.setWidthUndefined(); } window.setContent(layout); HorizontalLayout buttonsContainer = new HorizontalLayout(); buttonsContainer.setSpacing(true); boolean hasPrimaryAction = false; Map<Action, Button> buttonMap = new HashMap<>(); for (Action action : actions) { Button button = WebComponentsHelper.createButton(); button.setCaption(action.getCaption()); button.addClickListener(event -> { try { action.actionPerform(null); } finally { ui.removeWindow(window); } }); if (StringUtils.isNotEmpty(action.getIcon())) { button.setIcon(WebComponentsHelper.getIcon(action.getIcon())); button.addStyleName(WebButton.ICON_STYLE); } if (action instanceof AbstractAction && ((AbstractAction) action).isPrimary()) { button.addStyleName("c-primary-action"); button.focus(); hasPrimaryAction = true; } if (ui.isTestMode()) { button.setCubaId("optionDialog_" + action.getId()); button.setId(ui.getTestIdManager().getTestId("optionDialog_" + action.getId())); } buttonsContainer.addComponent(button); buttonMap.put(action, button); } assignDialogShortcuts(buttonMap); if (!hasPrimaryAction && actions.length > 0) { ((Button) buttonsContainer.getComponent(0)).focus(); } layout.addComponent(messageLab); layout.addComponent(buttonsContainer); layout.setExpandRatio(messageLab, 1); layout.setComponentAlignment(buttonsContainer, Alignment.BOTTOM_RIGHT); ui.addWindow(window); window.center(); }
From source file:com.hris.employee.EmployeeUI.java
private VerticalLayout firstComponent() { employeeGridUI = new EmployeeGridUI(new EmployeeDataContainer()); VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setHeight("100%"); employeeStatus = employeeStatusComboBox(); employeeStatus.addValueChangeListener((Property.ValueChangeEvent event) -> { v.removeComponent(employeeGridUI); if (employeeStatus.getValue() == null) { if (getBranchId() == 0) { employeeGridUI = new EmployeeGridUI(new EmployeeDataContainer()); } else { employeeGridUI = new EmployeeGridUI( new EmployeeDataContainer(getBranchId(), (int) employeeStatus.getValue())); }//from w w w . ja va 2 s. co m } else { employeeGridUI = new EmployeeGridUI( new EmployeeDataContainer(getBranchId(), (int) employeeStatus.getValue())); } v.addComponent(employeeGridUI); v.setExpandRatio(employeeGridUI, 2); }); v.addComponent(employeeStatus); v.addComponent(employeeGridUI); v.setExpandRatio(employeeGridUI, 2); return v; }
From source file:com.hris.employee.EmployeeUI.java
private VerticalLayout firstComponent(int branchId) { employeeGridUI = new EmployeeGridUI(new EmployeeDataContainer(branchId)); VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setHeight("100%"); employeeStatus = employeeStatusComboBox(); employeeStatus.addValueChangeListener((Property.ValueChangeEvent event) -> { v.removeComponent(employeeGridUI); if (employeeStatus.getValue() == null) { employeeGridUI = new EmployeeGridUI(new EmployeeDataContainer(getBranchId())); } else {/*from www .j a v a2 s .c o m*/ employeeGridUI = new EmployeeGridUI( new EmployeeDataContainer(getBranchId(), (int) employeeStatus.getValue())); } v.addComponent(employeeGridUI); v.setExpandRatio(employeeGridUI, 2); }); v.addComponent(employeeStatus); v.addComponent(employeeGridUI); v.setExpandRatio(employeeGridUI, 2); return v; }
From source file:com.hris.payroll.reports.ReportViewer.java
public ReportViewer(String reportType, int branchId, Date payrollDate) { this.reportType = reportType; this.branchId = branchId; this.payrollDate = payrollDate; setWidth("900px"); setHeight("600px"); center();/*from w ww . j a va2s . c om*/ StreamResource resource = null; switch (reportType) { case "Payslip": { String filename = "Payslip-" + new Date().getTime() + ".pdf"; resource = new StreamResource(new PayslipReportPDF(getBranchId(), getPayrollDate()), filename); break; } case "Advances Summary": { String filename = "Advances-" + new Date().getTime() + ".pdf"; resource = new StreamResource(new AdvancesSummaryReportPdf(getBranchId(), getPayrollDate()), filename); break; } default: { String filename = "Advances-" + new Date().getTime() + ".pdf"; resource = new StreamResource(new AdvancesReportPdf(getBranchId(), getPayrollDate(), reportType), filename); break; } } resource.setMIMEType("application/pdf"); VerticalLayout v = new VerticalLayout(); v.setSizeFull(); v.setSpacing(true); v.setMargin(new MarginInfo(false, false, true, false)); Embedded em = new Embedded(); em.setSource(resource); em.setSizeFull(); em.setType(Embedded.TYPE_BROWSER); v.addComponent(em); v.setExpandRatio(em, 1); setContent(v); }
From source file:com.invient.vaadin.InvientChartsDemoWin.java
License:Apache License
public InvientChartsDemoWin() { VerticalLayout mainLayout = new VerticalLayout(); setContent(mainLayout);//from w ww . j av a 2 s. c om setSizeFull(); mainLayout.setSizeFull(); setCaption("Invient Charts"); HorizontalLayout infoBar = new HorizontalLayout(); mainLayout.addComponent(infoBar); infoBar.setHeight("50px"); infoBar.setWidth("100%"); Label lblAppTitle = new Label("Demo Gallery for Invient Charts"); lblAppTitle.setSizeFull(); lblAppTitle.setStyleName("v-label-app-title"); infoBar.addComponent(lblAppTitle); mainSplit = new HorizontalSplitPanel(); mainSplit.setSizeFull(); mainLayout.addComponent(mainSplit); mainLayout.setExpandRatio(mainSplit, 1); leftLayout = new VerticalLayout(); leftLayout.setSpacing(true); mainSplit.setFirstComponent(leftLayout); rightLayout = new VerticalLayout(); rightLayout.setSpacing(true); rightLayout.setMargin(true); mainSplit.setSecondComponent(rightLayout); mainSplit.setSplitPosition(200, Sizeable.UNITS_PIXELS); navTree = createChartsTree(); leftLayout.addComponent(navTree); eventLog.setReadOnly(true); eventLog.setStyleName("v-textarea-chart-events-log"); eventLog.setSizeFull(); eventLog.setHeight("200px"); setTheme("chartdemo"); }
From source file:com.jain.addon.action.confirm.ConfirmWindow.java
License:Apache License
@JNIComponentInit public void init() { setModal(true);// ww w . java2 s . c o m setWidth("25%"); VerticalLayout layout = new VerticalLayout(); setContent(layout); layout.setWidth("100%"); layout.setMargin(true); layout.setSpacing(true); layout.setStyleName(JNStyleConstants.J_ALTERNATE_VIEW); JNConfirm confirm = action.getConfirm(); HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSpacing(true); hLayout.setWidth("100%"); findNAddIcon(confirm, hLayout); Label label = new Label(confirm.message()); label.setContentMode(confirm.mode()); hLayout.addComponent(label); hLayout.setExpandRatio(label, 2); layout.addComponent(hLayout); layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER); ActionMenuBar<ConfirmWindow> menuBar = new ActionMenuBar<ConfirmWindow>(null, this); layout.addComponent(menuBar); layout.setExpandRatio(menuBar, 2); layout.setComponentAlignment(menuBar, Alignment.MIDDLE_CENTER); }
From source file:com.jain.addon.component.crud.JCrudWindow.java
License:Apache License
private void createActions(VerticalLayout layout) { if (!isViewOnly()) { ActionBar<JCrudWindow<T>> hLayout = new ActionBar<JCrudWindow<T>>(null, this); VerticalLayout vLayout = new VerticalLayout(); vLayout.setSizeUndefined();/*ww w . j a v a 2 s . co m*/ vLayout.setStyleName(JNStyleConstants.J_VIEW); vLayout.addComponent(hLayout); layout.addComponent(vLayout); layout.setComponentAlignment(vLayout, Alignment.MIDDLE_CENTER); layout.setExpandRatio(vLayout, 1); } }
From source file:com.jain.common.authenticate.LoginAction.java
License:Apache License
private void createActions(VerticalLayout layout) { ButtonSegment hLayout = new ButtonSegment(ApplicationTheme.FIRST, ApplicationTheme.LAST); hLayout.setStyleName(ApplicationTheme.HEADER_SEGMENT_SMALL); hLayout.createSegment(this, JAction.LOGIN, JAction.CANCEL); VerticalLayout vLayout = new VerticalLayout(); vLayout.setSizeUndefined();//from www . j ava2 s . c om vLayout.setStyleName(ApplicationTheme.VIEW); vLayout.addComponent(hLayout); layout.addComponent(vLayout); layout.setComponentAlignment(vLayout, Alignment.MIDDLE_CENTER); layout.setExpandRatio(vLayout, 1); }
From source file:com.jain.common.header.Header.java
License:Apache License
public void addDefaultTab() { findNCreateCurrentComponent();//from www. ja v a 2 s . c o m VerticalLayout contentLayout = (VerticalLayout) getUI().getContent(); contentLayout.setSpacing(false); contentLayout.setMargin(false); contentLayout.addComponent(currentComponent); contentLayout.setExpandRatio(currentComponent, 3); }