Example usage for com.vaadin.ui Slider setValue

List of usage examples for com.vaadin.ui Slider setValue

Introduction

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

Prototype

@Override
public void setValue(Double value) 

Source Link

Document

Sets the value of this object.

Usage

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

License:Apache License

public Sliders() {
    setMargin(true);/*  ww w. java2  s  . co m*/

    Label h1 = new Label("Sliders");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    Slider slider = new Slider("Horizontal");
    slider.setValue(50.0);
    row.addComponent(slider);

    slider = new Slider("Horizontal, sized");
    slider.setValue(50.0);
    slider.setWidth("200px");
    row.addComponent(slider);

    slider = new Slider("Custom handle");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color1");
    row.addComponent(slider);

    slider = new Slider("Custom track");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color2");
    row.addComponent(slider);

    slider = new Slider("Custom indicator");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color3");
    row.addComponent(slider);

    slider = new Slider("No indicator");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("no-indicator");
    row.addComponent(slider);

    slider = new Slider("With ticks (not in IE8 & IE9)");
    slider.setValue(3.0);
    slider.setWidth("200px");
    slider.setMax(4);
    slider.addStyleName("ticks");
    row.addComponent(slider);

    slider = new Slider("Toggle imitation");
    slider.setWidth("50px");
    slider.setResolution(0);
    slider.setMin(0);
    slider.setMax(1);
    row.addComponent(slider);

    slider = new Slider("Vertical");
    slider.setValue(50.0);
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Vertical, sized");
    slider.setValue(50.0);
    slider.setOrientation(SliderOrientation.VERTICAL);
    slider.setHeight("200px");
    row.addComponent(slider);

    slider = new Slider("Custom handle");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color1");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Custom track");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color2");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Custom indicator");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color3");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("No indicator");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("no-indicator");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("With ticks");
    slider.setValue(3.0);
    slider.setHeight("200px");
    slider.setMax(4);
    slider.addStyleName("ticks");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Disabled");
    slider.setValue(50.0);
    slider.setEnabled(false);
    row.addComponent(slider);

    h1 = new Label("Progress Bars");
    h1.addStyleName("h1");
    addComponent(h1);

    row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    pb = new ProgressBar();
    pb.setCaption("Default");
    pb.setWidth("300px");
    // pb.setValue(0.6f);
    row.addComponent(pb);

    pb2 = new ProgressBar();
    pb2.setCaption("Point style");
    pb2.setWidth("300px");
    pb2.addStyleName("point");
    // pb2.setValue(0.6f);
    row.addComponent(pb2);

    if (!ValoThemeUI.isTestMode()) {
        ProgressBar pb3 = new ProgressBar();
        pb3.setIndeterminate(true);
        pb3.setCaption("Indeterminate");
        row.addComponent(pb3);
    }
}

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

License:Apache License

