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.mcparland.john.vaadin_mvn_arch.samples.crud.ProductForm.java
License:Apache License
public ProductForm(SampleCrudLogic sampleCrudLogic) { viewLogic = sampleCrudLogic;/* w w 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.mcparland.john.vaadin_mvn_arch.samples.crud.SampleCrudView.java
License:Apache License
public SampleCrudView() { setSizeFull();/*from ww w. j a va 2 s. c o m*/ addStyleName("crud-view"); HorizontalLayout topLayout = createTopBar(); table = new ProductTable(); table.addValueChangeListener(new ValueChangeListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { viewLogic.rowSelected(table.getValue()); } }); form = new ProductForm(viewLogic); form.setCategories(DataService.get().getAllCategories()); VerticalLayout barAndTableLayout = new VerticalLayout(); barAndTableLayout.addComponent(topLayout); barAndTableLayout.addComponent(table); barAndTableLayout.setMargin(true); barAndTableLayout.setSpacing(true); barAndTableLayout.setSizeFull(); barAndTableLayout.setExpandRatio(table, 1); barAndTableLayout.setStyleName("crud-main-layout"); addComponent(barAndTableLayout); addComponent(form); viewLogic.init(); }
From source file:com.mechanicshop.components.MaintenanceLayout.java
private void buildLayout() { HorizontalLayout layoutTitle = new HorizontalLayout(); layoutTitle.setSizeUndefined();// w w w . ja va 2s .c o m layoutTitle.setWidth("100%"); layoutTitle.setSpacing(false); layoutTitle.setMargin(false); titleLabel.addStyleName(ValoTheme.LABEL_H2); titleLabel.addStyleName(ValoTheme.LABEL_COLORED); titleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN); titleLabel.addStyleName(ValoTheme.LABEL_BOLD); titleLabel.setSizeUndefined(); layoutTitle.addComponent(titleLabel); layoutTitle.setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER); VerticalLayout layoutTable = new VerticalLayout(); layoutTable.setSizeFull(); layoutTable.setSpacing(true); HorizontalLayout layoutButtons = new HorizontalLayout(); layoutButtons.setMargin(false); layoutButtons.setSpacing(true); layoutButtons.setSizeUndefined(); Button passwordBtn = new Button("Edit Password"); passwordBtn.addClickListener(passwordListener); passwordBtn.setImmediate(true); passwordBtn.setIcon(FontAwesome.EDIT); passwordBtn.setStyleName(ValoTheme.BUTTON_TINY); Button media1Btn = new Button("Media 1 Default Text"); media1Btn.setStyleName(ValoTheme.BUTTON_TINY); media1Btn.setImmediate(true); media1Btn.setIcon(FontAwesome.EDIT); media1Btn.addClickListener(media1Listener); Button media2Btn = new Button("Media 2 Default Text"); media2Btn.setStyleName(ValoTheme.BUTTON_TINY); media2Btn.setImmediate(true); media2Btn.setIcon(FontAwesome.EDIT); media2Btn.addClickListener(media2Listener); layoutButtons.addComponents(passwordBtn, media1Btn, media2Btn); layoutButtons.setComponentAlignment(passwordBtn, Alignment.MIDDLE_LEFT); layoutButtons.setComponentAlignment(media1Btn, Alignment.MIDDLE_LEFT); layoutButtons.setComponentAlignment(media2Btn, Alignment.MIDDLE_LEFT); addComponent(layoutTitle); addComponent(layoutTable); layoutTable.addComponent(layoutButtons); layoutTable.addComponent(table); layoutTable.setComponentAlignment(table, Alignment.TOP_CENTER); layoutTable.setExpandRatio(table, 3); setComponentAlignment(layoutTitle, Alignment.TOP_CENTER); setComponentAlignment(layoutTable, Alignment.TOP_CENTER); setExpandRatio(layoutTable, 3); setSpacing(true); setMargin(true); }
From source file:com.mechanicshop.components.TableLayout.java
private void buildLayout() { HorizontalLayout layoutTitle = new HorizontalLayout(); layoutTitle.setSizeUndefined();// ww w . jav a 2 s . c om layoutTitle.setWidth("100%"); layoutTitle.setSpacing(false); layoutTitle.setMargin(false); titleLabel.addStyleName(ValoTheme.LABEL_H2); titleLabel.addStyleName(ValoTheme.LABEL_COLORED); titleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN); titleLabel.addStyleName(ValoTheme.LABEL_BOLD); titleLabel.setSizeUndefined(); layoutTitle.addComponent(titleLabel); layoutTitle.setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER); VerticalLayout layoutTable = new VerticalLayout(); layoutTable.addComponent(table); layoutTable.setComponentAlignment(table, Alignment.TOP_CENTER); layoutTable.setSizeFull(); layoutTable.setSpacing(true); HorizontalLayout layoutButtons = new HorizontalLayout(); layoutButtons.setMargin(false); layoutButtons.setSpacing(true); layoutButtons.setSizeUndefined(); layoutButtons.setWidth("100%"); Button addBtn = new Button("Add new Car"); addBtn.addClickListener(addBtnListener); addBtn.setImmediate(true); addBtn.setStyleName(ValoTheme.BUTTON_TINY); addBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY); Button deleteBtn = new Button("Delete Selected"); deleteBtn.setStyleName(ValoTheme.BUTTON_TINY); deleteBtn.addStyleName(ValoTheme.BUTTON_DANGER); deleteBtn.setImmediate(true); deleteBtn.addClickListener(removeListener); btnSendSMS.setStyleName(ValoTheme.BUTTON_TINY); btnSendSMS.addStyleName(ValoTheme.BUTTON_FRIENDLY); btnSendSMS.setImmediate(true); btnSendSMS.addClickListener(sendSMSBtnListener); searchTextField.setImmediate(true); searchTextField.addStyleName(ValoTheme.TEXTFIELD_TINY); searchTextField.addTextChangeListener(filterChangeListener); Label lbSearch = new Label("Search"); lbSearch.addStyleName(ValoTheme.LABEL_TINY); lbSearch.setSizeUndefined(); layoutButtons.addComponents(lbSearch, searchTextField, addBtn, deleteBtn, btnSendSMS); layoutButtons.setComponentAlignment(lbSearch, Alignment.MIDDLE_LEFT); layoutButtons.setComponentAlignment(searchTextField, Alignment.BOTTOM_LEFT); layoutButtons.setComponentAlignment(addBtn, Alignment.BOTTOM_RIGHT); layoutButtons.setComponentAlignment(deleteBtn, Alignment.BOTTOM_RIGHT); layoutButtons.setComponentAlignment(btnSendSMS, Alignment.BOTTOM_RIGHT); layoutButtons.setExpandRatio(addBtn, 3); addComponent(layoutTitle); addComponent(layoutTable); layoutTable.addComponent(layoutButtons); layoutTable.setExpandRatio(table, 3); setComponentAlignment(layoutTitle, Alignment.TOP_CENTER); setComponentAlignment(layoutTable, Alignment.TOP_CENTER); setExpandRatio(layoutTable, 3); setSpacing(true); setMargin(true); }
From source file:com.mechanicshop.components.TableLayout.java
public void createCustomMessage() { final TextArea textArea = new TextArea(); textArea.setImmediate(true);/* www .ja v a 2 s . c om*/ textArea.setColumns(30); textArea.setRows(10); textArea.addStyleName(ValoTheme.TEXTAREA_SMALL); textArea.setRequired(true); final Window subWindow = new Window(); subWindow.setModal(true); subWindow.setHeight("350px"); subWindow.setWidth("500px"); subWindow.setCaption("Insert Message"); subWindow.setStyleName(ValoTheme.WINDOW_TOP_TOOLBAR); subWindow.setClosable(false); subWindow.setResizable(false); HorizontalLayout layoutButtons = new HorizontalLayout(); layoutButtons.setMargin(false); Button sendBtn = new Button("Send"); sendBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { textArea.validate(); String message = textArea.getValue(); smsSenderService.sendMessageMassive(message); subWindow.close(); Notification.show("Message Sent"); } catch (Exception e) { } } }); sendBtn.setImmediate(true); sendBtn.setStyleName(ValoTheme.BUTTON_TINY); sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY); Button cancelBtn = new Button("Cancel"); cancelBtn.setStyleName(ValoTheme.BUTTON_TINY); cancelBtn.addStyleName(ValoTheme.BUTTON_DANGER); cancelBtn.setImmediate(true); cancelBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { subWindow.close(); } }); layoutButtons.setSizeUndefined(); layoutButtons.setSpacing(true); layoutButtons.addComponents(cancelBtn, sendBtn); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); layout.addComponent(textArea); layout.addComponent(layoutButtons); layout.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(textArea, 3); layout.setSizeFull(); subWindow.setContent(layout); subWindow.center(); getUI().addWindow(subWindow); }
From source file:com.mic.springvaadin.ui.AspectJManagedUI.java
License:Apache License
@Override protected void init(VaadinRequest vaadinRequest) { VerticalLayout layout = new VerticalLayout(); layout.setSizeFull();// ww w .j av a 2s . c om layout.setSpacing(true); layout.setMargin(true); defaultLabel = new Label("Default View 1"); defaultLabel.setImmediate(true); layout.addComponent(defaultLabel); viewContainer = new Panel(); viewContainer.setSizeFull(); layout.addComponent(viewContainer); layout.setExpandRatio(viewContainer, 1f); setContent(layout); Navigator navigator = new Navigator(this, viewContainer); navigator.addView("default", new DefaultView()); navigator.addView("default2", new DefaultView2()); if (navigator.getState().isEmpty()) { navigator.navigateTo("default"); } }
From source file:com.mycollab.mobile.module.project.view.bug.BugFormLayoutFactory.java
License:Open Source License
@Override public ComponentContainer getLayout() { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(false);/*from w w w . j a v a 2 s. c om*/ layout.setWidth("100%"); layout.addComponent(FormSectionBuilder.build(AppContext.getMessage(BugI18nEnum.SINGLE))); informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 14); layout.addComponent(informationLayout.getLayout()); layout.setComponentAlignment(informationLayout.getLayout(), Alignment.BOTTOM_CENTER); layout.setExpandRatio(informationLayout.getLayout(), 1.0f); return layout; }
From source file:com.naoset.framework.frontend.view.window.Window.java
public Window(Component component) { mySelf = this; this.body = component; //addStyleName("moviedetailswindow"); Responsive.makeResponsive(this); setCaption(body.getCaption());/*from ww w . j a v a 2 s. c om*/ center(); setCloseShortcut(ShortcutAction.KeyCode.ESCAPE, null); setResizable(false); setClosable(false); setHeight(90.0f, Unit.PERCENTAGE); VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); setContent(layout); Panel bodyWrapper = new Panel(body); bodyWrapper.setSizeFull(); bodyWrapper.addStyleName(ValoTheme.PANEL_BORDERLESS); bodyWrapper.addStyleName("scroll-divider"); layout.addComponent(bodyWrapper); layout.setExpandRatio(bodyWrapper, 1f); footer = buildFooter(); layout.addComponent(footer); }
From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.DeployablePanel.java
License:Open Source License
@PostConstruct public void init() { setSizeFull();// www. j av a 2s . com VerticalLayout mainContent = new VerticalLayout(); mainContent.setSpacing(true); mainContent.setMargin(true); mainContent.setStyleName("deployable-style"); mainContent.setSizeFull(); HorizontalLayout header = new HorizontalLayout(); header.setWidth("100%"); Button openManager = new Button("Edit repositories"); openManager.addStyleName("link"); openManager.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (tabSheet.getTab(manager) == null) { tabSheet.addTab(manager, "Manager", new ClassResource(getClass(), "/images/22x22/configuration.png"), containers.size()) .setClosable(true); } tabSheet.setSelectedTab(manager); } }); header.addComponent(openManager); header.setComponentAlignment(openManager, Alignment.MIDDLE_RIGHT); mainContent.addComponent(header); tabSheet.setSizeFull(); mainContent.addComponent(tabSheet); mainContent.setExpandRatio(tabSheet, 1.5f); DragAndDropWrapper mainContentWrapper = new DragAndDropWrapper(mainContent); mainContentWrapper.setDropHandler(new DeploymentDropHandler(deploymentViewManager, this, notifierService)); mainContentWrapper.setSizeFull(); setContent(mainContentWrapper); }
From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.repository.BaseRepositoryManagerPanel.java
License:Open Source License
@PostConstruct public void init() { setSizeFull();// w ww . j a va2 s.c o m VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setMargin(true); mainLayout.setSpacing(true); setContent(mainLayout); HorizontalLayout header = new HorizontalLayout(); header.setWidth("100%"); header.setSpacing(true); header.setMargin(true); TextField filter = new TextField(); filter.setInputPrompt("Filter repositories"); filter.setWidth("100%"); filter.addTextChangeListener(new RepositoryFilter()); header.addComponent(filter); header.setComponentAlignment(filter, Alignment.TOP_LEFT); Button createRepository = new Button("Add repository"); createRepository.addStyleName("wide"); createRepository.addStyleName("default"); createRepository.addClickListener(new CreateNewRepositoryListener()); header.addComponent(createRepository); header.setComponentAlignment(createRepository, Alignment.TOP_RIGHT); mainLayout.addComponent(header); mainLayout.addComponent(contentLayout); mainLayout.setExpandRatio(contentLayout, 1.5f); updateRepositories(); }