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.moscaville.ui.CsvVaadinUI.java

private void buildTemplateGrid() {
    VerticalLayout templateGridLayout = new VerticalLayout();
    templateGridLayout.setSpacing(true);
    templateGrid.setWidth("100%");
    templateGrid.setHeight("300px");
    templateGridLayout.addComponent(templateGrid);
    HorizontalLayout tgButtonLayout = new HorizontalLayout();
    tgButtonLayout.setSpacing(true);//from w  w  w.  j  a  v a2  s .c o m
    Button btnAddTemplate = new Button("Add", FontAwesome.PLUS_SQUARE);
    btnAddTemplate.setDescription("Add template");
    btnAddTemplate.addClickListener((Button.ClickEvent event) -> {
        templateManager.addProperty();
    });
    tgButtonLayout.addComponent(btnAddTemplate);
    Button btnDeleteTemplate = new Button("Delete", FontAwesome.MINUS_SQUARE);
    btnDeleteTemplate.setDescription("Delete template");
    btnDeleteTemplate.addClickListener((Button.ClickEvent event) -> {
        Object itemId = templateGrid.getSelectedRow();
        if (itemId != null) {
            templateManager.getContainer().removeItem(itemId);
        }
    });
    tgButtonLayout.addComponent(btnDeleteTemplate);
    templateGridLayout.addComponent(tgButtonLayout);
    mainLayout.addComponent(templateGridLayout);
}

From source file:com.mycompany.project.components.ContactDetails.java

public ContactDetails() {
    //        setCaption("Contact Details");

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);//from   ww  w . jav  a2 s. c o m
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);

    tfName.setSizeFull();
    tfAddress.setSizeFull();
    tfPhone.setSizeFull();
    tfEmail.setSizeFull();

    Panel panel = new Panel("Grupos");
    panel.setWidth("100%");
    panel.setHeight("50px");
    panel.setContent(groupsHLayout);

    mainVLayout.addComponent(tfName);
    mainVLayout.addComponent(tfAddress);
    mainVLayout.addComponent(tfPhone);
    mainVLayout.addComponent(tfEmail);
    mainVLayout.addComponent(groupsHLayout);

    Button btnUpdate = new Button("Actualizar");
    mainVLayout.addComponent(btnUpdate);

    btnUpdate.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //invoke business logic
            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();

            String name = tfName.getValue();
            String address = tfAddress.getValue();
            String phone = tfPhone.getValue();
            String email = tfEmail.getValue();

            ArrayList<String> selectedGroupIds = new ArrayList<String>();
            Set<String> groupIdSet = groupsMap.keySet();
            for (String groupId : groupIdSet) {
                CheckBox cb = groupsMap.get(groupId);
                if (cb.getValue()) {
                    selectedGroupIds.add(groupId);
                }
            }

            boolean success = bl.updateContact(selectedContactId, name, address, phone, email,
                    selectedGroupIds);
            if (success) {
                load(selectedContactId);
                Notification.show("Informacion", "Contacto Actualizado", Notification.Type.TRAY_NOTIFICATION);
            } else {
                Notification.show("Error", "\nSomething bad happened", Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    ContactDetails.this.setVisible(false);
}

From source file:com.mycompany.project.components.GroupDetails.java

public GroupDetails() {
    //        setCaption("Contact Details");

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);//from w  w  w. j  a v  a  2  s. co m
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);
    tfName.setSizeFull();
    mainVLayout.addComponent(tfName);

    Button btnUpdate = new Button("Update");
    mainVLayout.addComponent(btnUpdate);

    btnUpdate.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //invoke business logic
            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();

            String name = tfName.getValue();

            boolean success = bl.updateGroup(selectedGroupId, name);
            if (success) {
                load(selectedGroupId);
                Notification.show("Success", "Group updated", Notification.Type.TRAY_NOTIFICATION);
            } else {
                Notification.show("Error", "\nSomething bad happened", Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    GroupDetails.this.setVisible(false);
}

From source file:com.mycompany.project.components.NewContactForm.java

public NewContactForm() {

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);//w ww  .j a v  a  2 s.  c o  m
    mainVLayout.setSpacing(true);
    mainVLayout.addStyleName(boostrap.Forms.FORM.styleName());
    setContent(mainVLayout);

    // field properties
    tfName.setSizeFull();
    tfPhone.setSizeFull();
    tfemail.setSizeFull();

    tfName.focus();

    mainVLayout.addComponent(tfName);
    mainVLayout.addComponent(tfPhone);
    mainVLayout.addComponent(tfemail);

    Button btnSave = new Button("Guardar");
    mainVLayout.addComponent(btnSave);

    btnSave.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            // get hold of the business logic

            String name = tfName.getValue();
            String phone = tfPhone.getValue();
            String email = tfemail.getValue();

            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();
            String newContactId = bl.saveNewContact(name, phone, email);

            if (newContactId != null) {
                //saved successfully
                Notification.show("Success", name + " saved", Notification.Type.TRAY_NOTIFICATION);
                //reset fields
                resetFields();
            } else {
                //something bad happened
                Notification.show("Error", "\nContact could not be saved", Notification.Type.ERROR_MESSAGE);
            }
        }
    });
}