static void configure(Table table, boolean footer, boolean sized, boolean expandRatios, boolean stripes,
        boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact,
        boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) {
    table.setSelectable(true);/*ww  w. j  ava  2 s .  com*/
    table.setMultiSelect(true);
    table.setSortEnabled(true);
    table.setColumnCollapsingAllowed(true);
    table.setColumnReorderingAllowed(true);
    table.setPageLength(6);
    table.addActionHandler(ValoThemeUI.getActionHandler());
    table.setDragMode(TableDragMode.MULTIROW);
    table.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Notification.show(event.getTransferable().toString());
        }
    });
    table.setColumnAlignment(ValoThemeUI.DESCRIPTION_PROPERTY, Align.RIGHT);
    table.setColumnAlignment(ValoThemeUI.INDEX_PROPERTY, Align.CENTER);

    table.removeContainerProperty("textfield");
    table.removeGeneratedColumn("textfield");
    table.removeContainerProperty("button");
    table.removeGeneratedColumn("button");
    table.removeContainerProperty("label");
    table.removeGeneratedColumn("label");
    table.removeContainerProperty("checkbox");
    table.removeGeneratedColumn("checkbox");
    table.removeContainerProperty("datefield");
    table.removeGeneratedColumn("datefield");
    table.removeContainerProperty("combobox");
    table.removeGeneratedColumn("combobox");
    table.removeContainerProperty("optiongroup");
    table.removeGeneratedColumn("optiongroup");
    table.removeContainerProperty("slider");
    table.removeGeneratedColumn("slider");
    table.removeContainerProperty("progress");
    table.removeGeneratedColumn("progress");

    if (componentsInRows) {
        table.addContainerProperty("textfield", TextField.class, null);
        table.addGeneratedColumn("textfield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                TextField tf = new TextField();
                tf.setInputPrompt("Type here");
                // tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("datefield", TextField.class, null);
        table.addGeneratedColumn("datefield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                DateField tf = new DateField();
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("combobox", TextField.class, null);
        table.addGeneratedColumn("combobox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ComboBox tf = new ComboBox();
                tf.setInputPrompt("Select");
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("button", Button.class, null);
        table.addGeneratedColumn("button", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Button b = new Button("Button");
                b.addStyleName("small");
                return b;
            }
        });

        table.addContainerProperty("label", TextField.class, null);
        table.addGeneratedColumn("label", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Label label = new Label("Label component");
                label.setSizeUndefined();
                label.addStyleName("bold");
                return label;
            }
        });

        table.addContainerProperty("checkbox", TextField.class, null);
        table.addGeneratedColumn("checkbox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                CheckBox cb = new CheckBox(null, true);
                return cb;
            }
        });

        table.addContainerProperty("optiongroup", TextField.class, null);
        table.addGeneratedColumn("optiongroup", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                OptionGroup op = new OptionGroup();
                op.addItem("Male");
                op.addItem("Female");
                op.addStyleName("horizontal");
                return op;
            }
        });

        table.addContainerProperty("slider", TextField.class, null);
        table.addGeneratedColumn("slider", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Slider s = new Slider();
                s.setValue(30.0);
                return s;
            }
        });

        table.addContainerProperty("progress", TextField.class, null);
        table.addGeneratedColumn("progress", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ProgressBar bar = new ProgressBar();
                bar.setValue(0.7f);
                return bar;
            }
        });
    }
    table.setFooterVisible(footer);
    if (footer) {
        table.setColumnFooter(ValoThemeUI.CAPTION_PROPERTY, "caption");
        table.setColumnFooter(ValoThemeUI.DESCRIPTION_PROPERTY, "description");
        table.setColumnFooter(ValoThemeUI.ICON_PROPERTY, "icon");
        table.setColumnFooter(ValoThemeUI.INDEX_PROPERTY, "index");
    }

    if (sized) {
        table.setWidth("400px");
        table.setHeight("300px");
    } else {
        table.setSizeUndefined();
    }

    if (expandRatios) {
        if (!sized) {
            table.setWidth("100%");
        }
    }
    table.setColumnExpandRatio(ValoThemeUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0);
    table.setColumnExpandRatio(ValoThemeUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0);

    if (!stripes) {
        table.addStyleName("no-stripes");
    } else {
        table.removeStyleName("no-stripes");
    }

    if (!verticalLines) {
        table.addStyleName("no-vertical-lines");
    } else {
        table.removeStyleName("no-vertical-lines");
    }

    if (!horizontalLines) {
        table.addStyleName("no-horizontal-lines");
    } else {
        table.removeStyleName("no-horizontal-lines");
    }

    if (borderless) {
        table.addStyleName("borderless");
    } else {
        table.removeStyleName("borderless");
    }

    if (!headers) {
        table.addStyleName("no-header");
    } else {
        table.removeStyleName("no-header");
    }

    if (compact) {
        table.addStyleName("compact");
    } else {
        table.removeStyleName("compact");
    }

    if (small) {
        table.addStyleName("small");
    } else {
        table.removeStyleName("small");
    }

    if (!rowIndex && !rowCaption && rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.HIDDEN);
    }

    if (rowIndex) {
        table.setRowHeaderMode(RowHeaderMode.INDEX);
    }

    if (rowCaption) {
        table.setRowHeaderMode(RowHeaderMode.PROPERTY);
        table.setItemCaptionPropertyId(ValoThemeUI.CAPTION_PROPERTY);
    } else {
        table.setItemCaptionPropertyId(null);
    }

    if (rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.ICON_ONLY);
        table.setItemIconPropertyId(ValoThemeUI.ICON_PROPERTY);
    } else {
        table.setItemIconPropertyId(null);
    }
}

From source file:com.etest.valo.Sliders.java

License:Apache License

