Examples of Layout


Examples of com.vaadin.ui.Layout

        }
    }

    @Override
    protected void setup(VaadinRequest request) {
        Layout navigatorLayout = new VerticalLayout();
        navigator = new Navigator(this, navigatorLayout);

        addComponent(navigatorLayout);

        navigator.addView(DEFAULT_VIEW_ID, new DefaultView());
View Full Code Here

Examples of com.vaadin.ui.Layout

        //
        // }
        // });
        // layout.addComponent(sw);

        Layout ol = new GridLayout(1, 2);
        p = new Panel("Panel", ol);
        p.setSizeFull();
        Label l = new Label("Spacer");
        l.setHeight("400px");
        ol.addComponent(l);

        embedded = new Embedded(null, new ThemeResource(
                "icons/64/folder-add.png"));
        layout.addComponent(embedded);
        Button b = new Button(
                "Replace image with new embedded component (flashes)",
                new ClickListener() {

                    @Override
                    public void buttonClick(ClickEvent event) {
                        Embedded newEmbedded = new Embedded(null,
                                new ThemeResource("icons/64/folder-add.png"));
                        getMainWindow().replaceComponent(embedded, newEmbedded);
                        embedded = newEmbedded;

                    }

                });
        ol.addComponent(b);

        b = new Button("Change image source (is fine)", new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                String img = "folder-add";
                if (((ThemeResource) embedded.getSource()).getResourceId()
                        .contains("folder-add")) {
                    img = "folder-delete";
                }
                embedded.setSource(new ThemeResource("icons/64/" + img + ".png"));

            }

        });

        ol.addComponent(b);
        layout.addComponent(p);
    }
View Full Code Here

Examples of com.vaadin.ui.Layout

    private int i = 0;
    private Class<?> currentValue = VerticalLayout.class;

    @Override
    protected void setup() {
        Layout main = getLayout();
        main.setSizeUndefined();
        getMainWindow().getContent().setHeight(null);

        Label l = new Label(
                "This is a nice game to guess how many Layouts your FF2 (or any other browser) can deal with. Due to the worldwide attempt to decrease energy consumption, playing this game is only allowed above 60° longitude betwheen August and May (as excess energy consumed by you CPU is used to heat your room). It is considered wise to save all your work before starting the game.");

        VerticalLayout rootLayout = new VerticalLayout();
        rootLayout.setMargin(true);
        root = new Panel("Test box", rootLayout);
        root.setWidth("600px");
        root.setHeight("200px");
        final Button b = new Button("Go try your luck with " + i + " layouts!");
        b.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                FF2KILLER(i++);
                b.setCaption("Go try your luck with " + i + " layouts!");
            }

        });

        final ComboBox s = new ComboBox("Restart game with select:");
        s.setNullSelectionAllowed(false);
        s.addItem("-- Choose value --");
        s.setValue("-- Choose value --");
        s.addItem(VerticalLayout.class);
        s.addItem(HorizontalLayout.class);
        s.addItem(GridLayout.class);
        s.addListener(new ComboBox.ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                Object value = s.getValue();
                if (!value.equals("-- Choose value --")) {
                    currentValue = (Class<?>) value;
                    i = 0;
                    s.setValue("-- Choose value --");
                    b.setCaption("Go try your luck with " + i + " layouts!");
                }

            }
        });
        s.setImmediate(true);

        main.addComponent(l);
        main.addComponent(b);
        main.addComponent(s);
        main.addComponent(root);

    }
View Full Code Here