From source file:com.mycompany.project.components.NewGroupForm.java

public NewGroupForm() {

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);/*  w  ww. j  a v  a 2  s .c om*/
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);

    // field properties
    tfName.setSizeFull();

    mainVLayout.addComponent(tfName);

    Button btnSave = new Button("Save");
    mainVLayout.addComponent(btnSave);

    btnSave.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            // get hold of the business logic

            String name = tfName.getValue();

            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();
            String newGroupId = bl.saveNewGroup(name);

            if (newGroupId != null) {
                //saved successfully
                Notification.show("Success", name + " saved", Notification.Type.TRAY_NOTIFICATION);
                resetFields();
            } else {
                //something bad happened
                Notification.show("Error", "\nGroup could not be saved", Notification.Type.ERROR_MESSAGE);
            }
        }
    });
}

From source file:com.mycompany.project.views.ContactsView.java

public ContactsView() {

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);/*  w  ww .ja v  a  2  s  .c o m*/
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);

    // view header
    Label header = new Label("<div align=\"center\" style=\"font-size:12pt;\">Contactos</div>");
    header.setContentMode(ContentMode.HTML);

    mainVLayout.addComponent(header);

    // set window properties
    window.setWidth("400px");
    window.setCaption("Nuevo Contacto");
    window.setModal(true);
    window.setContent(newContactForm);

    // add new cotact button
    Button btnNew = new Button("Agregar Nuevo Contacto");
    mainVLayout.addComponent(btnNew);

    // clicking the button should display the NewContactForm
    btnNew.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (window.getParent() == null) {
                getUI().addWindow(window);
            }

        }
    });

    //add a horozontal layout - left has a table, right has a ContactDetail component
    HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setSizeFull();
    hLayout.setSpacing(true);

    mainVLayout.addComponent(hLayout);

    //add a table

    table.setWidth("600px");
    table.setImmediate(true);
    hLayout.addComponent(table);

    // how does table get its data
    beanContainer.setBeanIdProperty("id");
    table.setContainerDataSource(beanContainer);

    //set columns
    final Object[] NATURAL_COL_ORDER = new Object[] { "name", "phone", "email" };
    final String[] COL_HEADERS_ENGLISH = new String[] { "Name", "Phone", "Email" };

    table.setSelectable(true);
    table.setColumnCollapsingAllowed(true);
    table.setRowHeaderMode(RowHeaderMode.INDEX);
    table.setVisibleColumns(NATURAL_COL_ORDER);
    table.setColumnHeaders(COL_HEADERS_ENGLISH);

    // selecting a table row should enable/disale the ContactDetails component
    table.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            String contactId = (String) table.getValue();
            contactDetails.setContactId(contactId);
        }
    });

    //add a ContactDetails component

    //        contactDetails.setWidth("500px");
    hLayout.addComponent(contactDetails);

    // let the table fill the entire remaining width
    hLayout.setExpandRatio(contactDetails, 1);

}

From source file:com.mycompany.project.views.GroupsView.java

public GroupsView() {

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);/* w  ww. j  a  v  a2  s.  c o m*/
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);

    // view header
    Label header = new Label("<div align=\"center\" style=\"font-size:12pt;\">Grupos</div>");
    header.setContentMode(ContentMode.HTML);

    mainVLayout.addComponent(header);

    // set window properties
    window.setWidth("400px");
    window.setCaption("New Group");
    window.setModal(true);
    window.setContent(newGroupForm);

    // add new cotact button
    Button btnNew = new Button("Add New Group");
    mainVLayout.addComponent(btnNew);

    // clicking the button should display the NewContactForm
    btnNew.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (window.getParent() == null) {
                getUI().addWindow(window);
            }

        }
    });

    //add a horozontal layout - left has a table, right has a ContactDetail component
    HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setSizeFull();
    hLayout.setSpacing(true);

    mainVLayout.addComponent(hLayout);

    //add a table

    table.setWidth("600px");
    table.setImmediate(true);
    hLayout.addComponent(table);

    // how does table get its data
    beanContainer.setBeanIdProperty("id");
    table.setContainerDataSource(beanContainer);

    //set columns
    final Object[] NATURAL_COL_ORDER = new Object[] { "name" };
    final String[] COL_HEADERS_ENGLISH = new String[] { "Name" };

    table.setSelectable(true);
    table.setColumnCollapsingAllowed(true);
    table.setRowHeaderMode(RowHeaderMode.INDEX);
    table.setVisibleColumns(NATURAL_COL_ORDER);
    table.setColumnHeaders(COL_HEADERS_ENGLISH);

    // selecting a table row should enable/disale the ContactDetails component
    table.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            String groupId = (String) table.getValue();
            groupDetails.setGroupId(groupId);
        }
    });

    //add a ContactDetails component

    //        contactDetails.setWidth("500px");
    hLayout.addComponent(groupDetails);

    // let the table fill the entire remaining width
    hLayout.setExpandRatio(groupDetails, 1);
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.promote.ArticlePromotionViewImpl.java