public Sliders() {
    setMargin(true);/*from   w ww  .  j  a  va2s .com*/

    Label h1 = new Label("Sliders");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    Slider slider = new Slider("Horizontal");
    slider.setValue(50.0);
    row.addComponent(slider);

    slider = new Slider("Horizontal, sized");
    slider.setValue(50.0);
    slider.setWidth("200px");
    row.addComponent(slider);

    slider = new Slider("Custom handle");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color1");
    row.addComponent(slider);

    slider = new Slider("Custom track");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color2");
    row.addComponent(slider);

    slider = new Slider("Custom indicator");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color3");
    row.addComponent(slider);

    slider = new Slider("No indicator");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("no-indicator");
    row.addComponent(slider);

    slider = new Slider("With ticks (not in IE8 & IE9)");
    slider.setValue(3.0);
    slider.setWidth("200px");
    slider.setMax(4);
    slider.addStyleName("ticks");
    row.addComponent(slider);

    slider = new Slider("Toggle imitation");
    slider.setWidth("50px");
    slider.setResolution(0);
    slider.setMin(0);
    slider.setMax(1);
    row.addComponent(slider);

    slider = new Slider("Vertical");
    slider.setValue(50.0);
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Vertical, sized");
    slider.setValue(50.0);
    slider.setOrientation(SliderOrientation.VERTICAL);
    slider.setHeight("200px");
    row.addComponent(slider);

    slider = new Slider("Custom handle");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color1");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Custom track");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color2");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Custom indicator");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color3");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("No indicator");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("no-indicator");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("With ticks");
    slider.setValue(3.0);
    slider.setHeight("200px");
    slider.setMax(4);
    slider.addStyleName("ticks");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Disabled");
    slider.setValue(50.0);
    slider.setEnabled(false);
    row.addComponent(slider);

    h1 = new Label("Progress Bars");
    h1.addStyleName("h1");
    addComponent(h1);

    row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    pb = new ProgressBar();
    pb.setCaption("Default");
    pb.setWidth("300px");
    // pb.setValue(0.6f);
    row.addComponent(pb);

    pb2 = new ProgressBar();
    pb2.setCaption("Point style");
    pb2.setWidth("300px");
    pb2.addStyleName("point");
    // pb2.setValue(0.6f);
    row.addComponent(pb2);

    if (!MainUI.isTestMode()) {
        ProgressBar pb3 = new ProgressBar();
        pb3.setIndeterminate(true);
        pb3.setCaption("Indeterminate");
        row.addComponent(pb3);
    }
}

From source file:com.etest.valo.Tables.java

License:Apache License

