Example usage for com.vaadin.ui VerticalLayout setSpacing

List of usage examples for com.vaadin.ui VerticalLayout setSpacing

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setSpacing.

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:com.lst.deploymentautomation.vaadin.popup.TodoRejection.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    LspsUI ui = (LspsUI) getUI();//w  w w .j a  v  a  2 s.  co m
    setCaption(ui.getMessage("todo.rejectionTitle"));

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    setContent(layout);

    Label help = new Label(ui.getMessage("todo.rejectionHelp"));
    help.setStyleName("form-help");
    layout.addComponent(help);

    reason = new TextArea(ui.getMessage("todo.rejectionReason"));
    reason.setMaxLength(1024);
    reason.setRequired(true);
    reason.setSizeFull();
    layout.addComponent(reason);
    layout.setExpandRatio(reason, 1);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    layout.addComponent(buttons);

    @SuppressWarnings("serial")
    Button rejectButton = new Button(ui.getMessage("action.reject"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            reject();
        }
    });
    buttons.addComponent(rejectButton);

    @SuppressWarnings("serial")
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * @param audioFile//from  w  w w. j ava 2s .c  o  m
 */
protected void buildInformationPanel(AudioFile audioFile) {
    if (bottom == null) {
        this.bottom = new HorizontalLayout();
        bottom.setWidth("100%");
        content.addComponent(bottom);

        VerticalLayout side = new VerticalLayout();
        side.setMargin(true);
        side.setSpacing(true);
        side.setWidth("170px");
        bottom.addComponent(side);

        CssLayout musicFile = new CssLayout();
        musicFile.addStyleName(Runo.CSSLAYOUT_SHADOW);
        musicFile.addComponent(createPlayImage(audioFile, audioFile.getCover()));
        side.addComponent(musicFile);

        side.addComponent(setFavorite());
        side.addComponent(setRate());

        Component details = addDetails(audioFile);
        bottom.addComponent(details);
        bottom.setExpandRatio(details, 1);

    } else {
        bottom.removeAllComponents();
        content.removeComponent(bottom);
        this.bottom = null;
        buildInformationPanel(audioFile);
    }

}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.crud.ProductForm.java

License:Apache License

public ProductForm(SampleCrudLogic sampleCrudLogic) {
    viewLogic = sampleCrudLogic;/*  w ww.  j a va2s.  c  o  m*/
    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();//  w w  w  .jav a 2 s  .co  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.j a v a  2 s.co 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  .  j a v  a 2s. 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);/*from w  w  w  .  j  a  v  a 2  s. co m*/
    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();//www.  j a  va2 s .co m
    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.morevaadin.vaadin.theming.ThemingContent.java

License:Apache License

public ThemingContent() {

    CustomLayout layout = new CustomLayout("layout");

    setCompositionRoot(layout);/*from w ww. ja v  a2 s .c om*/

    layout.addComponent(menuBar, "top");
    layout.addComponent(new Button("Does nothing"), "bottom");

    VerticalLayout vLayout = new VerticalLayout();

    vLayout.addComponent(new InlineDateField());
    vLayout.addComponent(new TextField("", "Nothing to put in here"));
    vLayout.setSpacing(true);
    vLayout.setMargin(true);

    layout.addComponent(vLayout, "left");
}

From source file:com.morevaadin.vaadin7.custom.CustomComponentView.java

License:Apache License

public CustomComponentView() {

    VerticalLayout layout = new VerticalLayout();

    layout.setMargin(true);//from   w w w  .  j  a  v  a 2  s  .  c o  m
    layout.setSpacing(true);

    setCompositionRoot(layout);

    Button button = new Button("Vaadin");
    button.addListener(ClickEvent.class, this, "showClick");
    layout.addComponent(button);

    BootstrapButton customButton = new BootstrapButton("Default");
    customButton.addListener(BootstrapClickEvent.class, this, "showClick");
    layout.addComponent(customButton);

    layout.addComponent(new BootstrapButton("Large", Size.LARGE));
    layout.addComponent(new BootstrapButton("Small", Size.SMALL));
    layout.addComponent(new BootstrapButton("Mini", Size.MINI));
    layout.addComponent(new BootstrapButton("Primary", Type.PRIMARY));
    layout.addComponent(new BootstrapButton("Info", Type.INFO));
    layout.addComponent(new BootstrapButton("Success", Type.SUCCESS));
    layout.addComponent(new BootstrapButton("Warning", Type.WARNING));
    layout.addComponent(new BootstrapButton("Danger", Type.DANGER));
    layout.addComponent(new BootstrapButton("Inverse", Type.INVERSE));
}