本文整理汇总了Java中com.vaadin.server.Sizeable.Unit类的典型用法代码示例。如果您正苦于以下问题:Java Unit类的具体用法?Java Unit怎么用?Java Unit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Unit类属于com.vaadin.server.Sizeable包,在下文中一共展示了Unit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void test() {
Person p1 = new Person(1, "John", LocalDate.of(1990, Month.JANUARY, 2));
Person p2 = new Person(1, "George", LocalDate.of(1991, Month.JUNE, 19));
Person p3 = new Person(1, "Tim", LocalDate.of(1995, Month.APRIL, 7));
SerializablePredicate<Person> predicate = this::isBeforeJan1992;
FRadioButtonGroup<Person> radio = new FRadioButtonGroup<Person>().withCaption("My ComboBox", true)
.withWidth(300, Unit.PIXELS)
.withItems(p1, p2, p3)
.withItemCaptionGenerator(p -> p.getName())
.withItemIconGenerator(p -> VaadinIcons.USER)
.withItemEnabledProvider(predicate);
assertEquals("My ComboBox", radio.getCaption());
assertTrue(radio.isCaptionAsHtml());
assertEquals(300, radio.getWidth(), 0);
assertEquals(Unit.PIXELS, radio.getWidthUnits());
assertEquals(3, ((ListDataProvider<Person>) radio.getDataProvider()).getItems().size());
assertEquals(predicate, radio.getItemEnabledProvider());
}
示例2: testHorizontalSplitPanel
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
@Test
public void testHorizontalSplitPanel() {
VerticalLayout c1 = new VerticalLayout();
VerticalLayout c2 = new VerticalLayout();
FHorizontalSplitPanel panel = new FHorizontalSplitPanel().withFirstComponent(c1)
.withSecondComponent(c2)
.withMinSplitPosition(10, Unit.PERCENTAGE)
.withMaxSplitPosition(90, Unit.PERCENTAGE)
.withSplitPosition(30)
.withLocked(true)
.withSplitPositionChangeListener(event -> System.out.println("pos changed"))
.withSplitterClickListener(event -> System.out.println("splitter clicked"));
assertEquals(c1, panel.getFirstComponent());
assertEquals(c2, panel.getSecondComponent());
assertEquals(10, panel.getMinSplitPosition(), 0);
assertEquals(90, panel.getMaxSplitPosition(), 0);
assertEquals(Unit.PERCENTAGE, panel.getMinSplitPositionUnit());
assertEquals(Unit.PERCENTAGE, panel.getMaxSplitPositionUnit());
assertEquals(30, panel.getSplitPosition(), 0);
assertEquals(Unit.PERCENTAGE, panel.getSplitPositionUnit());
assertTrue(panel.isLocked());
}
示例3: testVerticalSplitPanel
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
@Test
public void testVerticalSplitPanel() {
VerticalLayout c1 = new VerticalLayout();
VerticalLayout c2 = new VerticalLayout();
FVerticalSplitPanel panel = new FVerticalSplitPanel().withFirstComponent(c1)
.withSecondComponent(c2)
.withMinSplitPosition(10, Unit.PERCENTAGE)
.withSplitPosition(30, Unit.PERCENTAGE, true)
.withMaxSplitPosition(90, Unit.PIXELS)
.withLocked(true)
.withSplitPositionChangeListener(event -> System.out.println("pos changed"))
.withSplitterClickListener(event -> System.out.println("splitter clicked"));
assertEquals(c1, panel.getFirstComponent());
assertEquals(c2, panel.getSecondComponent());
assertEquals(10, panel.getMinSplitPosition(), 0);
assertEquals(90, panel.getMaxSplitPosition(), 0);
assertEquals(Unit.PERCENTAGE, panel.getMinSplitPositionUnit());
assertEquals(Unit.PIXELS, panel.getMaxSplitPositionUnit());
assertEquals(30, panel.getSplitPosition(), 0);
assertEquals(Unit.PERCENTAGE, panel.getSplitPositionUnit());
assertTrue(panel.isLocked());
}
示例4: test
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
@Test
public void test() {
FSlider slider = new FSlider().withCaption("My Slider")
.withEnabled(true)
.withWidth("75%")
.withMin(25.0)
.withMax(75.0)
.withResolution(1)
.withOrientation(SliderOrientation.VERTICAL)
.withValue(34.1);
assertEquals("My Slider", slider.getCaption());
assertTrue(slider.isEnabled());
assertEquals(75, slider.getWidth(), 0);
assertEquals(Unit.PERCENTAGE, slider.getWidthUnits());
assertEquals(25, slider.getMin(), 0);
assertEquals(34.1, slider.getValue(), 0);
assertEquals(1, slider.getResolution());
assertEquals(SliderOrientation.VERTICAL, slider.getOrientation());
}
示例5: testItems
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testItems() {
Person p1 = new Person(1, "John", LocalDate.of(1990, Month.JANUARY, 2));
Person p2 = new Person(1, "George", LocalDate.of(1991, Month.JUNE, 19));
Person p3 = new Person(1, "Tim", LocalDate.of(1995, Month.APRIL, 7));
FNativeSelect<Person> select = new FNativeSelect<Person>().withCaption("My NativeSelect", true)
.withWidth(300, Unit.PIXELS)
.withItems(p1, p2, p3)
.withEmptySelectionAllowed(false)
.withEmptySelectionCaption("empty")
.withItemCaptionGenerator(p -> p.getName())
.withVisibleItemCount(5);
assertEquals("My NativeSelect", select.getCaption());
assertTrue(select.isCaptionAsHtml());
assertEquals(300, select.getWidth(), 0);
assertEquals(Unit.PIXELS, select.getWidthUnits());
assertFalse(select.isEmptySelectionAllowed());
assertEquals("empty", select.getEmptySelectionCaption());
assertEquals(5, select.getVisibleItemCount());
assertEquals(3, ((ListDataProvider<Person>) select.getDataProvider()).getItems().size());
}
示例6: testDataProvider
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testDataProvider() {
Person p1 = new Person(1, "John", LocalDate.of(1990, Month.JANUARY, 2));
Person p2 = new Person(1, "George", LocalDate.of(1991, Month.JUNE, 19));
Person p3 = new Person(1, "Tim", LocalDate.of(1995, Month.APRIL, 7));
List<Person> persons = Arrays.asList(p1, p2, p3);
ListDataProvider<Person> dataProvider = DataProvider.ofCollection(persons);
FNativeSelect<Person> select = new FNativeSelect<Person>().withCaption("My NativeSelect")
.withWidth(300, Unit.PIXELS)
.withDataProvider(dataProvider);
assertEquals("My NativeSelect", select.getCaption());
assertFalse(select.isCaptionAsHtml());
assertEquals(300, select.getWidth(), 0);
assertEquals(Unit.PIXELS, select.getWidthUnits());
assertEquals(3, ((ListDataProvider<Person>) select.getDataProvider()).getItems().size());
}
示例7: testDataProvider
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testDataProvider() {
Person p1 = new Person(1, "John", LocalDate.of(1990, Month.JANUARY, 2));
Person p2 = new Person(1, "George", LocalDate.of(1991, Month.JUNE, 19));
Person p3 = new Person(1, "Tim", LocalDate.of(1995, Month.APRIL, 7));
List<Person> persons = Arrays.asList(p1, p2, p3);
ListDataProvider<Person> dataProvider = DataProvider.ofCollection(persons);
FComboBox<Person> combBox = new FComboBox<Person>().withCaption("My ComboBox")
.withWidth(300, Unit.PIXELS)
.withDataProvider(
(item, filterText) -> item.toLowerCase().contains(filterText.toLowerCase()),
dataProvider);
assertEquals("My ComboBox", combBox.getCaption());
assertFalse(combBox.isCaptionAsHtml());
assertEquals(300, combBox.getWidth(), 0);
assertEquals(Unit.PIXELS, combBox.getWidthUnits());
assertEquals(3, ((ListDataProvider<Person>) combBox.getDataProvider()).getItems().size());
}
示例8: setWidth
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
@Override
protected DialogOptions setWidth(Float width, SizeUnit sizeUnit) {
super.setWidth(width, sizeUnit);
if (width != null) {
com.vaadin.ui.Window dialogWindow = asDialogWindow();
if (dialogWindow != null) {
if (width < 0) {
dialogWindow.setWidthUndefined();
component.setWidthUndefined();
getContainer().setWidthUndefined();
} else {
Unit unit = sizeUnit != null
? WebWrapperUtils.toVaadinUnit(sizeUnit)
: Unit.PIXELS;
dialogWindow.setWidth(width, unit);
component.setWidth(100, Unit.PERCENTAGE);
}
}
}
return this;
}
示例9: setHeight
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
@Override
protected DialogOptions setHeight(Float height, SizeUnit sizeUnit) {
super.setHeight(height, sizeUnit);
if (height != null) {
com.vaadin.ui.Window dialogWindow = asDialogWindow();
if (dialogWindow != null) {
if (height < 0) {
dialogWindow.setHeightUndefined();
component.setHeightUndefined();
getContainer().setHeightUndefined();
} else {
Unit unit = sizeUnit != null
? WebWrapperUtils.toVaadinUnit(sizeUnit)
: Unit.PIXELS;
dialogWindow.setHeight(height, unit);
component.setHeight(100, Unit.PERCENTAGE);
}
}
}
return this;
}
示例10: createComponentImpl
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
protected void createComponentImpl() {
if (orientation == SplitPanel.ORIENTATION_HORIZONTAL) {
component = new CubaHorizontalSplitPanel() {
@Override
public void setSplitPosition(float pos, Unit unit, boolean reverse) {
currentPosition = this.getSplitPosition();
inverse = this.isSplitPositionReversed();
super.setSplitPosition(pos, unit, reverse);
}
};
} else {
component = new VerticalSplitPanel() {
@Override
public void setSplitPosition(float pos, Unit unit, boolean reverse) {
currentPosition = this.getSplitPosition();
super.setSplitPosition(pos, unit, reverse);
}
};
}
component.addSplitPositionChangeListener(this::fireSplitPositionChangeListener);
}
示例11: applySettings
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
@Override
public void applySettings(Element element) {
if (!isSettingsEnabled()) {
return;
}
Element e = element.element("position");
if (e != null) {
String value = e.attributeValue("value");
String unit = e.attributeValue("unit");
if (!StringUtils.isBlank(value) && !StringUtils.isBlank(unit)) {
Unit convertedUnit;
if (NumberUtils.isNumber(unit)) {
convertedUnit = convertLegacyUnit(Integer.parseInt(unit));
} else {
convertedUnit = Unit.getUnitFromSymbol(unit);
}
component.setSplitPosition(Float.parseFloat(value), convertedUnit, component.isSplitPositionReversed());
}
}
}
示例12: presentTableData
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
@Override
public void presentTableData(RootResult rootrResult) {
ResultToListConverter resultToListConverter = new ResultToListConverter();
List<Result> resultList = resultToListConverter.apply(rootrResult);
Collections.sort(resultList, new Inverter<>(new ResultComparator()));
Grid<Result> grid = new Grid<>(TABLE_TITLE);
grid.addColumn(result -> result.getName()).setCaption(TABLE_COLUMN_METHOD_NAME).setId(TABLE_COLUMN_METHOD_NAME);
grid.addColumn(result -> result.getValue() + NONE).setCaption(TABLE_COLUMN_VALUE_NAME)
.setId(TABLE_COLUMN_VALUE_NAME);
grid.setColumnOrder(TABLE_COLUMN_METHOD_NAME, TABLE_COLUMN_VALUE_NAME);
grid.setStyleGenerator(result -> {
if (result.getValue() > MAX_ALLOWED_VALUES)
return ERROR_STYLE;
return NONE;
});
grid.setItems(resultList);
grid.setSizeFull();
grid.setWidth(70, Unit.REM);
mainPanel.addComponent(grid);
mainPanel.setComponentAlignment(grid, Alignment.MIDDLE_CENTER);
}
示例13: getCopyPasteLayout
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
private VerticalLayout getCopyPasteLayout() {
VerticalLayout layout = new VerticalLayout();
Label label = new Label("Paste the complete Content of your java-file here:");
layout.addComponent(label);
layout.setComponentAlignment(label, Alignment.TOP_CENTER);
copyPasteTextfield = new TextArea();
copyPasteTextfield.setWordWrap(false);
copyPasteTextfield.setWidth(30.0f, Unit.REM);
copyPasteTextfield.setHeight(30.0f, Unit.REM);
layout.addComponent(copyPasteTextfield);
layout.setComponentAlignment(copyPasteTextfield, Alignment.MIDDLE_CENTER);
Button button = new Button(ADD);
button.addClickListener(x -> addPasteListener.accept(getCopyPasteText()));
layout.addComponent(button);
layout.setComponentAlignment(button, Alignment.BOTTOM_RIGHT);
return layout;
}
示例14: createRowItem
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
protected final void createRowItem(final ResponsiveRow row, final Button button, final String description) {
final CssLayout layout = new CssLayout();
layout.addStyleName("v-layout-content-overview-panel-level2");
Responsive.makeResponsive(layout);
layout.setSizeUndefined();
button.addStyleName("itembox");
button.addStyleName("title");
Responsive.makeResponsive(button);
button.setWidth(100, Unit.PERCENTAGE);
layout.addComponent(button);
final Label descriptionLabel = new Label(description);
descriptionLabel.addStyleName("itembox");
Responsive.makeResponsive(descriptionLabel);
descriptionLabel.setWidth(100, Unit.PERCENTAGE);
layout.addComponent(descriptionLabel);
row.addColumn().withDisplayRules(DISPLAY_SIZE_XS_DEVICE,DISPLAYS_SIZE_XM_DEVICE,DISPLAY_SIZE_MD_DEVICE,DISPLAY_SIZE_LG_DEVICE).withComponent(layout);
}
示例15: createRowComponent
import com.vaadin.server.Sizeable.Unit; //导入依赖的package包/类
protected final void createRowComponent(final ResponsiveRow row, final Component component, final String description) {
final CssLayout layout = new CssLayout();
layout.addStyleName(".v-layout-content-pagemode-panel-level2");
Responsive.makeResponsive(layout);
layout.setSizeUndefined();
final Label descriptionLabel = new Label(description);
descriptionLabel.addStyleName("itembox");
Responsive.makeResponsive(descriptionLabel);
descriptionLabel.setWidth(100, Unit.PERCENTAGE);
layout.addComponent(descriptionLabel);
component.addStyleName("itembox");
component.addStyleName("title");
Responsive.makeResponsive(component);
component.setWidth(100, Unit.PERCENTAGE);
layout.addComponent(component);
row.addColumn().withDisplayRules(DISPLAY_SIZE_XS_DEVICE,DISPLAYS_SIZE_XM_DEVICE,DISPLAY_SIZE_MD_DEVICE,DISPLAY_SIZE_LG_DEVICE).withComponent(layout);
}