List of usage examples for com.vaadin.ui Slider Slider
public Slider()
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);/*w w w .j a v a 2s . co m*/ 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.esofthead.mycollab.module.project.ui.components.TaskSliderField.java
License:Open Source License
public TaskSliderField() { progressLbl = new Label(); progressLbl.setWidthUndefined();/*from w ww . jav a 2 s . co m*/ slider = new Slider(); slider.setOrientation(SliderOrientation.HORIZONTAL); slider.setImmediate(true); slider.setWidth("150px"); slider.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { Double value = (Double) valueChangeEvent.getProperty().getValue(); if (value != null) { double roundValue = Math.ceil(value / 10) * 10; slider.setValue(roundValue); progressLbl.setValue(roundValue + "%"); setInternalValue(roundValue); } else { slider.setValue(0d); progressLbl.setValue("0%"); setInternalValue(0d); } } }); body = new MHorizontalLayout(slider, progressLbl); }
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);/*from w ww . j a v a 2s . 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.mycollab.module.project.ui.components.TaskSliderField.java
License:Open Source License
public TaskSliderField() { progressLbl = new Label(); progressLbl.setWidthUndefined();//from w w w . ja v a 2 s . c om slider = new Slider(); slider.setOrientation(SliderOrientation.HORIZONTAL); slider.setImmediate(true); slider.setWidth("150px"); slider.addValueChangeListener(valueChangeEvent -> { Double value = (Double) valueChangeEvent.getProperty().getValue(); if (value != null) { double roundValue = Math.ceil(value / 10) * 10; slider.setValue(roundValue); progressLbl.setValue(roundValue + "%"); setInternalValue(roundValue); } else { slider.setValue(0d); progressLbl.setValue("0%"); setInternalValue(0d); } }); body = new MHorizontalLayout(slider, progressLbl); }
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 ww w . ja v a2s . 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:kn.uni.gis.ui.GameComposite.java
License:Apache License
@AutoGenerated private VerticalLayout buildVerticalLayout_2() { // common part: create layout verticalLayout_2 = new VerticalLayout(); verticalLayout_2.setImmediate(false); verticalLayout_2.setWidth("-1px"); verticalLayout_2.setHeight("-1px"); verticalLayout_2.setMargin(false);//from w ww .j a v a 2 s . co m // annimated annimated = new CheckBox(); annimated.setCaption("Animated"); annimated.setImmediate(false); annimated.setWidth("-1px"); annimated.setHeight("-1px"); verticalLayout_2.addComponent(annimated); // label_1 label_1 = new Label(); label_1.setCaption("Time"); label_1.setImmediate(false); label_1.setWidth("-1px"); label_1.setHeight("-1px"); label_1.setValue("Label"); verticalLayout_2.addComponent(label_1); // timeSlider timeSlider = new Slider(); timeSlider.setCaption("TimeBar"); timeSlider.setImmediate(false); timeSlider.setWidth("200px"); timeSlider.setHeight("-1px"); verticalLayout_2.addComponent(timeSlider); // speedSlider speedSlider = new Slider(); speedSlider.setCaption("Animation speed"); speedSlider.setImmediate(false); speedSlider.setWidth("200px"); speedSlider.setHeight("-1px"); verticalLayout_2.addComponent(speedSlider); return verticalLayout_2; }
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
Layout getSliderPreviews() throws ValueOutOfBoundsException { Layout grid = getPreviewLayout("Sliders"); Slider s = new Slider(); s.setWidth("200px"); s.setValue(50);//ww w .ja v a2 s. c o m grid.addComponent(s); s = new Slider(); s.setOrientation(Slider.ORIENTATION_VERTICAL); s.setHeight("70px"); s.setValue(50); grid.addComponent(s); return grid; }
From source file:org.inakirj.imagerulette.screens.DiceURLSetupView.java
License:Open Source License
/** * Sets the layout.//from w ww . ja v a2s . c om */ private void setLayout() { imagesLayout = new VerticalComponentGroup(); imagesLayout.setWidth(100, Unit.PERCENTAGE); ImageUtils.getAllImageURL().stream().forEach(i -> { HorizontalLayout sliderLAyout = new HorizontalLayout(); if (imagesLayout.getComponentCount() % 2 == 0) { sliderLAyout.addStyleName("dice-banner-1"); } else { sliderLAyout.addStyleName("dice-banner-2"); } sliderLAyout.setWidth(100, Unit.PERCENTAGE); Image img = new Image("", i.getSource()); img.addStyleName("dice-image"); img.setData(i.getData()); Slider slider = new Slider(); slider.addStyleName("dice-slider"); Label total = new Label(); total.addStyleName("size-24");// TODO is not working // Adding image sliderLAyout.addComponent(img); // Adding slider slider.setMin(0); slider.setMax(5); slider.setWidth(80, Unit.PERCENTAGE); slider.addValueChangeListener(s -> { total.setValue("x " + slider.getValue().intValue()); enableDiceTabOrNot(); }); sliderLAyout.addComponent(slider); // Adding label total.setValue("x 0"); sliderLAyout.addComponent(total); sliderLAyout.setExpandRatio(img, 2); sliderLAyout.setExpandRatio(slider, 7); sliderLAyout.setExpandRatio(total, 1); sliderLAyout.setComponentAlignment(img, Alignment.BOTTOM_LEFT); sliderLAyout.setComponentAlignment(slider, Alignment.BOTTOM_LEFT); sliderLAyout.setComponentAlignment(total, Alignment.BOTTOM_LEFT); // Adding layout imagesLayout.addComponent(sliderLAyout); }); addComponent(imagesLayout); }
From source file:org.lunifera.vaaclipse.ui.preferences.addon.internal.ScaleFieldEditorRenderer.java
License:Open Source License
@Override public void render() { CssLayout layout = new CssLayout(); layout.setWidth("100%"); layout.addComponent(new Label(editor.getLabel())); slider = new Slider(); slider.setWidth("100%"); if (editor.getMaxValue() != null) slider.setMax(editor.getMaxValue().doubleValue()); if (editor.getMinValue() != null) slider.setMin(editor.getMinValue().doubleValue()); try {// w ww . j av a2 s.co m slider.setValue(getValue().doubleValue()); } catch (ValueOutOfBoundsException vo) { } slider.setOrientation(SliderOrientation.HORIZONTAL); layout.addComponent(slider); this.component = layout; }
From source file:org.metawidget.vaadin.ui.widgetbuilder.VaadinWidgetBuilder.java
License:LGPL
public Component buildWidget(String elementName, Map<String, String> attributes, VaadinMetawidget metawidget) { // Hidden//from www . j av a2 s.co m if (TRUE.equals(attributes.get(HIDDEN))) { return new Stub(); } // Action if (ACTION.equals(elementName)) { return new Button(); } // Lookup the Class Class<?> clazz = WidgetBuilderUtils.getActualClassOrType(attributes, String.class); // Support mandatory Booleans (can be rendered as a checkbox, even // though they have a Lookup) if (Boolean.class.equals(clazz) && TRUE.equals(attributes.get(REQUIRED))) { return new CheckBox(); } // Lookups String lookup = attributes.get(LOOKUP); if (lookup != null && !"".equals(lookup)) { return createSelectComponent(attributes, lookup, metawidget); } if (clazz != null) { // Primitives if (clazz.isPrimitive()) { // booleans if (boolean.class.equals(clazz)) { return new CheckBox(); } // chars if (char.class.equals(clazz)) { TextField textField = new TextField(); textField.setMaxLength(1); return textField; } // Ranged String minimumValue = attributes.get(MINIMUM_VALUE); String maximumValue = attributes.get(MAXIMUM_VALUE); if (minimumValue != null && !"".equals(minimumValue) && maximumValue != null && !"".equals(maximumValue)) { Slider slider = new Slider(); slider.setMin(Double.parseDouble(minimumValue)); try { // Use big 'D' Double for Vaadin 6/7 compatibility slider.setValue(Double.valueOf(slider.getMin())); } catch (ValueOutOfBoundsException e) { throw WidgetBuilderException.newException(e); } slider.setMax(Double.parseDouble(maximumValue)); return slider; } // Not-ranged return createTextField(attributes); } // Strings if (String.class.equals(clazz)) { if (TRUE.equals(attributes.get(MASKED))) { return new PasswordField(); } if (TRUE.equals(attributes.get(LARGE))) { return new TextArea(); } return createTextField(attributes); } // Characters if (Character.class.isAssignableFrom(clazz)) { TextField textField = new TextField(); textField.setMaxLength(1); return textField; } // Dates if (Date.class.equals(clazz)) { return new PopupDateField(); } // Numbers // // Note: we use a text field, not a JSpinner or JSlider, because // BeansBinding gets upset at doing 'setValue( null )' if the Integer // is null. We can still use JSpinner/JSliders for primitives, though. if (Number.class.isAssignableFrom(clazz)) { return createTextField(attributes); } // Collections if (Collection.class.isAssignableFrom(clazz)) { return new Stub(); } } // Not simple, but don't expand if (TRUE.equals(attributes.get(DONT_EXPAND))) { return createTextField(attributes); } return null; }