static void configure(Table table, boolean footer, boolean sized, boolean expandRatios, boolean stripes,
        boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact,
        boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) {
    table.setSelectable(true);// w w  w . java 2  s .  com
    table.setMultiSelect(true);
    table.setSortEnabled(true);
    table.setColumnCollapsingAllowed(true);
    table.setColumnReorderingAllowed(true);
    table.setPageLength(6);
    table.addActionHandler(MainUI.getActionHandler());
    table.setDragMode(TableDragMode.MULTIROW);
    table.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Notification.show(event.getTransferable().toString());
        }
    });
    table.setColumnAlignment(MainUI.DESCRIPTION_PROPERTY, Align.RIGHT);
    table.setColumnAlignment(MainUI.INDEX_PROPERTY, Align.CENTER);

    table.removeContainerProperty("textfield");
    table.removeGeneratedColumn("textfield");
    table.removeContainerProperty("button");
    table.removeGeneratedColumn("button");
    table.removeContainerProperty("label");
    table.removeGeneratedColumn("label");
    table.removeContainerProperty("checkbox");
    table.removeGeneratedColumn("checkbox");
    table.removeContainerProperty("datefield");
    table.removeGeneratedColumn("datefield");
    table.removeContainerProperty("combobox");
    table.removeGeneratedColumn("combobox");
    table.removeContainerProperty("optiongroup");
    table.removeGeneratedColumn("optiongroup");
    table.removeContainerProperty("slider");
    table.removeGeneratedColumn("slider");
    table.removeContainerProperty("progress");
    table.removeGeneratedColumn("progress");

    if (componentsInRows) {
        table.addContainerProperty("textfield", TextField.class, null);
        table.addGeneratedColumn("textfield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                TextField tf = new TextField();
                tf.setInputPrompt("Type here");
                // tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("datefield", TextField.class, null);
        table.addGeneratedColumn("datefield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                DateField tf = new DateField();
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("combobox", TextField.class, null);
        table.addGeneratedColumn("combobox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ComboBox tf = new ComboBox();
                tf.setInputPrompt("Select");
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("button", Button.class, null);
        table.addGeneratedColumn("button", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Button b = new Button("Button");
                b.addStyleName("small");
                return b;
            }
        });

        table.addContainerProperty("label", TextField.class, null);
        table.addGeneratedColumn("label", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Label label = new Label("Label component");
                label.setSizeUndefined();
                label.addStyleName("bold");
                return label;
            }
        });

        table.addContainerProperty("checkbox", TextField.class, null);
        table.addGeneratedColumn("checkbox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                CheckBox cb = new CheckBox(null, true);
                return cb;
            }
        });

        table.addContainerProperty("optiongroup", TextField.class, null);
        table.addGeneratedColumn("optiongroup", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                OptionGroup op = new OptionGroup();
                op.addItem("Male");
                op.addItem("Female");
                op.addStyleName("horizontal");
                return op;
            }
        });

        table.addContainerProperty("slider", TextField.class, null);
        table.addGeneratedColumn("slider", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Slider s = new Slider();
                s.setValue(30.0);
                return s;
            }
        });

        table.addContainerProperty("progress", TextField.class, null);
        table.addGeneratedColumn("progress", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ProgressBar bar = new ProgressBar();
                bar.setValue(0.7f);
                return bar;
            }
        });
    }
    table.setFooterVisible(footer);
    if (footer) {
        table.setColumnFooter(MainUI.CAPTION_PROPERTY, "caption");
        table.setColumnFooter(MainUI.DESCRIPTION_PROPERTY, "description");
        table.setColumnFooter(MainUI.ICON_PROPERTY, "icon");
        table.setColumnFooter(MainUI.INDEX_PROPERTY, "index");
    }

    if (sized) {
        table.setWidth("400px");
        table.setHeight("300px");
    } else {
        table.setSizeUndefined();
    }

    if (expandRatios) {
        if (!sized) {
            table.setWidth("100%");
        }
    }
    table.setColumnExpandRatio(MainUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0);
    table.setColumnExpandRatio(MainUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0);

    if (!stripes) {
        table.addStyleName("no-stripes");
    } else {
        table.removeStyleName("no-stripes");
    }

    if (!verticalLines) {
        table.addStyleName("no-vertical-lines");
    } else {
        table.removeStyleName("no-vertical-lines");
    }

    if (!horizontalLines) {
        table.addStyleName("no-horizontal-lines");
    } else {
        table.removeStyleName("no-horizontal-lines");
    }

    if (borderless) {
        table.addStyleName("borderless");
    } else {
        table.removeStyleName("borderless");
    }

    if (!headers) {
        table.addStyleName("no-header");
    } else {
        table.removeStyleName("no-header");
    }

    if (compact) {
        table.addStyleName("compact");
    } else {
        table.removeStyleName("compact");
    }

    if (small) {
        table.addStyleName("small");
    } else {
        table.removeStyleName("small");
    }

    if (!rowIndex && !rowCaption && rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.HIDDEN);
    }

    if (rowIndex) {
        table.setRowHeaderMode(RowHeaderMode.INDEX);
    }

    if (rowCaption) {
        table.setRowHeaderMode(RowHeaderMode.PROPERTY);
        table.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    } else {
        table.setItemCaptionPropertyId(null);
    }

    if (rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.ICON_ONLY);
        table.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    } else {
        table.setItemIconPropertyId(null);
    }
}

From source file:com.foo01.ui.ReservationDetailView.java

