List of usage examples for com.vaadin.ui VerticalLayout addComponent
@Override public void addComponent(Component c)
From source file:com.blogspot.markogronroos.MainUI.java
License:GNU General Public License
@Override protected void init(VaadinRequest request) { final VerticalLayout main = new VerticalLayout(); main.setMargin(true);// www . ja v a 2 s.c o m setContent(main); //Window main = new Window("Test Application"); // Create a menu bar final MenuBar menubar = new MenuBar(); main.addComponent(menubar); // A feedback component final Label selection = new Label("-"); main.addComponent(selection); MenuBar.MenuItem menuitem1 = menubar.addItem("JPA Examples", null, null); MenuBar.MenuItem menuitem2 = menuitem1.addItem("Other Example", null, null); MenuBar.Command mycommand = new MenuBar.Command() { @Override public void menuSelected(MenuBar.MenuItem selectedItem) { selection.setValue("Ordered a " + selectedItem.getText() + " from menu."); String selectedText = selectedItem.getText(); if (selectedText.contains("1.1")) jpaContTable(main); else if (selectedText.contains("1.2")) jpaContTable2(main); else if (selectedText.contains("1.3")) jpaContForm1(main); else if (selectedText.contains("1.4")) pureJPAExample(main); //selectedItem. } }; menuitem1.addItem("1.1 demo JPAContainer Table component", null, mycommand); menuitem1.addItem("1.2 demo JPAContainer Table component, explicit EntityManager", null, mycommand); menuitem1.addItem("1.3 demo JPAContainer Form", null, mycommand); menuitem1.addItem("1.4 demo JPA batch", null, mycommand); //menuitem1.addItem(menuitem2); // Define a common menu command for all the menu items. // initEx2(request); }
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);// www.j a va2s . co m 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);/*w ww. j a v a2 s . com*/ 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 w w . j a va2 s .co m 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.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) */// ww w . j a v a2 s. co m 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 va2s . c om*/ 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);//from w ww . j a va 2s . c o m 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 ww w . j a v a 2 s . c o m 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);/*w w w.jav a 2 s. co 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.CommonParts.java
License:Apache License
public CommonParts() { setMargin(true);// w w w . jav a 2 s. c o m addStyleName("content-common"); Label h1 = new Label("Common UI Elements"); h1.addStyleName("h1"); addComponent(h1); VerticalLayout row = new VerticalLayout(); row.setWidth("100%"); row.setSpacing(true); addComponent(row); row.addComponent(loadingIndicators()); row.addComponent(notifications()); row.addComponent(windows()); row.addComponent(tooltips()); }