Example usage for com.vaadin.ui VerticalLayout VerticalLayout

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

Introduction

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

Prototype

public VerticalLayout() 

Source Link

Document

Constructs an empty VerticalLayout.

Usage

From source file:com.blogspot.markogronroos.MainUI.java

License:GNU General Public License

protected void jpaContTable(AbstractOrderedLayout main) {
    final VerticalLayout layout = new VerticalLayout();
    main.addComponent(layout);/*  w w w.  j ava2 s . com*/
    show(layout, "Please notice table rows are selectable, column order movable, column sort order adjustable");

    // Create a persistent person container
    JPAContainer<Trip> trips = JPAContainerFactory.make(Trip.class, "source.jpa");
    // You can add entities to the container as well
    trips.addEntity(new Trip("Riga", "Brussels", 5.0F));
    trips.addEntity(new Trip("London", "Riga", 101.0F));

    // Bind it to a component
    Table personTable = new Table("Past Trips", trips);

    personTable.setSizeUndefined();
    personTable.setSelectable(true);
    personTable.setMultiSelect(false);
    personTable.setImmediate(true);
    personTable.setColumnReorderingAllowed(true);
    personTable.setColumnCollapsingAllowed(true);

    personTable.setVisibleColumns(new String[] { "id", "price", "startLocation", "finishLocation" });
    layout.addComponent(personTable);

    Button button = new Button("Clear");
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            //layout.addComponent(new Label("Thank you for clicking"));
            layout.removeAllComponents();
        }
    });
    layout.addComponent(button);
}

From source file:com.blogspot.markogronroos.MainUI.java

License:GNU General Public License

protected void jpaContTable2(AbstractOrderedLayout main) {
    final VerticalLayout layout = new VerticalLayout();
    main.addComponent(layout);//from w  w  w  .  j ava  2 s  .c  o m
    show(layout, "This is same as above but EntityManager is created explicitly");

    EntityManager em = JPAContainerFactory.createEntityManagerForPersistenceUnit("source.jpa");
    /*
            
       Notice that if you use update the persistent data with an entity manager outside a JPAContainer bound to the 
       data, you need to refresh the container as described in Section 19.4.2, Creating and Accessing Entities?.
            
    Refreshing JPAContainer
            
    In cases where you change JPAContainer items outside the container, for example by through an EntityManager, 
    or when they change in the database, you need to refresh the container.
    The EntityContainer interface implemented by JPAContainer provides two methods to refresh a container. The 
    refresh() discards all container caches and buffers and refreshes all loaded items in the container. All 
    changes made to items provided by the container are discarded. The refreshItem() refreshes a single item.
            
    */
    // Create a persistent person container
    JPAContainer<Trip> trips = JPAContainerFactory.make(Trip.class, em);

    // You can add entities to the container as well
    trips.addEntity(new Trip("Riga", "Brussels", 5.0F));
    trips.addEntity(new Trip("London", "Riga", 101.0F));

    // Bind it to a component
    Table personTable = new Table("Past Trips", trips);

    personTable.setSizeUndefined();
    personTable.setSelectable(true);
    personTable.setMultiSelect(false);
    personTable.setImmediate(true);
    personTable.setColumnReorderingAllowed(true);
    personTable.setColumnCollapsingAllowed(true);

    personTable.setVisibleColumns(new String[] { "id", "price", "startLocation", "finishLocation" });
    layout.addComponent(personTable);

    Button button = new Button("Clear");
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            //layout.addComponent(new Label("Thank you for clicking"));
            layout.removeAllComponents();
        }
    });
    layout.addComponent(button);
}

From source file:com.blogspot.markogronroos.MainUI.java

License:GNU General Public License

