Package com.vaadin.ui

Examples of com.vaadin.ui.AbstractOrderedLayout


        ol.setCaption("Fixed width (" + ol.getWidth()
                + "px) and fixed height (" + ol.getHeight()
                + "px) / layout_add_remove_components");

        for (int i = 0; i < 2; i++) {
            AbstractOrderedLayout inner = createAddRemove(ol, "", "");
            ol.addComponent(inner);
            ol.setComponentAlignment(inner, Alignment.BOTTOM_RIGHT);
        }

        return ol;
View Full Code Here


            if (iter.next() == c) {
                break;
            }
            index++;
        }
        AbstractOrderedLayout inner = createAddRemove(ol, width,
                String.valueOf(suffix++));
        ol.addComponent(inner, index);
        if (width.contains("%")) {
            ol.setExpandRatio(inner, 1.0f);
        }
View Full Code Here

        addOL("l5,r10,t20,b40,vs20,hs40", "ticket1904", false);
        addOL("l5,r10,t20,b40,vs20,hs40", "ticket1904", true);
    }

    private void addOL(String descr, String style, boolean horizontal) {
        AbstractOrderedLayout ol;
        if (horizontal) {
            ol = new HorizontalLayout();
        } else {
            ol = new VerticalLayout();
        }
        ol.setMargin(true);
        ol.setSpacing(true);
        if (style != null) {
            ol.setStyleName(style);
        }
        ol.addComponent(new Label(descr));
        for (int i = 0; i < 3; i++) {
            Button b = new Button("Row " + (i + 1));
            if (!horizontal) {
                b.setWidth("500px");
            }
            ol.addComponent(b);
        }
        getMainWindow().addComponent(ol);
    }
View Full Code Here

                new ValueChangeListener() {
                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        Object value = event.getProperty().getValue();

                        AbstractOrderedLayout newLayout;
                        if (value.equals("Horizontal")) {
                            newLayout = new HorizontalLayout();
                        } else {
                            newLayout = new VerticalLayout();
                        }

                        while (currentLayout.getComponentCount() > 0) {
                            Component child = currentLayout.getComponent(0);
                            Alignment alignment = currentLayout
                                    .getComponentAlignment(child);
                            float expRatio = currentLayout
                                    .getExpandRatio(child);
                            newLayout.addComponent(child);
                            newLayout.setExpandRatio(child, expRatio);
                            newLayout.setComponentAlignment(child, alignment);

                        }
                        newLayout.setStyleName("theLayout");

                        newLayout.setHeight(currentLayout.getHeight(),
                                currentLayout.getHeightUnits());
                        newLayout.setWidth(currentLayout.getWidth(),
                                currentLayout.getWidthUnits());

                        newLayout.setMargin(currentLayout.getMargin());
                        newLayout.setSpacing(currentLayout.isSpacing());

                        getLayout().replaceComponent(currentLayout, newLayout);
                        getLayout().setExpandRatio(newLayout, 1);
                        currentLayout = newLayout;
                    }