@Override
protected final void onBecomingVisible() {
    getNavigationBar().setCaption("Detail Rezervace");

    //buttony pod navbarem
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setStyleName("buttonToolBarLayout");
    buttonsLayout.setWidth("100%");

    Button deleteButton = new Button();
    deleteButton.setCaption("SMAZAT");
    deleteButton.setWidth(null);/* w  ww  . j  av a2  s .c  o m*/
    buttonsLayout.addComponent(deleteButton);

    Label plug = new Label();
    buttonsLayout.addComponent(plug);

    Button saveButton = new Button();
    saveButton.setCaption("ULOIT");
    saveButton.setWidth(null);
    buttonsLayout.addComponent(saveButton);
    buttonsLayout.setExpandRatio(plug, 1.0f);
    List<Source> sourcesList = MockSource.mockSources();

    //combobox na zdroje a jmeno uzivatele
    HorizontalLayout sourceAndNameLayout = new HorizontalLayout();
    sourceAndNameLayout.setWidth("100%");
    sourceAndNameLayout.setStyleName("sourceAndNameLayout");

    NativeSelect select = new NativeSelect();
    select.setNullSelectionAllowed(false);
    System.out.println(Page.getCurrent().getBrowserWindowWidth());
    String width = Page.getCurrent().getBrowserWindowWidth() / 2.5 + "px";
    select.setWidth(width);
    select.addItems(sourcesList);
    for (Source s : sourcesList) {
        if (reservation.getSource().equals(s)) {
            select.select(s);
            break;
        }
    }
    sourceAndNameLayout.addComponent(select);

    Label plug2 = new Label();
    sourceAndNameLayout.addComponent(plug2);

    Label name = new Label(reservation.getUser());
    name.setWidth(null);
    sourceAndNameLayout.addComponent(name);
    sourceAndNameLayout.setExpandRatio(plug2, 1.0f);

    //datepickery
    DatePicker dateFrom = new DatePicker();
    dateFrom.setStyleName("datePickerDetailView");
    dateFrom.setValue(reservation.getBeginning());
    dateFrom.setUseNative(true);
    dateFrom.setResolution(Resolution.TIME);
    dateFrom.setWidth("100%");

    DatePicker dateTo = new DatePicker();
    dateTo.setStyleName("datePickerDetailView");
    dateTo.setValue(reservation.getEnding());
    dateTo.setUseNative(true);
    dateTo.setResolution(Resolution.TIME);
    dateTo.setWidth("100%");

    //layout pro slider a popisky
    HorizontalLayout sliderLayout = new HorizontalLayout();
    sliderLayout.setStyleName("sliderLayout");
    sliderLayout.setWidth("100%");
    sliderLayout.setSpacing(true);

    Label sliderCaption = new Label("Po?et: ");
    sliderCaption.addStyleName("sliderCaption");
    sliderCaption.setWidth(null);
    sliderLayout.addComponent(sliderCaption);

    final Label horvalue = new Label();
    horvalue.setWidth("45px");
    horvalue.setStyleName("value");
    sliderLayout.addComponent(horvalue);

    final Slider horslider = new Slider(1, 10);
    horslider.setOrientation(SliderOrientation.HORIZONTAL);
    horslider.setValue(Double.valueOf(1));
    horslider.getState();
    horslider.getValue();
    horslider.setImmediate(true);
    horslider.setWidth("100%");
    sliderLayout.addComponent(horslider);
    sliderLayout.setExpandRatio(horslider, 1.0f);

    horvalue.setValue(String.valueOf(horslider.getValue().intValue()));

    horslider.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            int value = horslider.getValue().intValue();

            horvalue.setValue(String.valueOf(value));
        }
    });

    //switch schvaleno
    HorizontalLayout switchLayout = new HorizontalLayout();
    switchLayout.setStyleName("switchLayout");
    switchLayout.addComponent(new Label("Schvleno:"));
    switchLayout.setSpacing(true);
    Switch checkbox = new Switch(null, true);
    switchLayout.addComponent(checkbox);

    //popis rezervace
    TextArea description = new TextArea();
    description.setStyleName("descriptionDetailView");

    description.setWidth("100%");
    description.setImmediate(false);
    description.setCaption("Popis:");
    description.setValue(reservation.getDescription());
    //description.setRequired(true);
    description.setRequiredError("Popis mus bt zadn!");
    description.setNullRepresentation("");
    description.setReadOnly(true);
    //description.setRows(0);

    final VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    content.setStyleName(width);
    content.addComponent(buttonsLayout);
    content.addComponent(sourceAndNameLayout);
    content.addComponent(dateFrom);
    content.addComponent(dateTo);

    content.addComponent(sliderLayout);
    content.addComponent(switchLayout);
    content.addComponent(description);

    setContent(content);
}

From source file:com.foo01.ui.ReservationView.java

