List of usage examples for com.vaadin.ui HorizontalLayout addComponent
@Override public void addComponent(Component c)
From source file:com.haulmont.cuba.web.LoginWindow.java
License:Apache License
protected HorizontalLayout createTitleLayout() { HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setStyleName("cuba-login-title"); titleLayout.setSpacing(true);//from w ww . j a v a 2s. c om Image logoImage = getLogoImage(); if (logoImage != null) { logoImage.setStyleName("cuba-login-icon"); titleLayout.addComponent(logoImage); titleLayout.setComponentAlignment(logoImage, Alignment.MIDDLE_LEFT); } String welcomeMsg = messages.getMainMessage("loginWindow.welcomeLabel", resolvedLocale); Label label = new Label(welcomeMsg.replace("\n", "<br/>")); label.setContentMode(ContentMode.HTML); label.setWidthUndefined(); label.setStyleName("cuba-login-caption"); if (!StringUtils.isBlank(label.getValue())) { titleLayout.addComponent(label); titleLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); } return titleLayout; }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaRowsCount.java
License:Apache License
public CubaRowsCount() { HorizontalLayout layout = new HorizontalLayout(); layout.setStyleName("c-paging"); layout.setSpacing(false);//from www . j ava 2s . c o m layout.setMargin(new MarginInfo(false, false, false, true)); setCompositionRoot(layout); CubaPlaceHolder expander = new CubaPlaceHolder(); expander.setWidth("100%"); layout.addComponent(expander); layout.setExpandRatio(expander, 1); AbstractOrderedLayout contentLayout = createContentLayout(); layout.addComponent(contentLayout); layout.setWidth("100%"); setWidth("100%"); }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaRowsCount.java
License:Apache License
protected AbstractOrderedLayout createContentLayout() { HorizontalLayout contentLayout = new HorizontalLayout(); contentLayout.setStyleName("c-paging-wrap"); contentLayout.setSpacing(true);// w w w . j a va2 s .c om firstButton = new CubaButton(); firstButton.setIcon(WebComponentsHelper.getIcon("icons/rows-count-first.png")); firstButton.setStyleName("c-paging-change-page"); firstButton.addStyleName("c-paging-first"); contentLayout.addComponent(firstButton); contentLayout.setComponentAlignment(firstButton, Alignment.MIDDLE_CENTER); prevButton = new CubaButton(); prevButton.setIcon(WebComponentsHelper.getIcon("icons/rows-count-prev.png")); prevButton.setStyleName("c-paging-change-page"); prevButton.addStyleName("c-paging-prev"); contentLayout.addComponent(prevButton); contentLayout.setComponentAlignment(prevButton, Alignment.MIDDLE_CENTER); label = new Label(); label.setWidthUndefined(); label.setStyleName("c-paging-status"); contentLayout.addComponent(label); contentLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); countButton = new CubaButton("[?]"); countButton.setWidthUndefined(); countButton.setStyleName(BaseTheme.BUTTON_LINK); countButton.addStyleName("c-paging-count"); countButton.setTabIndex(-1); contentLayout.addComponent(countButton); contentLayout.setComponentAlignment(countButton, Alignment.MIDDLE_CENTER); nextButton = new CubaButton(); nextButton.setIcon(WebComponentsHelper.getIcon("icons/rows-count-next.png")); nextButton.setStyleName("c-paging-change-page"); nextButton.addStyleName("c-paging-next"); contentLayout.addComponent(nextButton); contentLayout.setComponentAlignment(nextButton, Alignment.MIDDLE_CENTER); lastButton = new CubaButton(); lastButton.setIcon(WebComponentsHelper.getIcon("icons/rows-count-last.png")); lastButton.setStyleName("c-paging-change-page"); lastButton.addStyleName("c-paging-last"); contentLayout.addComponent(lastButton); contentLayout.setComponentAlignment(lastButton, Alignment.MIDDLE_CENTER); return contentLayout; }
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();/*w w w.j ava 2s. 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.haulmont.cuba.web.widgets.CubaRowsCount.java
License:Apache License
public CubaRowsCount() { HorizontalLayout layout = new HorizontalLayout(); // vaadin8 use CssLayout instead layout.setStyleName("c-paging"); layout.setSpacing(false);//from ww w . j av a 2 s.com layout.setMargin(new MarginInfo(false, false, false, true)); setCompositionRoot(layout); CubaPlaceHolder expander = new CubaPlaceHolder(); expander.setWidth("100%"); layout.addComponent(expander); layout.setExpandRatio(expander, 1); AbstractOrderedLayout contentLayout = createContentLayout(); layout.addComponent(contentLayout); layout.setWidth("100%"); setWidth("100%"); }
From source file:com.haulmont.cuba.web.widgets.CubaRowsCount.java
License:Apache License
protected AbstractOrderedLayout createContentLayout() { HorizontalLayout contentLayout = new HorizontalLayout(); // vaadin8 use CssLayout instead contentLayout.setStyleName("c-paging-wrap"); contentLayout.setSpacing(true);/*from w w w. ja v a2s. c o m*/ contentLayout.setMargin(false); firstButton = new CubaButton(); firstButton.setStyleName("c-paging-change-page"); firstButton.addStyleName("c-paging-first"); contentLayout.addComponent(firstButton); contentLayout.setComponentAlignment(firstButton, Alignment.MIDDLE_CENTER); prevButton = new CubaButton(); prevButton.setStyleName("c-paging-change-page"); prevButton.addStyleName("c-paging-prev"); contentLayout.addComponent(prevButton); contentLayout.setComponentAlignment(prevButton, Alignment.MIDDLE_CENTER); label = new Label(); label.setWidthUndefined(); label.setStyleName("c-paging-status"); contentLayout.addComponent(label); contentLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); countButton = new CubaButton("[?]"); countButton.setWidthUndefined(); countButton.setStyleName(ValoTheme.BUTTON_LINK); countButton.addStyleName("c-paging-count"); countButton.setTabIndex(-1); contentLayout.addComponent(countButton); contentLayout.setComponentAlignment(countButton, Alignment.MIDDLE_CENTER); nextButton = new CubaButton(); nextButton.setStyleName("c-paging-change-page"); nextButton.addStyleName("c-paging-next"); contentLayout.addComponent(nextButton); contentLayout.setComponentAlignment(nextButton, Alignment.MIDDLE_CENTER); lastButton = new CubaButton(); lastButton.setStyleName("c-paging-change-page"); lastButton.addStyleName("c-paging-last"); contentLayout.addComponent(lastButton); contentLayout.setComponentAlignment(lastButton, Alignment.MIDDLE_CENTER); return contentLayout; }
From source file:com.hivesys.dashboard.view.preferences.PreferencesView.java
License:Apache License
public PreferencesView() { user = (User) VaadinSession.getCurrent().getAttribute(User.class.getName()); setSpacing(true);/*from ww w. j a va 2 s .c o m*/ setMargin(true); Label title = new Label("Forms"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("800px"); form.addStyleName("light"); addComponent(form); Label section = new Label("Personal Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); firstNameField = new TextField("First Name"); firstNameField.setWidth("50%"); form.addComponent(firstNameField); lastNameField = new TextField("Last Name"); lastNameField.setWidth("50%"); form.addComponent(lastNameField); titleField = new ComboBox("Title"); titleField.setInputPrompt("Please specify"); titleField.addItem("Mr."); titleField.addItem("Mrs."); titleField.addItem("Ms."); titleField.setNewItemsAllowed(true); form.addComponent(titleField); usernameField = new TextField("Username"); usernameField.setRequired(true); form.addComponent(usernameField); sexField = new OptionGroup("Sex"); sexField.addItem(Boolean.FALSE); sexField.setItemCaption(Boolean.FALSE, "Female"); sexField.addItem(Boolean.TRUE); sexField.setItemCaption(Boolean.TRUE, "Male"); sexField.addStyleName("horizontal"); form.addComponent(sexField); section = new Label("Contact Info"); section.addStyleName("h3"); section.addStyleName("colored"); form.addComponent(section); emailField = new TextField("Email"); emailField.setWidth("50%"); emailField.setRequired(true); form.addComponent(emailField); locationField = new TextField("Location"); locationField.setWidth("50%"); locationField.setNullRepresentation(""); form.addComponent(locationField); phoneField = new TextField("Phone"); phoneField.setWidth("50%"); phoneField.setNullRepresentation(""); form.addComponent(phoneField); section = new Label("Additional Info"); section.addStyleName("h4"); section.addStyleName("colored"); form.addComponent(section); websiteField = new TextField("Website"); websiteField.setInputPrompt("http://"); websiteField.setWidth("100%"); form.addComponent(websiteField); bioField = new RichTextArea("Bio"); bioField.setWidth("100%"); bioField.setValue( "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>"); form.addComponent(bioField); Button edit = new Button("Edit", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { boolean readOnly = form.isReadOnly(); if (readOnly) { bioField.setReadOnly(false); form.setReadOnly(false); form.removeStyleName("light"); event.getButton().setCaption("Save"); event.getButton().addStyleName("primary"); } else { bioField.setReadOnly(true); form.setReadOnly(true); form.addStyleName("light"); event.getButton().setCaption("Edit"); event.getButton().removeStyleName("primary"); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); form.addComponent(footer); footer.addComponent(edit); Label lastModified = new Label("Last modified by you a minute ago"); lastModified.addStyleName("light"); footer.addComponent(lastModified); fieldGroup = new BeanFieldGroup<>(User.class); fieldGroup.bindMemberFields(this); fieldGroup.setItemDataSource(user); form.setReadOnly(true); bioField.setReadOnly(true); }
From source file:com.hris.payroll.alphalist.AlphaListMainUI.java
public AlphaListMainUI(int branchId) { this.branchId = branchId; setSizeFull();//ww w .j a v a 2 s . c o m setMargin(new MarginInfo(true, true, false, true)); setSpacing(true); HorizontalLayout h1 = new HorizontalLayout(); h1.setCaption("Year: "); h1.setWidthUndefined(); h1.setSpacing(true); h1.addComponent(employmentStatus); h1.addComponent(selectYear()); h1.addComponent(alphaListButton()); h1.addComponent(exportToExcelButton()); addComponent(h1); HorizontalLayout h2 = new HorizontalLayout(); h2.setWidthUndefined(); h2.setSpacing(true); progress.setWidth("410px"); h2.addComponent(progress); h2.setComponentAlignment(progress, Alignment.MIDDLE_LEFT); status.setValue("0%"); h2.addComponent(status); processLabel.setValue(""); h2.addComponent(processLabel); addComponent(h2); addComponent(grid); setExpandRatio(grid, 3); }
From source file:com.hris.payroll.reports.ReportUI.java
public ReportUI(int branchId) { this.branchId = branchId; setSizeFull();// w w w .j a va 2s . c om setMargin(new MarginInfo(true, true, false, true)); setSpacing(true); HorizontalLayout h1 = new HorizontalLayout(); h1.setWidthUndefined(); h1.setSpacing(true); h1.addComponent(reportType); h1.addComponent(payrollDateField()); h1.addComponent(viewReportBtn()); addComponent(h1); addComponent(grid); setExpandRatio(grid, 2); HorizontalLayout h2 = new HorizontalLayout(); h2.setWidthUndefined(); h2.setSpacing(true); }
From source file:com.hris.payroll.thirteenthmonth.ThirteenthMonth.java
public ThirteenthMonth(int branchId) { this.branchId = branchId; setSizeFull();/* ww w . jav a2 s . c o m*/ setMargin(new MarginInfo(true, true, false, true)); setSpacing(true); HorizontalLayout h1 = new HorizontalLayout(); h1.setWidthUndefined(); h1.setSpacing(true); h1.addComponent(employmentStatus); h1.addComponent(selectYear()); h1.addComponent(generate13thMonth()); h1.addComponent(exportToExcelButton()); addComponent(h1); HorizontalLayout h2 = new HorizontalLayout(); h2.setWidthUndefined(); h2.setSpacing(true); progress.setWidth("410px"); h2.addComponent(progress); h2.setComponentAlignment(progress, Alignment.MIDDLE_LEFT); status.setValue("0%"); h2.addComponent(status); grid = new ThirteenthMonthDataGridProperty(); addComponent(h2); addComponent(grid); setExpandRatio(grid, 3); }