View Full Code Here

    /**
     * Build Layout for test
     */
    private void buildLayout() {
        for (int i = 0; i < components.length; i++) {
            AbstractOrderedLayout layout = null;
            try {
                layout = (AbstractOrderedLayout) layoutClass.newInstance();
            } catch (InstantiationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            layout.setHeight("300px");
            layout.setWidth("200px");
            layout.addComponent(components[i]);
            layout.setComponentAlignment(components[i], alignments[i]);
            if (i < components.length / 2) {
                l1.addComponent(layout);
            } else {
                l2.addComponent(layout);
            }
View Full Code Here

            addComponent(createSimpleSelector("Expand ratio",
                    new ValueChangeListener() {
                        @Override
                        public void valueChange(ValueChangeEvent event) {
                            AbstractOrderedLayout parent = (AbstractOrderedLayout) getParent();
                            if (parent == null) {
                                return;
                            }
                            String value = event.getProperty().getValue()
                                    .toString();
                            parent.setExpandRatio(SampleChild.this,
                                    Float.parseFloat(value));
                        }
                    }, "0", "1", "2"));

            // Why is Alignment not an enum? Now we have to use reflection just
            // to get the different values as hardcoding is never an option! ;)
            List<String> alignmentValues = new ArrayList<String>();
            Field[] fields = Alignment.class.getDeclaredFields();
            for (Field field : fields) {
                if (field.getType() == Alignment.class) {
                    alignmentValues.add(field.getName());
                }
            }
            addComponent(createSimpleSelector("Alignment",
                    new ValueChangeListener() {
                        @Override
                        public void valueChange(ValueChangeEvent event) {
                            String value = event.getProperty().getValue()
                                    .toString();
                            AlignmentHandler parent = (AlignmentHandler) getParent();
                            if (parent == null) {
                                return;
                            }
                            try {
                                Field field = Alignment.class
                                        .getDeclaredField(value);
                                Alignment alignment = (Alignment) field
                                        .get(null);
                                parent.setComponentAlignment(SampleChild.this,
                                        alignment);
                            } catch (Exception e) {
                                throw new RuntimeException(e);
                            }
                        }
View Full Code Here

            if (invalidHeight) {
                Stack<ComponentInfo> attributes = null;
                String msg = "";
                // set proper error messages
                if (parent instanceof AbstractOrderedLayout) {
                    AbstractOrderedLayout ol = (AbstractOrderedLayout) parent;
                    boolean vertical = false;

                    if (ol instanceof VerticalLayout) {
                        vertical = true;
                    }

                    if (vertical) {
                        msg = "Component with relative height inside a VerticalLayout with no height defined.";
                        attributes = getHeightAttributes(component);
                    } else {
                        msg = "At least one of a HorizontalLayout's components must have non relative height if the height of the layout is not defined";
                        attributes = getHeightAttributes(component);
                    }
                } else if (parent instanceof GridLayout) {
                    msg = "At least one of the GridLayout's components in each row should have non relative height if the height of the layout is not defined.";
                    attributes = getHeightAttributes(component);
                } else {
                    // default error for non sized parent issue
                    msg = "A component with relative height needs a parent with defined height.";
                    attributes = getHeightAttributes(component);
                }
                printServerError(msg, attributes, false, serverErrorStream);
                clientJSON.append(",\"heightMsg\":\"" + msg + "\"");
            }
            if (invalidWidth) {
                Stack<ComponentInfo> attributes = null;
                String msg = "";
                if (parent instanceof AbstractOrderedLayout) {
                    AbstractOrderedLayout ol = (AbstractOrderedLayout) parent;
                    boolean horizontal = true;

                    if (ol instanceof VerticalLayout) {
                        horizontal = false;
                    }
View Full Code Here

        if (parent.getWidth() < 0) {
            // Undefined width

            if (parent instanceof AbstractOrderedLayout) {
                AbstractOrderedLayout ol = (AbstractOrderedLayout) parent;
                boolean horizontal = true;
                if (ol instanceof OrderedLayout) {
                    if (((OrderedLayout) ol).getOrientation() == OrderedLayout.ORIENTATION_VERTICAL) {
                        horizontal = false;
                    }
View Full Code Here

            if (invalidHeight) {
                Stack<ComponentInfo> attributes = null;
                String msg = "";
                // set proper error messages
                if (parent instanceof AbstractOrderedLayout) {
                    AbstractOrderedLayout ol = (AbstractOrderedLayout) parent;
                    boolean vertical = false;

                    if (ol instanceof OrderedLayout) {
                        if (((OrderedLayout) ol).getOrientation() == OrderedLayout.ORIENTATION_VERTICAL) {
                            vertical = true;
                        }
                    } else if (ol instanceof VerticalLayout) {
                        vertical = true;
                    }

                    if (vertical) {
                        msg = "Component with relative height inside a VerticalLayout with no height defined.";
                        attributes = getHeightAttributes(component);
                    } else {
                        msg = "At least one of a HorizontalLayout's components must have non relative height if the height of the layout is not defined";
                        attributes = getHeightAttributes(component);
                    }
                } else if (parent instanceof GridLayout) {
                    msg = "At least one of the GridLayout's components in each row should have non relative height if the height of the layout is not defined.";
                    attributes = getHeightAttributes(component);
                } else {
                    // default error for non sized parent issue
                    msg = "A component with relative height needs a parent with defined height.";
                    attributes = getHeightAttributes(component);
                }
                printServerError(msg, attributes, false, serverErrorStream);
                clientJSON.print(",\"heightMsg\":\"" + msg + "\"");
            }
            if (invalidWidth) {
                Stack<ComponentInfo> attributes = null;
                String msg = "";
                if (parent instanceof AbstractOrderedLayout) {
                    AbstractOrderedLayout ol = (AbstractOrderedLayout) parent;
                    boolean horizontal = true;

                    if (ol instanceof OrderedLayout) {
                        if (((OrderedLayout) ol).getOrientation() == OrderedLayout.ORIENTATION_VERTICAL) {
                            horizontal = false;
View Full Code Here

     * @param ratio
     * @see AbstractOrderedLayout
     */
    public void expand(Component component, float ratio) {
        if (cc instanceof AbstractOrderedLayout) {
            AbstractOrderedLayout l = (AbstractOrderedLayout) cc;
            l.setExpandRatio(component, ratio);
        }
    }
View Full Code Here

TOP

Related Classes of com.vaadin.ui.AbstractOrderedLayout

Copyright © 2018 www.massapicom. 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.