@Override
protected final void onBecomingVisible() {
    getNavigationBar().setCaption("Detail Rezervace");

    //buttony pod navbarem
    //        HorizontalLayout buttonsLayout = new HorizontalLayout();
    //        buttonsLayout.setStyleName("buttonToolBarLayout");
    //        buttonsLayout.setWidth("100%");
    ///*from   w  w w  .j  ava 2s.  c  o m*/
    //        Button deleteButton = new Button();
    //        deleteButton.setCaption("SMAZAT");
    //        deleteButton.setWidth(null);
    //        buttonsLayout.addComponent(deleteButton);
    //
    //        Label plug = new Label();
    //        buttonsLayout.addComponent(plug);
    //
    //        Button saveButton = new Button();
    //        saveButton.setCaption("ULOIT");
    //        saveButton.setWidth(null);
    //        buttonsLayout.addComponent(saveButton);
    //        buttonsLayout.setExpandRatio(plug, 1.0f);  

    //combobox na zdroje a jmeno uzivatele
    List<Source> sourcesList = MockSource.mockSources();
    HorizontalLayout sourceAndNameLayout = new HorizontalLayout();
    sourceAndNameLayout.setWidth("100%");
    sourceAndNameLayout.setStyleName("sourceAndNameLayout");

    NativeSelect select = new NativeSelect();
    select.setNullSelectionAllowed(false);
    System.out.println(Page.getCurrent().getBrowserWindowWidth());
    String width = Page.getCurrent().getBrowserWindowWidth() / 2.5 + "px";
    select.setWidth(width);
    select.addItems(sourcesList);
    for (Source s : sourcesList) {
        if (reservation.getSource().equals(s)) {
            select.select(s);
            break;
        }
    }
    sourceAndNameLayout.addComponent(select);

    Label plug2 = new Label();
    sourceAndNameLayout.addComponent(plug2);

    Label name = new Label(reservation.getUser());
    name.setWidth(null);
    sourceAndNameLayout.addComponent(name);
    sourceAndNameLayout.setExpandRatio(plug2, 1.0f);

    //datepickery
    DatePicker dateFrom = new DatePicker();
    dateFrom.setStyleName("datePickerDetailView");
    dateFrom.setValue(reservation.getBeginning());
    dateFrom.setUseNative(true);
    dateFrom.setResolution(Resolution.TIME);
    dateFrom.setWidth("100%");

    DatePicker dateTo = new DatePicker();
    dateTo.setStyleName("datePickerDetailView");
    dateTo.setValue(reservation.getEnding());
    dateTo.setUseNative(true);
    dateTo.setResolution(Resolution.TIME);
    dateTo.setWidth("100%");

    //layout pro slider a popisky
    HorizontalLayout sliderLayout = new HorizontalLayout();
    sliderLayout.setStyleName("sliderLayout");
    sliderLayout.setWidth("100%");
    sliderLayout.setSpacing(true);

    Label sliderCaption = new Label("Po?et: ");
    sliderCaption.addStyleName("sliderCaption");
    sliderCaption.setWidth(null);
    sliderLayout.addComponent(sliderCaption);

    final Label horvalue = new Label();
    horvalue.setWidth("45px");
    horvalue.setStyleName("value");
    sliderLayout.addComponent(horvalue);

    final Slider horslider = new Slider(1, 10);
    horslider.setOrientation(SliderOrientation.HORIZONTAL);
    horslider.setValue(Double.valueOf(1));
    horslider.getState();
    horslider.getValue();
    horslider.setImmediate(true);
    horslider.setWidth("100%");
    sliderLayout.addComponent(horslider);
    sliderLayout.setExpandRatio(horslider, 1.0f);

    horvalue.setValue(String.valueOf(horslider.getValue().intValue()));

    horslider.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            int value = horslider.getValue().intValue();

            horvalue.setValue(String.valueOf(value));
        }
    });

    //switch schvaleno
    HorizontalLayout switchLayout = new HorizontalLayout();
    switchLayout.setStyleName("switchLayout");
    switchLayout.addComponent(new Label("Schvleno:"));
    switchLayout.setSpacing(true);
    Switch checkbox = new Switch(null, true);
    switchLayout.addComponent(checkbox);

    //popis rezervace
    TextArea description = new TextArea();
    description.setStyleName("descriptionDetailView");

    description.setWidth("100%");
    description.setImmediate(false);
    description.setCaption("Popis:");
    description.setValue(reservation.getDescription());
    //description.setRequired(true);
    description.setRequiredError("Popis mus bt zadn!");
    description.setNullRepresentation("");
    description.setReadOnly(true);
    //description.setRows(0);

    final VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    content.addComponent(new ButtonToolBarLayout(this));
    content.addComponent(sourceAndNameLayout);
    content.addComponent(dateFrom);
    content.addComponent(dateTo);

    content.addComponent(sliderLayout);
    content.addComponent(switchLayout);
    content.addComponent(description);

    setContent(content);
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * This method set rate for current track.
 * /*from  w w  w.j  a v  a 2 s.c  om*/
 * @return Slider element with proper value.
 */
private Slider setRate() {
    // TODO: Add this element to database.
    Slider slider = new Slider("Rate the track:");
    slider.setWidth("130px");

    try {
        slider.setValue(0.0);
    } catch (ValueOutOfBoundsException e) {
        // Ignore
    }

    return slider;
}

From source file:com.rex.components.valo.Sliders.java

License:Apache License