protected void jpaContForm1(AbstractOrderedLayout main) {
    final VerticalLayout layout = new VerticalLayout();
    main.addComponent(layout);/*from  w ww  . j a  va 2  s. c om*/
    show(layout, "JPAContainer Form Example enterd!");

    // Have a persistent container
    final JPAContainer<Trip> trips = JPAContainerFactory.make(Trip.class, "source.jpa");
    // For selecting an item to edit
    // Country Editor
    final Form tripForm = new Form();
    tripForm.setCaption("Trip form");

    tripForm.setWidth("420px");
    tripForm.setBuffered(true);
    tripForm.setEnabled(false);
    Object itemId = trips.getIdByIndex(0);
    if (itemId == null)
        show(layout, "Sorry no item retrieved!");
    else {
        show(layout, " choosen item: " + itemId); //+" class: "+itemId.getClass().getName());
        Item tripItem = trips.getItem(itemId);
        show(layout, " Item found :" + tripItem);
        layout.addComponent(tripForm);

        // Use a JPAContainer field factory
        //  - no configuration is needed here
        final FieldFactory fieldFactory = new FieldFactory();
        //fieldFactory.
        tripForm.setFormFieldFactory(fieldFactory);
        // Edit the item in the form
        tripForm.setItemDataSource(tripItem);
        tripForm.setEnabled(true);

        tripForm.setVisibleItemProperties(new String[] { "startLocation", "finishLocation", "status" });
        //tripForm.getField("name").setCaption("name new caption");

        // Handle saves on the form
        final Button save = new Button("Save");
        tripForm.getFooter().addComponent(save);
        save.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                try {
                    tripForm.commit();
                    tripForm.setEnabled(false);
                } catch (InvalidValueException e) {
                    e.printStackTrace();
                }
            }
        });

    }

}

From source file:com.blogspot.markogronroos.MainUI.java

License:GNU General Public License

protected void pureJPAExample(AbstractOrderedLayout main) {
    final VerticalLayout layout = new VerticalLayout();
    main.addComponent(layout);//from w ww. j a v  a2  s  .c o m
    show(layout, "Entering pureJPAExample");
    EntityManager em = JPAContainerFactory.createEntityManagerForPersistenceUnit("source.jpa");
    em.getTransaction().begin();
    em.createQuery("DELETE FROM Trip t").executeUpdate();
    show(layout, "Rows deleted!");
    em.persist(new Trip("Istambul", "Mumbai", 555.0F));
    em.persist(new Trip("Mumbai", "Brussels", 125.0F));
    show(layout, "2 rows added!");
    em.getTransaction().commit();
    show(layout, "Commit completed!");

}

From source file:com.bsb.common.vaadin.embed.component.ComponentWrapper.java

License:Apache License

/**
 * Wraps the specified {@link Component} into a Vaadin application.
 *
 * @param component the component to wrap
 * @return an application displaying that component
 * @see #wrapLayout(com.vaadin.ui.Layout)
 * @see #wrapWindow(com.vaadin.ui.Window)
 */// w  w w . jav a  2  s.c om
public Application wrap(Component component) {
    if (component instanceof Window) {
        return wrapWindow((Window) component);
    }
    if (component instanceof Layout) {
        return wrapLayout((Layout) component);
    }

    // Ok it's a component we cannot handle directly
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSizeFull();
    layout.addComponent(component);
    layout.setExpandRatio(component, 1);
    return wrapLayout(layout);
}

From source file:com.bsb.samples.vaadin.wizard.core.FinalStep.java

License:Apache License

public Component getContent() {
    final VerticalLayout content = new VerticalLayout();

    content.setMargin(true);/*from w  w w  .  j a  va 2s. c  o m*/

    final Label sorry = new Label(
            "We sincerely hope that you were not expecting a demo of a " + "kick-ass Wizard :)");
    content.addComponent(sorry);

    return content;
}

From source file:com.bsb.samples.vaadin.wizard.core.FirstStep.java

License:Apache License

