List of usage examples for com.vaadin.ui VerticalLayout setHeight
@Override public void setHeight(String height)
From source file:com.foc.vaadin.FocWebApplication.java
License:Apache License
protected void init2(VaadinRequest request) { // Create the footer Layout with a simple Label VerticalLayout footerLayout = new VerticalLayout(); {/*w w w. ja v a2s .c om*/ footerLayout.addComponent(new Label("This is the footer always visible")); footerLayout.setHeight("-1px"); } // Create the Body Panel that contains a VerticalLayout itself Panel panel = new Panel(); { panel.setSizeFull();// Panel size is undefined final VerticalLayout panelLayout = new VerticalLayout(); panelLayout.setSizeUndefined();// Panel Layout size is undefined panel.setContent(panelLayout); // Fill the panel layout with lots of labels to exceed the window height for (int i = 0; i < 200; i++) { panelLayout.addComponent(new Label("Thank you for clicking")); } } // Put all in the the MainVerticalLayout final VerticalLayout mainVerticalLayout = new VerticalLayout(); mainVerticalLayout.setSizeFull();// Main Layout is set to size Full so that it fills all the height mainVerticalLayout.addComponent(panel); mainVerticalLayout.addComponent(footerLayout); mainVerticalLayout.setExpandRatio(panel, 1); setContent(mainVerticalLayout); }
From source file:com.freebox.engeneering.application.web.layout.LeftSideBarController.java
License:Apache License
/** * Initializes view when system enters 'initView' action state. * * @param event - state event./*ww w . j av a 2 s . c om*/ */ public void initView(@SuppressWarnings("rawtypes") StateEvent event) { final VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.addStyleName("sidebar"); verticalLayout.setWidth("100%"); verticalLayout.setHeight("100%"); setView(verticalLayout); }
From source file:com.haulmont.cuba.web.LoginWindow.java
License:Apache License
protected VerticalLayout createCenterLayout(int formWidth, int formHeight, int fieldWidth, boolean localesSelectVisible) { VerticalLayout centerLayout = new VerticalLayout(); centerLayout.setStyleName("cuba-login-bottom"); centerLayout.setWidth(formWidth + "px"); centerLayout.setHeight(formHeight + "px"); HorizontalLayout titleLayout = createTitleLayout(); centerLayout.addComponent(titleLayout); centerLayout.setComponentAlignment(titleLayout, Alignment.MIDDLE_CENTER); FormLayout loginFormLayout = createLoginFormLayout(fieldWidth, localesSelectVisible); centerLayout.addComponent(loginFormLayout); centerLayout.setComponentAlignment(loginFormLayout, Alignment.MIDDLE_CENTER); return centerLayout; }
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 ww w . j av a 2s .c o 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 ww w. ja va 2s . c om 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.jain.common.approot.ApplicationUI.java
License:Apache License
public void initialize(Locale locale) { user.setLocale(locale);//from w ww. j a v a 2 s . c om addApplicationTitle(); VerticalLayout view = new VerticalLayout(); setContent(view); view.setStyleName(ApplicationTheme.VIEW); view.setWidth("100%"); view.setHeight("100%"); view.setSpacing(false); view.setMargin(false); createWelcomebar(view); Header header = CDIComponent.getInstance(Header.class); view.addComponent(header); header.addDefaultTab(); }
From source file:com.logicbomb.newschool.MyAppWidgetSet.core.UserDetailsWidget.java
public UserDetailsWidget() { HorizontalLayout h = new HorizontalLayout(); addComponent(h);/*from w w w . j a v a 2 s .com*/ h.setSizeFull(); //h.setSpacing(true); Button userPhoto = new Button(); userPhoto.setIcon(FontAwesome.USER); userPhoto.setHeight("100px"); userPhoto.setWidth("100px"); h.addComponent(userPhoto); //h.setComponentAlignment(userPhoto, Alignment.TOP_LEFT); VerticalLayout v = new VerticalLayout(); //v.setStyleName("backColorBlack"); h.addComponent(v); v.setStyleName("v-layout-padding-left"); //h.setComponentAlignment(userPhoto, Alignment.TOP_RIGHT); v.setHeight("106px"); v.setWidth("100px"); // v.setComponentAlignment(userStatus, Alignment.MIDDLE_CENTER); Button editProfile = new Button("Profile"); editProfile.setStyleName("v-button-type3"); editProfile.setIcon(FontAwesome.USER); editProfile.setWidth("100px"); editProfile.setWidth("102px"); v.addComponent(editProfile); //v.setComponentAlignment(editProfile, Alignment.TOP_LEFT); Button settings = new Button("Settings"); settings.setStyleName("v-button-type3"); settings.setIcon(FontAwesome.WRENCH); settings.setWidth("100px"); settings.setWidth("102px"); v.addComponent(settings); //v.setComponentAlignment(editProfile, Alignment.MIDDLE_RIGHT); Button logOut = new Button("Log Out"); logOut.setStyleName("v-button-type3"); logOut.setIcon(FontAwesome.KEY); logOut.setWidth("100px"); logOut.setWidth("102px"); v.addComponent(logOut); //v.setComponentAlignment(editProfile, Alignment.BOTTOM_RIGHT); //v.setComponentAlignment(userStatus, Alignment.MIDDLE_CENTER); }
From source file:com.mcparland.john.vaadin_mvn_arch.samples.crud.ProductForm.java
License:Apache License
public ProductForm(SampleCrudLogic sampleCrudLogic) { viewLogic = sampleCrudLogic;/*from ww w.ja v a 2 s . c om*/ addStyleName("product-form-wrapper"); setId("product-form"); productName.setWidth("100%"); price.setConverter(new EuroConverter()); stockCount.setWidth("80px"); availability.setNullSelectionAllowed(false); availability.setTextInputAllowed(false); for (Availability s : Availability.values()) { availability.addItem(s); } category.setWidth("100%"); saveButton.addStyleName(ValoTheme.BUTTON_PRIMARY); cancelButton.addStyleName("cancel"); removeButton.addStyleName(ValoTheme.BUTTON_DANGER); VerticalLayout layout = new VerticalLayout(); layout.setHeight("100%"); layout.setSpacing(true); layout.addStyleName("form-layout"); HorizontalLayout priceAndStock = new HorizontalLayout(price, stockCount); priceAndStock.setSpacing(true); priceAndStock.setWidth("100%"); price.setWidth("100%"); stockCount.setWidth("100%"); availability.setWidth("100%"); layout.addComponent(productName); layout.addComponent(priceAndStock); layout.addComponent(availability); layout.addComponent(category); CssLayout expander = new CssLayout(); expander.addStyleName("expander"); layout.addComponent(expander); layout.setExpandRatio(expander, 1); layout.addComponent(saveButton); layout.addComponent(cancelButton); layout.addComponent(removeButton); addComponent(layout); fieldGroup = new BeanFieldGroup<Product>(Product.class); fieldGroup.bindMemberFields(this); // perform validation and enable/disable buttons while editing ValueChangeListener valueListener = new ValueChangeListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { formHasChanged(); } }; for (Field<?> f : fieldGroup.getFields()) { f.addValueChangeListener(valueListener); } fieldGroup.addCommitHandler(new CommitHandler() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void preCommit(CommitEvent commitEvent) throws CommitException { } @Override public void postCommit(CommitEvent commitEvent) throws CommitException { DataService.get().updateProduct(fieldGroup.getItemDataSource().getBean()); } }); saveButton.addClickListener(new ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { try { fieldGroup.commit(); // only if validation succeeds Product product = fieldGroup.getItemDataSource().getBean(); viewLogic.saveProduct(product); } catch (CommitException e) { Notification n = new Notification("Please re-check the fields", Type.ERROR_MESSAGE); n.setDelayMsec(500); n.show(getUI().getPage()); } } }); cancelButton.setClickShortcut(KeyCode.ESCAPE); cancelButton.addClickListener(new ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { viewLogic.cancelProduct(); } }); removeButton.addClickListener(new ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { Product product = fieldGroup.getItemDataSource().getBean(); viewLogic.deleteProduct(product); } }); }
From source file:com.mycollab.module.user.accountsettings.customize.view.LogoEditWindow.java
License:Open Source License
private void editPhoto(byte[] imageData) { try {/* w ww.j a v a 2s .c om*/ originalImage = ImageIO.read(new ByteArrayInputStream(imageData)); } catch (IOException e) { throw new UserInvalidInputException("Invalid image type"); } originalImage = ImageUtil.scaleImage(originalImage, 650, 650); MHorizontalLayout previewBox = new MHorizontalLayout().withMargin(new MarginInfo(false, true, true, false)) .withFullWidth(); final String logoPath = MyCollabUI.getBillingAccount().getLogopath(); Resource defaultPhoto = AccountAssetsResolver.createLogoResource(logoPath, 150); previewImage = new Embedded(null, defaultPhoto); previewImage.setWidth("100px"); previewBox.addComponent(previewImage); previewBox.setComponentAlignment(previewImage, Alignment.TOP_LEFT); MVerticalLayout previewBoxRight = new MVerticalLayout().withSpacing(false) .withMargin(new MarginInfo(false, true, false, true)); previewBoxRight .addComponent(ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_IMAGE_EDIT_INSTRUCTION))); MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> EventBusFactory.getInstance() .post(new SettingEvent.GotoGeneralSetting(LogoEditWindow.this, null))) .withStyleName(WebThemes.BUTTON_OPTION); MButton acceptBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), clickEvent -> { if (scaleImageData != null && scaleImageData.length > 0) { try { BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData)); AccountLogoService accountLogoService = AppContextUtil.getSpringBean(AccountLogoService.class); accountLogoService.upload(UserUIContext.getUsername(), image, MyCollabUI.getAccountId()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } catch (IOException e) { throw new MyCollabException("Error when saving account logo", e); } } }).withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.SAVE) .withClickShortcut(ShortcutAction.KeyCode.ENTER); MHorizontalLayout controlBtns = new MHorizontalLayout(acceptBtn, cancelBtn); previewBoxRight.with(controlBtns).withAlign(controlBtns, Alignment.TOP_LEFT); previewBox.with(previewBoxRight).expand(previewBoxRight); content.addComponent(previewBox); CssLayout cropBox = new CssLayout(); cropBox.setWidth("100%"); VerticalLayout currentPhotoBox = new VerticalLayout(); Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage), "image/png"); CropField cropField = new CropField(resource); cropField.setImmediate(true); cropField.setSelectionAspectRatio(150 / 28); cropField.addValueChangeListener(valueChangeEvent -> { VCropSelection newSelection = (VCropSelection) valueChangeEvent.getProperty().getValue(); int x1 = newSelection.getXTopLeft(); int y1 = newSelection.getYTopLeft(); int x2 = newSelection.getXBottomRight(); int y2 = newSelection.getYBottomRight(); if (x2 > x1 && y2 > y1) { BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1)); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { ImageIO.write(subImage, "png", outStream); scaleImageData = outStream.toByteArray(); displayPreviewImage(); } catch (IOException e) { LOG.error("Error while scale image: ", e); } } }); currentPhotoBox.setWidth("650px"); currentPhotoBox.setHeight("650px"); currentPhotoBox.addComponent(cropField); cropBox.addComponent(currentPhotoBox); content.with(previewBox, ELabel.hr(), cropBox); }
From source file:com.mycollab.module.user.ui.components.ImagePreviewCropWindow.java
License:Open Source License
public ImagePreviewCropWindow(final ImageSelectionCommand imageSelectionCommand, final byte[] imageData) { super(UserUIContext.getMessage(ShellI18nEnum.OPT_PREVIEW_EDIT_IMAGE)); MVerticalLayout content = new MVerticalLayout(); withModal(true).withResizable(false).withWidth("700px").withCenter().withContent(content); try {//from w w w .j a va2s .c om originalImage = ImageIO.read(new ByteArrayInputStream(imageData)); } catch (IOException e) { throw new UserInvalidInputException("Invalid image type"); } originalImage = ImageUtil.scaleImage(originalImage, 650, 650); MHorizontalLayout previewBox = new MHorizontalLayout().withMargin(new MarginInfo(false, true, true, false)) .withFullWidth(); previewPhoto = new VerticalLayout(); previewPhoto.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); previewPhoto.setWidth("100px"); previewBox.with(previewPhoto).withAlign(previewPhoto, Alignment.TOP_LEFT); VerticalLayout previewBoxTitle = new VerticalLayout(); previewBoxTitle.setMargin(new MarginInfo(false, true, false, true)); previewBoxTitle .addComponent(ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_IMAGE_EDIT_INSTRUCTION))); MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION); MButton acceptBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), clickEvent -> { if (scaleImageData != null && scaleImageData.length > 0) { try { BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData)); imageSelectionCommand.process(image); close(); } catch (IOException e) { throw new MyCollabException("Error when saving user avatar", e); } } }).withIcon(FontAwesome.CHECK).withStyleName(WebThemes.BUTTON_ACTION); MHorizontalLayout controlBtns = new MHorizontalLayout(acceptBtn, cancelBtn); previewBoxTitle.addComponent(controlBtns); previewBoxTitle.setComponentAlignment(controlBtns, Alignment.TOP_LEFT); previewBox.with(previewBoxTitle).expand(previewBoxTitle); CssLayout cropBox = new CssLayout(); cropBox.setWidth("100%"); VerticalLayout currentPhotoBox = new VerticalLayout(); Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage), "image/png"); CropField cropField = new CropField(resource); cropField.setImmediate(true); cropField.setSelectionAspectRatio(1.0f); cropField.addValueChangeListener(valueChangeEvent -> { VCropSelection newSelection = (VCropSelection) valueChangeEvent.getProperty().getValue(); int x1 = newSelection.getXTopLeft(); int y1 = newSelection.getYTopLeft(); int x2 = newSelection.getXBottomRight(); int y2 = newSelection.getYBottomRight(); if (x2 > x1 && y2 > y1) { BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1)); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { ImageIO.write(subImage, "png", outStream); scaleImageData = outStream.toByteArray(); displayPreviewImage(); } catch (IOException e) { LOG.error("Error while scale image: ", e); } } }); currentPhotoBox.setWidth("520px"); currentPhotoBox.setHeight("470px"); currentPhotoBox.addComponent(cropField); cropBox.addComponent(currentPhotoBox); content.with(previewBox, ELabel.hr(), cropBox); displayPreviewImage(); }