public Sliders() {
    setMargin(true);//  www  .j a v  a 2  s.  c  o  m

    Label h1 = new Label("Sliders");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    Slider slider = new Slider("Horizontal");
    slider.setValue(50.0);
    row.addComponent(slider);

    slider = new Slider("Horizontal, sized");
    slider.setValue(50.0);
    slider.setWidth("200px");
    row.addComponent(slider);

    slider = new Slider("Custom handle");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color1");
    row.addComponent(slider);

    slider = new Slider("Custom track");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color2");
    row.addComponent(slider);

    slider = new Slider("Custom indicator");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color3");
    row.addComponent(slider);

    slider = new Slider("No indicator");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("no-indicator");
    row.addComponent(slider);

    slider = new Slider("With ticks (not in IE8 & IE9)");
    slider.setValue(3.0);
    slider.setWidth("200px");
    slider.setMax(4);
    slider.addStyleName("ticks");
    row.addComponent(slider);

    slider = new Slider("Toggle imitation");
    slider.setWidth("50px");
    slider.setResolution(0);
    slider.setMin(0);
    slider.setMax(1);
    row.addComponent(slider);

    slider = new Slider("Vertical");
    slider.setValue(50.0);
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Vertical, sized");
    slider.setValue(50.0);
    slider.setOrientation(SliderOrientation.VERTICAL);
    slider.setHeight("200px");
    row.addComponent(slider);

    slider = new Slider("Custom handle");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color1");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Custom track");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color2");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Custom indicator");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color3");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("No indicator");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("no-indicator");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("With ticks");
    slider.setValue(3.0);
    slider.setHeight("200px");
    slider.setMax(4);
    slider.addStyleName("ticks");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Disabled");
    slider.setValue(50.0);
    slider.setEnabled(false);
    row.addComponent(slider);

    h1 = new Label("Progress Bars");
    h1.addStyleName("h1");
    addComponent(h1);

    row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    pb = new ProgressBar();
    pb.setCaption("Default");
    pb.setWidth("300px");
    // pb.setValue(0.6f);
    row.addComponent(pb);

    pb2 = new ProgressBar();
    pb2.setCaption("Point style");
    pb2.setWidth("300px");
    pb2.addStyleName("point");
    // pb2.setValue(0.6f);
    row.addComponent(pb2);

    if (!ReportEngineUI.isTestMode()) {
        ProgressBar pb3 = new ProgressBar();
        pb3.setIndeterminate(true);
        pb3.setCaption("Indeterminate");
        row.addComponent(pb3);
    }
}

From source file:com.rex.components.valo.Tables.java

License:Apache License

