本文整理汇总了Java中com.vaadin.ui.TextField.setPlaceholder方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.setPlaceholder方法的具体用法?Java TextField.setPlaceholder怎么用?Java TextField.setPlaceholder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.ui.TextField
的用法示例。
在下文中一共展示了TextField.setPlaceholder方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateOffHeapGrid
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void updateOffHeapGrid() {
int nRows = offheaps.getValue().intValue() + 1;
// removes rows
for (int r = offheapGrid.getRows(); r > nRows; r--) {
offheapGrid.removeRow(r - 1);
}
// set new row limit
offheapGrid.setRows(nRows);
// add new rows
for (int r = 1; r < nRows; r++) {
if (offheapGrid.getComponent(0, r) == null) {
TextField name = new TextField();
name.setPlaceholder("Name");
name.setValue("offheap-" + r);
TextField memory = new TextField();
memory.setPlaceholder("Size (MB)");
memory.setValue("256");
offheapGrid.addComponent(name, 0, r);
offheapGrid.addComponent(memory, 1, r);
}
}
}
示例2: updateDataRootGrid
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void updateDataRootGrid() {
int header = getDataRootFirstRow();
int nRows = dataRoots.getValue().intValue() + header;
// removes rows
for (int r = dataRootGrid.getRows(); r > nRows; r--) {
dataRootGrid.removeRow(r - 1);
}
// set new row limit
dataRootGrid.setRows(nRows);
// add new rows
for (int r = header; r < nRows; r++) {
if (dataRootGrid.getComponent(0, r) == null) {
TextField id = new TextField();
id.setPlaceholder("ID");
id.setValue("dataroot-" + (r - header + 1));
TextField path = new TextField();
path.setPlaceholder("Location");
path.setValue(new File(baseLocation.getValue(), "data/dataroot-" + (r - header + 1)).getAbsolutePath());
path.setEnabled(false);
id.addValueChangeListener(event -> path.setValue(new File(baseLocation.getValue(), "data/" + event.getValue()).getAbsolutePath()));
path.setWidth(100, Unit.PERCENTAGE);
dataRootGrid.addComponent(id, 0, r, 1, r);
dataRootGrid.addComponent(path, DATAROOT_PATH_COLUMN, r);
}
}
}
示例3: platformBackupWanted
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void platformBackupWanted(boolean wanted) {
int row = getBackupRow();
if (wanted) {
dataRootGrid.insertRow(row);
TextField id = new TextField();
id.setPlaceholder("ID");
id.setValue("BACKUP");
id.setReadOnly(true);
TextField path = new TextField();
path.setPlaceholder("Location");
path.setValue(new File(baseLocation.getValue(), "data/backup").getAbsolutePath());
path.setEnabled(false);
path.setWidth(100, Unit.PERCENTAGE);
dataRootGrid.addComponent(id, 0, row, 1, row);
dataRootGrid.addComponent(path, DATAROOT_PATH_COLUMN, row);
} else {
dataRootGrid.removeRow(row);
}
}
示例4: platformPersistenceWanted
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void platformPersistenceWanted(boolean wanted) {
int row = getPersistenceRow();
if (wanted) {
dataRootGrid.insertRow(row);
TextField id = new TextField();
id.setPlaceholder("ID");
id.setValue("PLATFORM");
id.setReadOnly(true);
TextField path = new TextField();
path.setPlaceholder("Location");
path.setValue(new File(baseLocation.getValue(), "data/platform").getAbsolutePath());
path.setEnabled(false);
path.setWidth(100, Unit.PERCENTAGE);
dataRootGrid.addComponent(id, 0, row, 1, row);
dataRootGrid.addComponent(path, DATAROOT_PATH_COLUMN, row);
} else {
dataRootGrid.removeRow(row);
}
}
示例5: genNumberField
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
public static <T> TextField genNumberField(Binder<T> binder, String propertyId, Converter converter, String inputPrompt) {
final TextField field = new TextField();
field.setWidth("100%");
field.addStyleName(STYLENAME_GRIDCELLFILTER);
field.addStyleName(ValoTheme.TEXTFIELD_TINY);
field.addValueChangeListener(e -> {
if (binder.isValid()) {
field.setComponentError(null);
}
});
binder.forField(field)
.withNullRepresentation("")
// .withValidator(text -> text != null && text.length() > 0, "invalid")
.withConverter(converter)
.bind(propertyId);
field.setPlaceholder(inputPrompt);
return field;
}
示例6: updateKitControls
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void updateKitControls() {
if (kitAwareClassLoaderDelegator.isEEKit()) {
if (kitPathLayout.getRows() == 1) {
final TextField licensePath = new TextField();
licensePath.setWidth(100, Unit.PERCENTAGE);
licensePath.setValue(settings.getLicensePath() == null ? "" : settings.getLicensePath());
licensePath.setPlaceholder("License location");
licensePath.addValueChangeListener(event -> {
try {
displayWarningNotification("License location updated with success !");
String licensePathValue = licensePath.getValue();
if (licensePathValue != null) {
File file = new File(licensePathValue);
if (!file.exists() || !file.isFile()) {
throw new NoSuchFileException("Path does not exist on the system !");
}
}
settings.setLicensePath(event.getValue());
} catch (NoSuchFileException e) {
displayErrorNotification("Kit path could not update !", "Make sure the path points to a valid license file !");
}
});
kitPathLayout.addComponent(licensePath);
}
} else {
if (kitPathLayout.getRows() == 2) {
kitPathLayout.removeRow(1);
}
}
}
示例7: getAllMetricsGrid
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private Grid<MetricsGridRow> getAllMetricsGrid(Map<String, Number> metrics) {
allMetricsRows = metrics.entrySet().stream()
.map(MetricsGridRow::new)
.collect(Collectors.toList());
Grid<MetricsGridRow> grid = new Grid<>(MetricsGridRow.class);
grid.removeAllColumns();
Column<MetricsGridRow, String> nameColumn = grid.addColumn(MetricsGridRow::getName)
.setCaption("Name")
.setExpandRatio(1);
grid.addColumn(MetricsGridRow::getValue).setCaption("Value");
grid.setItems(allMetricsRows);
grid.sort(nameColumn);
grid.setSizeFull();
grid.setRowHeight(40);
TextField filterInput = new TextField();
filterInput.setPlaceholder("filter by metric...");
filterInput.addValueChangeListener(e -> updateMetrics(e.getValue()));
filterInput.setValueChangeMode(ValueChangeMode.LAZY);
filterInput.setSizeFull();
// Header row
HeaderRow filterRow = grid.addHeaderRowAt(grid.getHeaderRowCount());
filterRow.getCell(nameColumn).setComponent(filterInput);
return grid;
}
示例8: initFilterRow
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void initFilterRow(Column<Application, String> appColumn, Column<Application, String> envColumn, Column<Application, String> urlColumn) {
TextField filterApp = new TextField();
TextField filterEnv = new TextField();
TextField filterUrl = new TextField();
filterApp.setPlaceholder("filter by application...");
filterApp.addValueChangeListener(e -> updateApplications(e.getValue(), filterEnv.getValue(), filterUrl.getValue()));
filterApp.setValueChangeMode(ValueChangeMode.LAZY);
filterApp.focus();
filterApp.setSizeFull();
filterEnv.setPlaceholder("filter by environment...");
filterEnv.addValueChangeListener(e -> updateApplications(filterApp.getValue(), e.getValue(), filterUrl.getValue()));
filterEnv.setValueChangeMode(ValueChangeMode.LAZY);
filterEnv.setSizeFull();
filterUrl.setPlaceholder("filter by URL...");
filterUrl.addValueChangeListener(e -> updateApplications(filterApp.getValue(), filterEnv.getValue(), e.getValue()));
filterUrl.setValueChangeMode(ValueChangeMode.LAZY);
filterUrl.setSizeFull();
// Header row
HeaderRow filterRow = grid.addHeaderRowAt(grid.getHeaderRowCount());
filterRow.getCell(appColumn).setComponent(filterApp);
filterRow.getCell(envColumn).setComponent(filterEnv);
filterRow.getCell(urlColumn).setComponent(filterUrl);
}
示例9: AbstractCrudView
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
public AbstractCrudView() {
form = getForm();
grid = getGrid();
service = getDataService();
dataProvider = new CrudDataProvider<>(service, getFilterBy());
filter = new TextField();
filter.setId("filterText");
filter.setPlaceholder("filtre...");
filter.addValueChangeListener(e -> {
listEntries(e.getValue());
});
Button clearFilterButton = new Button(VaadinIcons.CLOSE);
clearFilterButton.setId("clearFilterButton");
clearFilterButton.addClickListener(event -> filter.clear());
filterLayout = new CssLayout(filter, clearFilterButton);
filterLayout.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
initForm();
initGrid();
if (form != null) {
addComponent(title);
if (isCreateAllowed()) {
addComponent(buttonLayout);
}
addComponent(form);
if (isFilterAllowed()) {
addComponent(filterLayout);
}
addComponentsAndExpand(grid);
} else {
if (isFilterAllowed()) {
addComponent(filterLayout);
}
addComponentsAndExpand(grid);
}
}
示例10: addKitControls
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void addKitControls() {
kitControlsLayout = new VerticalLayout();
kitPathLayout = new GridLayout(1, 1);
kitPathLayout.setWidth(100, Unit.PERCENTAGE);
kitPathLayout.setColumnExpandRatio(0, 2);
Label info = new Label();
if (settings.getKitPath() != null) {
info.setValue("Using " + (kitAwareClassLoaderDelegator.isEEKit() ? "Enterprise Kit" : "Open source Kit"));
} else {
info.setValue("Enter Kit location:");
}
TextField kitPath = new TextField();
kitPath.setPlaceholder("Kit location");
kitPath.setWidth("100%");
kitPath.setValue(settings.getKitPath() != null ? settings.getKitPath() : "");
kitPath.addValueChangeListener(event -> {
try {
kitAwareClassLoaderDelegator.setKitPath(kitPath.getValue());
info.setValue("Using " + (kitAwareClassLoaderDelegator.isEEKit() ? "Enterprise" : "Open source") + " Kit");
if (voltronConfigLayout != null) {
voltronConfigLayout.removeAllComponents();
}
if (voltronControlLayout != null) {
voltronControlLayout.removeAllComponents();
}
updateKitControls();
initVoltronConfigLayout();
initVoltronControlLayout();
initRuntimeLayout();
updateServerGrid();
displayWarningNotification("Kit location updated with success !");
} catch (Exception e) {
if (e.getCause() instanceof NoSuchFileException) {
displayErrorNotification("Kit path could not update !", "Make sure the path points to a kit !");
} else {
displayErrorNotification("Kit path could not update !", e);
}
}
});
kitPathLayout.addComponent(kitPath);
kitControlsLayout.addComponent(info);
kitControlsLayout.addComponent(kitPathLayout);
mainLayout.addTab(kitControlsLayout, "STEP 1: KIT");
}
示例11: initGrid
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void initGrid() {
this.grid = new Grid<>(PropertyItem.class);
this.grid.removeAllColumns();
Column<PropertyItem, String> propertyColumn = this.grid.addColumn(PropertyItem::getKey)
.setCaption("Property")
.setExpandRatio(1);
Column<PropertyItem, String> valueColumn = this.grid.addColumn(PropertyItem::getValue)
.setCaption("Value")
.setExpandRatio(1);
Column<PropertyItem, String> originColumn = this.grid.addColumn(PropertyItem::getOrigin).setCaption("Origin");
this.grid.sort(propertyColumn);
this.grid.setSizeFull();
this.grid.setRowHeight(40);
// distinct origin
List<String> origins = this.currentEnv.getProperties().stream()
.map(PropertyItem::getOrigin)
.distinct()
.sorted(String::compareTo)
.collect(Collectors.toList());
// Filters
TextField filterProperty = new TextField();
TextField filterValue = new TextField();
NativeSelect<String> filterOrigin = new NativeSelect<>(null, origins);
filterProperty.setPlaceholder("filter by key...");
filterProperty.addValueChangeListener(e -> updateProperties(e.getValue(), filterValue.getValue(), filterOrigin.getValue()));
filterProperty.setValueChangeMode(ValueChangeMode.LAZY);
filterProperty.focus();
filterProperty.setSizeFull();
filterValue.setPlaceholder("filter by value...");
filterValue.addValueChangeListener(e -> updateProperties(filterProperty.getValue(), e.getValue(), filterOrigin.getValue()));
filterValue.setValueChangeMode(ValueChangeMode.LAZY);
filterValue.setSizeFull();
filterOrigin.addValueChangeListener(e -> updateProperties(filterProperty.getValue(), filterValue.getValue(), e.getValue()));
filterOrigin.setSizeFull();
// Header row
HeaderRow filterRow = grid.addHeaderRowAt(grid.getHeaderRowCount());
filterRow.getCell(propertyColumn).setComponent(filterProperty);
filterRow.getCell(valueColumn).setComponent(filterValue);
filterRow.getCell(originColumn).setComponent(filterOrigin);
}
示例12: enter
import com.vaadin.ui.TextField; //导入方法依赖的package包/类
@Override
public void enter(ViewChangeEvent event) {
pageHelper.setErrorHandler(this);
this.removeAllComponents();
// Get application
int appId = Integer.parseInt(event.getParameters());
Application app = pageHelper.getApp(appId);
// Get loggers config
Optional<Loggers> loggers = getLoggers(app);
if(loggers.isPresent()) {
// Display loggers in a grid
grid = new Grid<>(LoggerGridRow.class);
grid.removeAllColumns();
Column<LoggerGridRow, String> nameColumn = grid.addColumn(LoggerGridRow::getName)
.setCaption("Name")
.setExpandRatio(2);
grid.addComponentColumn(logger -> {
NativeSelect<String> levelsDropdown = new NativeSelect<>(null, loggers.get().getLevels());
levelsDropdown.setEmptySelectionAllowed(false);
levelsDropdown.setSelectedItem(logger.getLevel());
// on selected level
levelsDropdown.addValueChangeListener(value -> {
// change logger level
loggersService.changeLevel(app, logger.getName(), value.getValue());
// refresh data in grid (several loggers might have been impacted)
updateLoggers(app);
Notification.show(
String.format("Logger %s level changed to %s", logger.getName(), value.getValue())
, Notification.Type.TRAY_NOTIFICATION);
});
return levelsDropdown;
}) .setCaption("Level")
.setExpandRatio(1);
grid.setSizeFull();
grid.setRowHeight(40);
grid.setItems(loggersRows);
grid.sort(nameColumn);
// Filter grid by logger name
filterInput = new TextField();
filterInput.setPlaceholder("filter by logger name...");
filterInput.addValueChangeListener(e -> filterLoggers(e.getValue()));
filterInput.setValueChangeMode(ValueChangeMode.LAZY);
filterInput.focus();
filterInput.setSizeFull();
// Header row
HeaderRow filterRow = grid.addHeaderRowAt(grid.getHeaderRowCount());
filterRow.getCell(nameColumn).setComponent(filterInput);
this.addComponent(new PageHeader(app, "Loggers"));
this.addComponent(new Label("Changing a level will update one/many logger(s) level(s)"));
this.addComponent(grid);
} else {
this.addComponent(new PageHeader(app, "Loggers"));
this.addComponent(new Label(String.format("Failed to call %s<br />This endpoint is available since Spring Boot 1.5", app.endpoints().loggers()), ContentMode.HTML));
}
}