public Component getContent() {
    final VerticalLayout content = new VerticalLayout();
    content.setSpacing(true);/*  w ww.ja  v  a 2 s  .c om*/
    content.setMargin(true);

    final Label intro = new Label("A trivial use of the Wizards for Vaadin add-on");
    content.addComponent(intro);

    final Label description = new Label(
            "This demonstrates an application where a custom widgetset has been compiled in a separate JAR "
                    + "project that is not bound to the standard build lifecycle of the project. By making this "
                    + "project optional, the lengthy compilation of the widgetset is only performed on demand. "
                    + "Besides, a full clean of your project in your IDE does not require you to rebuild the "
                    + "widgetset.");
    content.addComponent(description);

    return content;
}

From source file:com.bsb.samples.vaadin.wizard.core.WizardSampleApplication.java

License:Apache License

@Override
public void init() {
    final VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();//from w  ww .  ja va  2s  .  c om
    mainLayout.setMargin(true);

    final Wizard wizard = new Wizard();
    wizard.addStep(new FirstStep(), "First");
    wizard.addStep(new FinalStep(), "Final");
    wizard.setWidth(800, Sizeable.UNITS_PIXELS);
    wizard.setHeight(600, Sizeable.UNITS_PIXELS);

    mainLayout.addComponent(wizard);
    mainLayout.setComponentAlignment(wizard, Alignment.MIDDLE_CENTER);

    final Window mainWindow = new Window("Wizard Sample");
    mainWindow.setContent(mainLayout);
    setMainWindow(mainWindow);

}

From source file:com.cavisson.gui.dashboard.components.charts.Impl.ResizeInsideVaadinComponent.java

@Override
protected Component getChart() {

    VerticalSplitPanel verticalSplitPanel = new VerticalSplitPanel();
    HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
    horizontalSplitPanel.setSecondComponent(verticalSplitPanel);
    verticalSplitPanel.setFirstComponent(createChart());

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);/*  ww w .j a  v a2s .  c o  m*/
    verticalLayout.setSpacing(true);
    verticalLayout.addComponent(
            new Label("Relatively sized components resize themselves automatically when in Vaadin component."));

    Button button = new Button("Open in a window");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Window window = new Window("Chart windodw");
            window.setContent(createChart());
            window.setWidth("50%");
            window.setHeight("50%");

            getUI().addWindow(window);

        }
    });

    verticalLayout.addComponent(button);
    horizontalSplitPanel.setFirstComponent(verticalLayout);

    return horizontalSplitPanel;
}

From source file:com.cavisson.gui.dashboard.components.controls.Accordions.java

License:Apache License

Accordion getAccordion(String caption) {
    TestIcon testIcon = new TestIcon(0);
    Accordion ac = new Accordion();
    ac.setCaption(caption);//from   w w w .j  a v  a  2s  .  c o  m
    ac.addTab(new VerticalLayout() {
        {
            setMargin(true);
            addComponent(new Label(
                    "Fabio vel iudice vincam, sunt in culpa qui officia. Ut enim ad minim veniam, quis nostrud exercitation."));
        }
    }, "First Caption", testIcon.get());
    ac.addTab(new VerticalLayout() {
        {
            setMargin(true);
            addComponent(new Label("Gallia est omnis divisa in partes tres, quarum."));
        }
    }, "Second Caption", testIcon.get());
    ac.addTab(new VerticalLayout() {
        {
            setMargin(true);
            addComponent(new Label(
                    "Nihil hic munitissimus habendi senatus locus, nihil horum? Sed haec quis possit intrepidus aestimare tellus."));
        }
    }, "Third Caption", testIcon.get());
    ac.addTab(new VerticalLayout() {
        {
            setMargin(true);
            addComponent(new Label(
                    "Inmensae subtilitatis, obscuris et malesuada fames. Quisque ut dolor gravida, placerat libero vel, euismod."));
        }
    }, "Custom Caption Style", testIcon.get()).setStyleName("color1");
    return ac;
}