static void configure(Table table, Grid grid, boolean footer, boolean sized, boolean expandRatios,
        boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers,
        boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon,
        boolean componentsInRows) {

    table.setSelectable(true);/*from   w  w w  .  java2s.  c  om*/
    table.setMultiSelect(true);
    grid.setSelectionMode(SelectionMode.MULTI);

    table.setSortEnabled(true);
    for (Column c : grid.getColumns()) {
        if (!c.getPropertyId().equals("icon")) {
            c.setSortable(true);
        }
        c.setHidable(true);
    }

    table.setColumnCollapsingAllowed(true);
    table.setColumnReorderingAllowed(true);
    grid.setColumnReorderingAllowed(true);

    table.setPageLength(6);
    grid.setHeightByRows(6);

    table.addActionHandler(ReportEngineUI.getActionHandler());
    table.setDragMode(TableDragMode.MULTIROW);
    table.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Notification.show(event.getTransferable().toString());
        }
    });
    table.setColumnAlignment(ReportEngineUI.DESCRIPTION_PROPERTY, Align.RIGHT);
    table.setColumnAlignment(ReportEngineUI.INDEX_PROPERTY, Align.CENTER);

    table.removeContainerProperty("textfield");
    table.removeGeneratedColumn("textfield");
    table.removeContainerProperty("button");
    table.removeGeneratedColumn("button");
    table.removeContainerProperty("label");
    table.removeGeneratedColumn("label");
    table.removeContainerProperty("checkbox");
    table.removeGeneratedColumn("checkbox");
    table.removeContainerProperty("datefield");
    table.removeGeneratedColumn("datefield");
    table.removeContainerProperty("combobox");
    table.removeGeneratedColumn("combobox");
    table.removeContainerProperty("optiongroup");
    table.removeGeneratedColumn("optiongroup");
    table.removeContainerProperty("slider");
    table.removeGeneratedColumn("slider");
    table.removeContainerProperty("progress");
    table.removeGeneratedColumn("progress");

    if (componentsInRows) {
        table.addContainerProperty("textfield", TextField.class, null);
        table.addGeneratedColumn("textfield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                TextField tf = new TextField();
                tf.setInputPrompt("Type here");
                // tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("datefield", TextField.class, null);
        table.addGeneratedColumn("datefield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                DateField tf = new DateField();
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("combobox", TextField.class, null);
        table.addGeneratedColumn("combobox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ComboBox tf = new ComboBox();
                tf.setInputPrompt("Select");
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("button", Button.class, null);
        table.addGeneratedColumn("button", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Button b = new Button("Button");
                b.addStyleName("small");
                return b;
            }
        });

        table.addContainerProperty("label", TextField.class, null);
        table.addGeneratedColumn("label", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Label label = new Label("Label component");
                label.setSizeUndefined();
                label.addStyleName("bold");
                return label;
            }
        });

        table.addContainerProperty("checkbox", TextField.class, null);
        table.addGeneratedColumn("checkbox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                CheckBox cb = new CheckBox(null, true);
                return cb;
            }
        });

        table.addContainerProperty("optiongroup", TextField.class, null);
        table.addGeneratedColumn("optiongroup", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                OptionGroup op = new OptionGroup();
                op.addItem("Male");
                op.addItem("Female");
                op.addStyleName("horizontal");
                return op;
            }
        });

        table.addContainerProperty("slider", TextField.class, null);
        table.addGeneratedColumn("slider", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Slider s = new Slider();
                s.setValue(30.0);
                return s;
            }
        });

        table.addContainerProperty("progress", TextField.class, null);
        table.addGeneratedColumn("progress", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ProgressBar bar = new ProgressBar();
                bar.setValue(0.7f);
                return bar;
            }
        });
    }
    table.setFooterVisible(footer);
    if (footer) {
        table.setColumnFooter(ReportEngineUI.CAPTION_PROPERTY, "caption");
        table.setColumnFooter(ReportEngineUI.DESCRIPTION_PROPERTY, "description");
        table.setColumnFooter(ReportEngineUI.ICON_PROPERTY, "icon");
        table.setColumnFooter(ReportEngineUI.INDEX_PROPERTY, "index");
    }

    if (sized) {
        table.setWidth("400px");
        grid.setWidth("400px");
        table.setHeight("300px");
        grid.setHeight("300px");
    } else {
        table.setSizeUndefined();
        grid.setSizeUndefined();
    }

    if (componentsInRows) {
        table.setWidth("100%");
    } else {
        table.setWidth(null);
    }

    if (expandRatios) {
        if (!sized) {
            table.setWidth("100%");
        }
    }
    table.setColumnExpandRatio(ReportEngineUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0);
    table.setColumnExpandRatio(ReportEngineUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0);

    if (!stripes) {
        table.addStyleName("no-stripes");
    } else {
        table.removeStyleName("no-stripes");
    }

    if (!verticalLines) {
        table.addStyleName("no-vertical-lines");
    } else {
        table.removeStyleName("no-vertical-lines");
    }

    if (!horizontalLines) {
        table.addStyleName("no-horizontal-lines");
    } else {
        table.removeStyleName("no-horizontal-lines");
    }

    if (borderless) {
        table.addStyleName("borderless");
    } else {
        table.removeStyleName("borderless");
    }

    if (!headers) {
        table.addStyleName("no-header");
    } else {
        table.removeStyleName("no-header");
    }

    if (compact) {
        table.addStyleName("compact");
    } else {
        table.removeStyleName("compact");
    }

    if (small) {
        table.addStyleName("small");
    } else {
        table.removeStyleName("small");
    }

    if (!rowIndex && !rowCaption && rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.HIDDEN);
    }

    if (rowIndex) {
        table.setRowHeaderMode(RowHeaderMode.INDEX);
    }

    if (rowCaption) {
        table.setRowHeaderMode(RowHeaderMode.PROPERTY);
        table.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    } else {
        table.setItemCaptionPropertyId(null);
    }

    if (rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.ICON_ONLY);
        table.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    } else {
        table.setItemIconPropertyId(null);
    }
}

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.WidgetTestApplication.java

License:Apache License

private void addUploadSpeedSlider() {
    final Slider slider = new Slider("Delay (ms)");
    slider.setWidth("200px");
    slider.setImmediate(true);//from   www .j ava  2s  .c o  m
    slider.setMin(0);
    slider.setMax(1000);
    slider.setValue(uploadSpeed);
    slider.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            uploadSpeed = slider.getValue();
        }
    });
    form.addComponent(slider);
}