本文整理汇总了Java中com.holonplatform.vaadin.components.Components类的典型用法代码示例。如果您正苦于以下问题:Java Components类的具体用法?Java Components怎么用?Java Components使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Components类属于com.holonplatform.vaadin.components包,在下文中一共展示了Components类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectable1
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void selectable1() {
// tag::selectable1[]
SingleSelect<TestData> singleSelect = Components.input.singleSelect(TestData.class).caption("Single select")
.build(); // <1>
singleSelect.setValue(new TestData(1)); // <2>
singleSelect.select(new TestData(1)); // <3>
singleSelect.clear(); // <4>
singleSelect.deselectAll(); // <5>
boolean selected = singleSelect.isSelected(new TestData(1)); // <6>
singleSelect.addSelectionListener(
s -> s.getFirstSelectedItem().ifPresent(i -> Notification.show("Selected: " + i.getId()))); // <7>
// end::selectable1[]
}
示例2: selectable2
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void selectable2() {
// tag::selectable2[]
MultiSelect<TestData> multiSelect = Components.input.multiSelect(TestData.class).caption("Multi select")
.build(); // <1>
Set<TestData> values = new HashSet<>();
values.add(new TestData(1));
values.add(new TestData(2));
multiSelect.setValue(values); // <2>
multiSelect.select(new TestData(3)); // <3>
multiSelect.deselect(new TestData(3)); // <4>
multiSelect.clear(); // <5>
multiSelect.deselectAll(); // <6>
boolean selected = multiSelect.isSelected(new TestData(1)); // <7>
multiSelect.addSelectionListener(s -> Notification.show(s.getAllSelectedItems().stream()
.map(i -> String.valueOf(i.getId())).collect(Collectors.joining(";", "Selected: ", "")))); // <8>
// end::selectable2[]
}
示例3: selectable9
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void selectable9() {
// tag::selectable9[]
Datastore datastore = obtainDatastore();
final PathProperty<Long> ID = PathProperty.create("id", Long.class);
final PathProperty<String> DESCRIPTION = PathProperty.create("description", String.class);
SingleSelect<Long> singleSelect = Components.input.singleSelect(ID) // <1>
.dataSource(datastore, DataTarget.named("testData"), PropertySet.of(ID, DESCRIPTION)) // <2>
.itemCaptionGenerator(propertyBox -> propertyBox.getValue(DESCRIPTION)) // <3>
.build();
singleSelect.setValue(Long.valueOf(1)); // <4>
Long selectedId = singleSelect.getValue(); // <5>
singleSelect.refresh(); // <6>
// end::selectable9[]
}
示例4: listing4
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void listing4() {
// tag::listing4[]
PropertyListing listing = Components.listing.properties(PROPERTIES) //
.header(ID, "Custom ID header") // <1>
.columnHidingAllowed(true) // <2>
.hidable(ID, false) // <3>
.columnReorderingAllowed(true) // <4>
.alignment(ID, ColumnAlignment.RIGHT) // <5>
.hidden(DESCRIPTION, true) // <6>
.resizable(ID, false) // <7>
.width(ID, 100) // <8>
.expandRatio(DESCRIPTION, 1) // <9>
.minWidth(DESCRIPTION, 200) // <10>
.maxWidth(DESCRIPTION, 300) // <11>
.style(ID, (property, item) -> item.getValue(DESCRIPTION) != null ? "empty" : "not-empty") // <12>
.withPropertyReorderListener((properties, userOriginated) -> { // <13>
// ...
}).withPropertyResizeListener((property, widthInPixel, userOriginated) -> { // <14>
// ...
}).withPropertyVisibilityListener((property, hidden, userOriginated) -> { // <15>
// ...
}).build();
// end::listing4[]
}
示例5: listing7
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void listing7() {
// tag::listing7[]
PropertyListing listing = Components.listing.properties(PROPERTIES) //
.selectionMode(SelectionMode.SINGLE) // <1>
.build();
final PropertyBox ITEM = PropertyBox.builder(PROPERTIES).set(ID, 1L).build();
PropertyBox selected = listing.getFirstSelectedItem().orElse(null); // <2>
boolean isSelected = listing.isSelected(ITEM); // <3>
listing.select(ITEM); // <4>
listing.deselectAll(); // <5>
// end::listing7[]
}
示例6: listing10
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void listing10() {
// tag::listing10[]
Datastore datastore = getDatastore();
PropertyListing listing = Components.listing.properties(PROPERTIES) //
.dataSource(datastore, DataTarget.named("test"), ID) // <1>
.commitHandler((addedItems, modifiedItems, removedItems) -> { // <2>
// ...
}).build();
final PropertyBox ITEM = PropertyBox.builder(PROPERTIES).set(ID, 777L).set(DESCRIPTION, "A description")
.build();
listing.addItem(ITEM); // <3>
listing.refreshItem(ITEM); // <4>
listing.removeItem(ITEM); // <5>
// end::listing10[]
}
示例7: listing11
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void listing11() {
// tag::listing11[]
Datastore datastore = getDatastore();
PropertyListing listing = Components.listing.properties(PROPERTIES) //
.dataSource(datastore, DataTarget.named("test"), ID) //
.buffered(true) // <1>
.build();
final PropertyBox ITEM = PropertyBox.builder(PROPERTIES).set(ID, 777L).set(DESCRIPTION, "A description")
.build();
listing.addItem(ITEM); // <2>
listing.refreshItem(ITEM); // <3>
listing.removeItem(ITEM); // <4>
listing.commit(); // <5>
listing.discard(); // <6>
// end::listing11[]
}
示例8: input5
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void input5() {
// tag::input5[]
Input<String> stringInput = Components.input.string().build();
ValidatableInput<String> validatableInput = ValidatableInput.from(stringInput); // <1>
validatableInput.addValidator(Validator.email()); // <2>
validatableInput.addValidator(Validator.max(100)); // <3>
validatableInput.setValidationStatusHandler(e -> { // <4>
if (e.isInvalid()) {
Notification.show(e.getErrorMessage(), Type.ERROR_MESSAGE);
}
});
validatableInput.validate(); // <5>
validatableInput.setValidateOnValueChange(true); // <6>
// end::input5[]
}
示例9: group1
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void group1() {
// tag::group1[]
final PathProperty<Long> ID = PathProperty.create("id", Long.class);
final PathProperty<String> DESCRIPTION = PathProperty.create("description", String.class);
final PropertySet<?> PROPERTIES = PropertySet.of(ID, DESCRIPTION);
PropertyInputGroup group = Components.input.propertyGroup().properties(PROPERTIES) // <1>
.bind(ID, Components.input.number(Long.class).build()) // <2>
.bind(DESCRIPTION, Components.input.string().maxLength(100).build()) // <3>
.build();
group.setValue(PropertyBox.builder(PROPERTIES).set(ID, 1L).set(DESCRIPTION, "TestDescription").build()); // <4>
PropertyBox value = group.getValue(); // <5>
group.addValueChangeListener(e -> { // <6>
PropertyBox changedValue = e.getValue();
});
// end::group1[]
}
示例10: group6
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void group6() {
// tag::group6[]
final PathProperty<Long> ID = PathProperty.create("id", Long.class);
final PathProperty<String> DESCRIPTION = PathProperty.create("description", String.class);
final PropertySet<?> PROPERTIES = PropertySet.of(ID, DESCRIPTION);
PropertyInputGroup group = Components.input.propertyGroup().properties(PROPERTIES) //
.stopValidationAtFirstFailure(true) // <1>
.stopOverallValidationAtFirstFailure(true) // <2>
.validationStatusHandler(validationEvent -> { // <3>
// ...
}).propertiesValidationStatusHandler(validationEvent -> { // <4>
// ...
}).build();
// end::group6[]
}
示例11: form1
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void form1() {
// tag::form1[]
final PathProperty<Long> ID = PathProperty.create("id", Long.class);
final PathProperty<String> DESCRIPTION = PathProperty.create("description", String.class);
final PropertySet<?> PROPERTIES = PropertySet.of(ID, DESCRIPTION);
PropertyInputForm form = Components.input.form(new FormLayout()).properties(PROPERTIES).required(ID).build(); // <1>
form = Components.input.form(new FormLayout()).properties(PROPERTIES).required(ID)
.composer((layout, source) -> { // <2>
source.getValueComponents().forEach(c -> layout.addComponent(c.getComponent()));
}).build();
form.setValue(PropertyBox.builder(PROPERTIES).set(ID, 1L).set(DESCRIPTION, "Test").build()); // <3>
PropertyBox value = form.getValue(); // <4>
// end::form1[]
}
示例12: view2
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void view2() {
// tag::view2[]
final PathProperty<Long> ID = PathProperty.create("id", Long.class);
final PathProperty<String> DESCRIPTION = PathProperty.create("description", String.class);
final PropertySet<?> PROPERTIES = PropertySet.of(ID, DESCRIPTION);
PropertyViewGroup viewGroup = Components.view.propertyGroup().properties(PROPERTIES).build(); // <1>
PropertyViewForm viewForm = Components.view.formVertical().properties(PROPERTIES).build(); // <2>
viewForm = Components.view.form(new FormLayout()).properties(PROPERTIES) //
.composer((layout, source) -> { // <3>
source.getValueComponents().forEach(c -> layout.addComponent(c.getComponent()));
}).build();
viewForm.setValue(PropertyBox.builder(PROPERTIES).set(ID, 1L).set(DESCRIPTION, "Test").build()); // <4>
PropertyBox value = viewForm.getValue(); // <5>
// end::view2[]
}
示例13: dialog1
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
public void dialog1() {
// tag::dialog1[]
Dialog dialog = Components.dialog() // <1>
.draggable(false) // <2>
.closable(true) // <3>
.resizable(true) // <4>
.modal(true) // <5>
.message("Dialog message", "dialog.message.code") // <6>
.okButtonConfigurator(cfg -> cfg.caption("Done").icon(FontAwesome.CHECK_CIRCLE_O)) // <7>
.withCloseListener((window, action) -> { // <8>
// ...
}).build();
dialog.open(); // <9>
dialog.close(); // <10>
// end::dialog1[]
}
示例14: buildActions
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
@Override
protected void buildActions(HorizontalLayout actionsContainer) {
actionsContainer.setSpacing(true);
// yes
final Button btnYes = Components.button().styleName(ValoTheme.BUTTON_PRIMARY)
.caption(Localizable.builder().message(DEFAULT_YES_BUTTON_MESSAGE)
.messageCode(DEFAULT_YES_BUTTON_MESSAGE_CODE).build())
.onClick(e -> onDialogYesButtonClick(e.getButton())).build();
getYesButtonConfigurator().ifPresent(c -> c.configureDialogButton(Components.configure(btnYes)));
actionsContainer.addComponent(btnYes);
actionsContainer.setComponentAlignment(btnYes, Alignment.MIDDLE_LEFT);
if (getWidth() > -1) {
btnYes.setWidth("100%");
}
// no
final Button btnNo = Components.button()
.caption(Localizable.builder().message(DEFAULT_NO_BUTTON_MESSAGE)
.messageCode(DEFAULT_NO_BUTTON_MESSAGE_CODE).build())
.onClick(e -> onDialogNoButtonClick(e.getButton())).build();
getNoButtonConfigurator().ifPresent(c -> c.configureDialogButton(Components.configure(btnNo)));
actionsContainer.addComponent(btnNo);
actionsContainer.setComponentAlignment(btnNo, Alignment.MIDDLE_RIGHT);
if (getWidth() > -1) {
btnNo.setWidth("100%");
}
}
示例15: testDatastoreItemConverter
import com.holonplatform.vaadin.components.Components; //导入依赖的package包/类
@Test
public void testDatastoreItemConverter() {
SingleSelect<String> slt = Components.input.singleSelect(CODE).dataSource(datastore, TARGET, PROPERTIES)
.build();
slt.select("c3");
assertNotNull(slt.getValue());
assertEquals("c3", slt.getValue());
MultiSelect<String> mslt = Components.input.multiSelect(CODE).dataSource(datastore, TARGET, PROPERTIES).build();
mslt.select("c3", "c5");
assertNotNull(mslt.getValue());
assertTrue(mslt.getValue().contains("c3"));
assertTrue(mslt.getValue().contains("c5"));
}