com.vaadin.flow.component.textfield.TextArea Java Examples
The following examples show how to use
com.vaadin.flow.component.textfield.TextArea.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppConfigView.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
VerticalLayout makeConfigForm() { VerticalLayout content = new VerticalLayout(); appName = new TextField("App Name"); appName.setWidth("300px"); configName = new TextField("Key"); configName.setWidth("300px"); configValue = new TextArea("Value"); configValue.setWidth("600px"); HorizontalLayout buttons = new HorizontalLayout(); saveButton = new Button("Save", buttonClickEvent -> { String key = appName.getValue() + ":" + configName.getValue(); AppConfigEvent appConfigEvent = new AppConfigEvent(appName.getValue(), configName.getValue(), configValue.getValue()); configurationService.put(key, configValue.getValue()) .doOnSuccess(aVoid -> Notification.show("Saved Successfully")) .then(brokerManager.broadcast(appConfigEvent.toCloudEvent(URI.create("broker:" + brokerManager.localBroker().getIp())))) .subscribe(); }); content.add(new H3("Key/Value")); content.add(appName); content.add(configName); content.add(configValue); buttons.add(saveButton); buttons.add(new Button("New Configuration", buttonClickEvent -> { clearForm(); })); content.add(buttons); return content; }
Example #2
Source File: AttributesView.java From radman with MIT License | 4 votes |
AttributeEditDialog(AttributeService attributeService, UpdateListener<T> updateListener) { this.attributeService = attributeService; FormLayout formLayout = new FormLayout(); formLayout.add(new H3(getDialogTitle())); TextArea description = new TextArea("Description"); description.setValueChangeMode(ValueChangeMode.EAGER); description.setWidthFull(); binder = new Binder<>(getClazz()); binder.forField(description).bind(AttributeDto::getDescription, AttributeDto::setDescription); Button cancelBtn = new Button("Cancel", event -> setOpened(false)); Button saveBtn = new Button("Save", event -> { BinderValidationStatus<T> validationStatus = binder.validate(); if (validationStatus.isOk()) { try { T attributeDto = binder.getBean(); attributeDto = save(attributeDto); updateListener.onUpdated(this, attributeDto); setOpened(false); } catch (Exception e) { log.warn("Failed to update attribute. Reason = '{}'", e.getMessage()); ErrorNotification.show("Error", "Ooops, something went wrong, try again please"); } } }); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END); controlsLayout.setWidthFull(); controlsLayout.add(cancelBtn); controlsLayout.add(saveBtn); formLayout.add(description); formLayout.add(new Hr()); formLayout.add(controlsLayout); formLayout.setMaxWidth("500px"); add(formLayout); }
Example #3
Source File: NasView.java From radman with MIT License | 4 votes |
NasFormDialog(NasService nasService) { this.nasService = nasService; TextField name = new TextField("Name"); name.setValueChangeMode(ValueChangeMode.EAGER); TextField shortName = new TextField("Short name"); shortName.setValueChangeMode(ValueChangeMode.EAGER); TextField type = new TextField("Type"); type.setValueChangeMode(ValueChangeMode.EAGER); NumberField port = new NumberField("Port"); port.setValueChangeMode(ValueChangeMode.EAGER); PasswordField secret = new PasswordField("Secret"); secret.setValueChangeMode(ValueChangeMode.EAGER); TextField server = new TextField("Server"); server.setValueChangeMode(ValueChangeMode.EAGER); TextField community = new TextField("Community"); community.setValueChangeMode(ValueChangeMode.EAGER); TextArea description = new TextArea("Description"); description.setValueChangeMode(ValueChangeMode.EAGER); FormLayout formLayout = new FormLayout(); formLayout.setWidthFull(); formLayout.setMaxWidth("700px"); formLayout.add(name, shortName, server, port, secret, type, community, description); formLayout.setResponsiveSteps( new FormLayout.ResponsiveStep("0px", 1), new FormLayout.ResponsiveStep("450px", 2)); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END); controlsLayout.add(new Button("Cancel", event -> setOpened(false))); controlsLayout.add(getConfirmBtn()); controlsLayout.setWidthFull(); add(new H3(getDialogTitle())); add(formLayout); add(new Hr()); add(controlsLayout); binder = new BeanValidationBinder<>(NasDto.class); binder.bind(name, "nasName"); binder.bind(shortName, "shortName"); binder.bind(type, "type"); binder.forField(port) .withConverter(new DoubleToIntegerConverter("Port must be number " + "between 1 and " + 65535 + ".")) .bind("ports"); binder.bind(secret, "secret"); binder.bind(server, "server"); binder.bind(community, "community"); binder.bind(description, "description"); }
Example #4
Source File: JwtGeneratorView.java From alibaba-rsocket-broker with Apache License 2.0 | 4 votes |
VerticalLayout makeGeneratorForm() { VerticalLayout content = new VerticalLayout(); appNameText = new TextField("App Name"); appNameText.setWidth("300px"); appNameText.setPlaceholder("your-app-name"); ownersText = new TextField("Owners"); ownersText.setWidth("300px"); orgIdsText = new TextField("Org IDs"); orgIdsText.setPlaceholder("1"); orgIdsText.setWidth("300px"); serviceAccountsText = new TextField("Service Accounts"); serviceAccountsText.setValue("default"); serviceAccountsText.setWidth("300px"); rolesText = new TextField("Roles"); rolesText.setWidth("300px"); rolesText.setValue("user"); authoritiesText = new TextField("Authorities"); rolesText.setWidth("300px"); rolesText.setValue(""); tokenTextArea = new TextArea("JWT Token"); tokenTextArea.setWidth("800px"); tokenTextArea.setHeight("240px"); tokenTextArea.setReadOnly(true); rolesText.setWidth("200px"); HorizontalLayout buttons = new HorizontalLayout(); generateBtn = new Button("Generate", buttonClickEvent -> { String appName = appNameText.getValue(); String[] orgIds = orgIdsText.getValue().trim().split("[,;\\s]*"); String[] serviceAccounts = serviceAccountsText.getValue().trim().split("[,;\\s]*"); String[] owners = ownersText.getValue().trim().split("[,;\\s]*"); String[] roles = rolesText.getValue().trim().split("[,;\\s]*"); String[] authorities = authoritiesText.getValue().trim().split("[,;\\s]*"); try { String token = authenticationService.generateCredentials(UUID.randomUUID().toString(), orgIds, serviceAccounts, roles, authorities, appName, owners); tokenTextArea.setValue(token); } catch (Exception ignore) { } }); content.add(appNameText); content.add(ownersText); content.add(orgIdsText); content.add(serviceAccountsText); content.add(rolesText); content.add(authoritiesText); content.add(tokenTextArea); buttons.add(generateBtn); buttons.add(new Button("Clear", buttonClickEvent -> { clearForm(); })); content.add(buttons); return content; }
Example #5
Source File: ServiceTestingView.java From alibaba-rsocket-broker with Apache License 2.0 | 4 votes |
VerticalLayout makeServiceCallForm() { VerticalLayout content = new VerticalLayout(); this.serviceNameFiled = new TextField("Service Name"); serviceNameFiled.setWidth("300px"); this.methodNameField = new TextField("Method Name"); methodNameField.setWidth("300px"); TextArea jsonDataTextArea = new TextArea("JSON Data"); jsonDataTextArea.setWidth("600px"); jsonDataTextArea.setHeight("200px"); Pre responsePre = new Pre(); HorizontalLayout buttons = new HorizontalLayout(); Button callButton = new Button("Invoke", buttonClickEvent -> { String serviceName = serviceNameFiled.getValue(); String methodName = methodNameField.getValue(); String jsonData = jsonDataTextArea.getValue(); if (serviceName == null || serviceName.isEmpty()) { serviceNameFiled.setErrorMessage("Please input service name"); } if (methodName == null || methodName.isEmpty()) { methodNameField.setErrorMessage("Please input service name"); } if (jsonData != null) { jsonData = jsonData.trim(); if (!jsonData.isEmpty() && !jsonData.startsWith("[")) { jsonData = "[" + jsonData + "]"; } } callRSocketService(serviceName, methodName, jsonData, responsePre); }); content.add(new H3("RSocket Service Testing")); content.add(serviceNameFiled); content.add(methodNameField); content.add(jsonDataTextArea); content.add(new H4("Response")); content.add(responsePre); buttons.add(callButton); buttons.add(new Button("Clear", buttonClickEvent -> { serviceNameFiled.clear(); serviceNameFiled.setInvalid(false); methodNameField.clear(); jsonDataTextArea.clear(); responsePre.setText(""); })); content.add(buttons); return content; }
Example #6
Source File: AbstractAutoGeneratedCrudFormFactory.java From crudui with Apache License 2.0 | 4 votes |
protected void bindField(HasValue field, String property, Class<?> propertyType, CrudFormConfiguration configuration) { Binder.BindingBuilder bindingBuilder = binder.forField(field); if (TextField.class.isAssignableFrom(field.getClass()) || PasswordField.class.isAssignableFrom(field.getClass()) || TextArea.class.isAssignableFrom(field.getClass())) { bindingBuilder = bindingBuilder.withNullRepresentation(""); } if(configuration.getConverters().containsKey(property)) { bindingBuilder = bindingBuilder.withConverter(configuration.getConverters().get(property)); } else if (Double.class.isAssignableFrom(propertyType) || double.class.isAssignableFrom(propertyType)) { bindingBuilder = bindingBuilder.withConverter(new StringToDoubleConverter(null, "Must be a number")); } else if (Long.class.isAssignableFrom(propertyType) || long.class.isAssignableFrom(propertyType)) { bindingBuilder = bindingBuilder.withConverter(new StringToLongConverter(null, "Must be a number")); } else if (BigDecimal.class.isAssignableFrom(propertyType)) { bindingBuilder = bindingBuilder.withConverter(new StringToBigDecimalConverter(null, "Must be a number")); } else if (BigInteger.class.isAssignableFrom(propertyType)) { bindingBuilder = bindingBuilder.withConverter(new StringToBigIntegerConverter(null, "Must be a number")); } else if (Integer.class.isAssignableFrom(propertyType) || int.class.isAssignableFrom(propertyType)) { bindingBuilder = bindingBuilder.withConverter(new StringToIntegerConverter(null, "Must be a number")); } else if (Byte.class.isAssignableFrom(propertyType) || byte.class.isAssignableFrom(propertyType)) { bindingBuilder = bindingBuilder.withConverter(new StringToByteConverter(null, "Must be a number")); } else if (Character.class.isAssignableFrom(propertyType) || char.class.isAssignableFrom(propertyType)) { bindingBuilder = bindingBuilder.withConverter(new StringToCharacterConverter()); } else if (Float.class.isAssignableFrom(propertyType) || float.class.isAssignableFrom(propertyType)) { bindingBuilder = bindingBuilder.withConverter(new StringToFloatConverter(null, "Must be a number")); } else if (Date.class.isAssignableFrom(propertyType)) { bindingBuilder = bindingBuilder.withConverter(new LocalDateToDateConverter()); } bindingBuilder.bind(property); }