Java Code Examples for com.vaadin.flow.component.textfield.TextArea#setWidth()

The following examples show how to use com.vaadin.flow.component.textfield.TextArea#setWidth() . 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 vote down vote up
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: JwtGeneratorView.java    From alibaba-rsocket-broker with Apache License 2.0 4 votes vote down vote up
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 3
Source File: ServiceTestingView.java    From alibaba-rsocket-broker with Apache License 2.0 4 votes vote down vote up
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;
}