Example usage for com.vaadin.ui FormLayout removeComponent

List of usage examples for com.vaadin.ui FormLayout removeComponent

Introduction

In this page you can find the example usage for com.vaadin.ui FormLayout removeComponent.

Prototype

@Override
public void removeComponent(Component c) 

Source Link

Document

Removes the component from this container.

Usage

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.DataEntryPropertyComponent.java

License:Apache License

@Override
protected Component initContent() {
    Panel p = new Panel();
    FormLayout l = new FormLayout();
    getInternalValue().forEach(prop -> {
        if (!prop.getPropertyName().equals("property.expected.result")) {
            HorizontalLayout hl = new HorizontalLayout();
            TextField tf = new TextField(TRANSLATOR.translate(prop.getPropertyName()), prop.getPropertyValue());
            hl.addComponent(tf);// www .  ja  v a 2s  . c o m
            if (edit) {
                //Add button for deleting this property.
                Button delete = new Button();
                delete.setIcon(VaadinIcons.MINUS);
                delete.addClickListener(listener -> {
                    getInternalValue().remove(prop);
                    l.removeComponent(hl);
                });
                hl.addComponent(delete);
            }
            l.addComponent(hl);
        }
    });
    p.setContent(l);
    return p;
}