License:Open Source License

private void createCenterPiece() {
    HorizontalLayout centerpieceLayout = new HorizontalLayout();
    centerpieceLayout.setWidth("100%");
    centerpieceLayout.setSpacing(true);/*from w ww .  j a  v a 2s .c  o m*/

    VerticalLayout centerpieceSettings = new VerticalLayout();
    centerpieceSettings.setWidth("100%");
    centerpieceSettings.setSpacing(true);

    Field richTextField = listener.createRichTextField();
    richTextField.setCaption("Teaser");
    richTextField.setWidth("100%");
    richTextField.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            try {
                articleItem.removeItemProperty("siteAlert");
                articleItem.addItemProperty("siteAlert", DefaultPropertyUtil.newDefaultProperty(String.class,
                        event.getProperty().getValue().toString()));
                articleItem.applyChanges();
            } catch (RepositoryException e) {
                e.printStackTrace();
            }
        }
    });

    centerpieceSettings.addComponent(richTextField);

    Label placementLabel = new Label("", ContentMode.HTML);
    placementLabel.setCaption("Placement");
    centerpieceSettings.addComponent(placementLabel);

    CheckBox home = listener.createCheckBox("Home Page");
    centerpieceSettings.addComponent(home);
    CheckBox news = listener.createCheckBox("News Landing");
    centerpieceSettings.addComponent(news);
    CheckBox comm = listener.createCheckBox("Community Landing");
    centerpieceSettings.addComponent(comm);
    CheckBox team = listener.createCheckBox("Team Landing");
    centerpieceSettings.addComponent(team);
    CheckBox cheer = listener.createCheckBox("Cheerleader Landing");
    centerpieceSettings.addComponent(cheer);

    centerpieceLayout.addComponent(centerpieceSettings);

    Label previewLabel = new Label("", ContentMode.HTML);
    previewLabel.setCaption("Centerpiece preview");
    centerpieceLayout.addComponent(previewLabel);

    centerPiece.setContent(centerpieceLayout);
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.promote.ArticlePromotionViewImpl.java

License:Open Source License

private void createAlert() {
    VerticalLayout alertTextLayout = new VerticalLayout();
    alertTextLayout.setSpacing(true);
    alertTextLayout.setCaption("Alert Text");

    MagnoliaRichTextField textField = (MagnoliaRichTextField) listener.createRichTextField();
    textField.setSizeFull();/*from   ww w  .  jav  a2 s  .co  m*/

    HorizontalLayout periodLayout = new HorizontalLayout();
    periodLayout.setSpacing(true);
    // periodLayout.setWidth("100%");
    DateField startDate = new DateField();
    // startDate.setWidth("100%");
    DateField endDate = new DateField();
    // endDate.setWidth("100%");

    periodLayout.addComponent(new Label("START"));
    periodLayout.addComponent(startDate);
    periodLayout.addComponent(new Label("END"));
    periodLayout.addComponent(endDate);

    alertTextLayout.addComponent(textField);
    alertTextLayout.addComponent(periodLayout);

    HorizontalLayout alertLayout = new HorizontalLayout();
    alertLayout.setSpacing(true);
    alertLayout.setWidth("100%");
    alertLayout.addComponent(alertTextLayout);

    final Label alertPreview = new Label("", ContentMode.HTML);
    alertPreview.setCaption("Alert Preview");
    alertPreview.addStyleName("preview-label");
    textField.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            alertPreview.setValue(String.valueOf(event.getProperty().getValue()));
        }
    });
    alertPreview.setSizeUndefined();
    alertLayout.addComponent(alertPreview);
    alert.setContent(alertLayout);

    textField.setValue(
            "<b>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,</b>");
}

From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java

License:Apache License

/**
 * Create delete tab in the accordion./*from   w  ww  .  ja  v a 2s .  co m*/
 * 
 * @return the component.
 */
@SuppressWarnings("serial")
private final AbstractComponent createDelete() {

    /* root layout */
    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setMargin(true);
    layout.setSpacing(true);

    final Label label = new Label("Deleting a device can be done, only if it is de-activated.");
    layout.addComponent(label);
    label.setWidth(null);
    layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);

    final Button deleteButton = new Button("Delete");

    layout.addComponent(deleteButton);
    layout.setComponentAlignment(deleteButton, Alignment.BOTTOM_CENTER);

    deleteButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                final DeviceDeleteWindow deleteWindow = new DeviceDeleteWindow(model.getItemUuid());
                deleteWindow.add(model);
            } catch (final Exception e) {
                LOGGER.error("Can not delete device: ", e);
            }
        }
    });
    return layout;
}