Examples of com.vaadin.ui.Layout

        main.addComponent(root);

    }

    private void FF2KILLER(int layouts) {
        Layout layout = getTestLayout();
        Layout r = layout;
        for (int i = 0; i < layouts; i++) {
            Layout lo = getTestLayout();
            layout.addComponent(lo);
            layout = lo;
        }
        layout.addComponent(new Label(
                "FF did it! Vaadin, Mozilla and you win! Dare to try again?"));
View Full Code Here

Examples of com.vaadin.ui.Layout

                "FF did it! Vaadin, Mozilla and you win! Dare to try again?"));
        root.setContent(r);
    }

    Layout getTestLayout() {
        Layout l = new VerticalLayout();
        if (currentValue == GridLayout.class) {
            l = new GridLayout(1, 1);
        } else {
            try {
                l = (Layout) currentValue.newInstance();
View Full Code Here

Examples of com.vaadin.ui.Layout

    @Override
    protected void setup() {
        GridLayout gl = new GridLayout(3, 2);
        gl.setSizeFull();
        gl.setSpacing(true);
        Layout main = gl;

        DragDropPane pane1 = new DragDropPane();
        pane1.setSizeFull();
        pane1.setCaption("Pane1");

        Label label = new Label("Foo");
        label.setSizeUndefined();

        pane1.addComponent(label);

        Link l = new Link("This is link", new ExternalResource(
                "http://www.google.com/"));
        pane1.addComponent(l, "top:100px; left: 20px;");

        label = new Label("Bar");
        label.setSizeUndefined();
        pane1.addComponent(label);

        DragDropPane pane2 = new DragDropPane();
        pane2.setCaption("Pane2 (accept needs server side visit, check for \"Bar\")");
        final AcceptCriterion crit = new ServerSideCriterion() {
            /**
             *
             */
            private static final long serialVersionUID = 1L;

            @Override
            public boolean accept(DragAndDropEvent dragEvent) {
                Transferable transferable = dragEvent.getTransferable();
                // System.out.println("Simulating 500ms processing...");
                // try {
                // Thread.sleep(200);
                // } catch (InterruptedException e) {
                // // TODO Auto-generated catch block
                // e.printStackTrace();
                // }
                // System.out.println("Done get to work.");

                Component component = (Component) transferable
                        .getData("component");
                if (component == null) {
                    component = transferable.getSourceComponent();
                }

                if (component != null) {
                    if (component.toString() != null
                            && component.toString().contains("Bar")) {
                        return true;
                    }
                }
                return false;
            }
        };

        pane2.setAcceptCriterion(crit);

        pane2.setId("pane2");
        pane2.setSizeFull();

        DragDropPane pane3 = new DragDropPane();
        pane3.setSizeFull();
        pane3.setCaption("Pane3");

        final Tree t = new Tree(
                "Tree with sorting enabled. Also allows dragging elsewhere.");

        final HierarchicalContainer idx = new HierarchicalContainer();
        t.setContainerDataSource(idx);
        t.setId("perseys");
        t.addItem("Foo");
        t.addItem("Bar");
        t.addItem("Bar1");
        t.addItem("Bar2");
        t.addItem("Bar3");
        t.addItem("Bar4");
        t.addItem("Bar5");
        t.addItem("Child");
        t.setParent("Child", "Foo");
        t.setSizeFull();
        t.setDragMode(TreeDragMode.NODE);

        /*
         * Moves items in tree (and could work in Table too). Also supports
         * "building" tree.
         *
         * TODO fix algorithm, broken in some cases.
         */
        DropHandler itemSorter = new DropHandler() {

            @SuppressWarnings("unused")
            private void populateSubTree(HierarchicalContainer idx,
                    HierarchicalContainer subtree, Object itemId) {
                Collection<?> children = subtree.getChildren(itemId);
                if (children != null) {

                    for (Object childId : children) {
                        Item addItem = idx.addItem(childId);
                        if (addItem != null) {
                            // did not exist, populate properties
                            Item item = subtree.getItem(itemId);
                            Collection<?> itemPropertyIds = item
                                    .getItemPropertyIds();
                            for (Object propId : itemPropertyIds) {
                                addItem.getItemProperty(propId)
                                        .setValue(
                                                item.getItemProperty(propId)
                                                        .getValue());
                            }
                        }
                        idx.setParent(childId, itemId);
                        populateSubTree(idx, subtree, childId);
                    }
                }

            }

            @SuppressWarnings("unused")
            private HierarchicalContainer getSubTree(HierarchicalContainer idx,
                    Object itemId) {
                HierarchicalContainer hierarchicalContainer = new HierarchicalContainer();
                Collection<?> containerPropertyIds = idx
                        .getContainerPropertyIds();
                for (Object object : containerPropertyIds) {
                    hierarchicalContainer.addContainerProperty(object,
                            idx.getType(object), null);
                }
                hierarchicalContainer.addItem(itemId);
                copyChildren(idx, hierarchicalContainer, itemId);
                return hierarchicalContainer;
            }

            private void copyChildren(HierarchicalContainer source,
                    HierarchicalContainer target, Object itemId) {
                Collection<?> children = source.getChildren(itemId);
                if (children != null) {
                    for (Object childId : children) {
                        Item item = source.getItem(childId);
                        Item addedItem = target.addItem(childId);
                        target.setParent(childId, itemId);
                        Collection<?> itemPropertyIds = item
                                .getItemPropertyIds();
                        for (Object propertyId : itemPropertyIds) {
                            addedItem.getItemProperty(propertyId)
                                    .setValue(
                                            item.getItemProperty(propertyId)
                                                    .getValue());
                        }
                        copyChildren(source, target, childId);
                    }
                }

            }

            @Override
            public void drop(DragAndDropEvent event) {
                TreeTargetDetails details = (TreeTargetDetails) event
                        .getTargetDetails();
                // TODO set properties, so same sorter could be used in Table
                Transferable transferable = event.getTransferable();
                if (transferable instanceof DataBoundTransferable) {
                    DataBoundTransferable transferrable2 = (DataBoundTransferable) transferable;

                    Object itemId = transferrable2.getItemId();

                    Object itemIdOver = details.getItemIdOver();

                    // TODO could use the "folder" node id to make the drop
                    // logic simpler
                    Object itemIdInto = details.getItemIdInto();
                    VerticalDropLocation dropLocation = details
                            .getDropLocation();

                    Object itemIdAfter = details.getItemIdAfter();

                    if (itemIdOver.equals(itemIdInto)) { // directly on a node
                        t.setParent(itemId, itemIdOver);
                        return;
                    }

                    idx.setParent(itemId, itemIdInto);

                    if (dropLocation == null) {
                        System.err.println("No detail of drop place available");
                    }
                    idx.moveAfterSibling(itemId, itemIdAfter);
                }

                return;
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {
                // TODO should actually check that source is same as target
                return AcceptItem.ALL;
            }

        };

        t.setDropHandler(itemSorter);

        Table ta = new Table("Test table");
        ta.setContainerDataSource(idx);
        ta.addContainerProperty("Foos", String.class, "Foo");
        ta.addContainerProperty("Bars", String.class, "Bar");
        ta.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
        ta.setSizeFull();
        ta.setDragMode(TableDragMode.ROW);

        main.addComponent(pane1);
        main.addComponent(pane2);
        main.addComponent(pane3);
        main.addComponent(t);
        main.addComponent(ta);
        main.addComponent(new Link("Foo", new ExternalResource(
                "http://www.itmill.com/")));

        getLayout().setSizeFull();
        addComponent(main);

View Full Code Here

Examples of com.vaadin.ui.Layout

        main.addComponent(new Label(
                "Below are same tables that all should render somewhat nice. Also when testing, you might want to try resizing window."));

        Table t;

        Layout lo = new VerticalLayout();
        lo.setWidth("600px");
        lo.setHeight("250px");

        t = getTestTable(4, 50);
        t.setSizeFull();
        lo.setCaption("Fullsize table insize 400x250px layout");
        lo.addComponent(t);
        main.addComponent(lo);

        // t = new Table("Empty table");
        // main.addComponent(t);
View Full Code Here

Examples of com.vaadin.ui.Layout

    public static final String NAME = "login";

    public LoginView(final Navigator navigator,
            final String fragmentAndParameters) {
        Layout layout = new VerticalLayout();

        final TextField email = new TextField("Email");
        layout.addComponent(email);

        final PasswordField password = new PasswordField("Password");
        layout.addComponent(password);

        final Button login = new Button("Login", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                Notification.show("Ok, let's pretend you're " + email);

                // indicate the user is logged in
                ((NavigationtestUI) UI.getCurrent()).setLoggedInUser(email
                        .getValue());

                // navigate back to the intended place
                navigator.navigateTo(fragmentAndParameters);
            }
        });
        layout.addComponent(login);
        setContent(layout);

    }
View Full Code Here

Examples of com.vaadin.ui.Layout

@Theme("sassy")
public class SassyUI extends UI {
    @Override
    public void init(VaadinRequest request) {
        Button b = new Button("Reindeer");
        Layout layout = new VerticalLayout();
        layout.addComponent(b);

        b = new Button("important");
        b.addStyleName("important");
        layout.addComponent(b);

        b = new Button("More important");
        b.setPrimaryStyleName("my-button");
        layout.addComponent(b);

        setContent(layout);
    }
View Full Code Here

Examples of com.vaadin.ui.Layout

    String pendingViewAndParameters = null;

    public SettingsView(final Navigator navigator) {
        this.navigator = navigator;
        Layout layout = new VerticalLayout();

        date = new InlineDateField("Birth date");
        date.setImmediate(true);
        layout.addComponent(date);
        // pretend we have a datasource:
        date.setPropertyDataSource(new ObjectProperty<Date>(new Date()));
        date.setBuffered(true);
        // show buttons when date is changed
        date.addValueChangeListener(new ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                hideOrShowButtons();
                pendingViewAndParameters = null;
            }
        });

        // commit the TextField changes when "Save" is clicked
        apply = new Button("Apply", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                date.commit();
                hideOrShowButtons();
                processPendingView();
            }
        });
        layout.addComponent(apply);

        // Discard the TextField changes when "Cancel" is clicked
        cancel = new Button("Cancel", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                date.discard();
                hideOrShowButtons();
                processPendingView();
            }
        });
        cancel.setStyleName(Reindeer.BUTTON_LINK);
        layout.addComponent(cancel);

        // attach a listener so that we'll get asked isViewChangeAllowed?
        navigator.addViewChangeListener(new ViewChangeListener() {
            @Override
            public boolean beforeViewChange(ViewChangeEvent event) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.