Search in sources :

Example 46 with TextArea

use of com.vaadin.flow.component.textfield.TextArea in project alibaba-rsocket-broker by alibaba.

the class JwtGeneratorView method makeGeneratorForm.

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;
}
Also used : Button(com.vaadin.flow.component.button.Button) AuthenticationService(com.alibaba.spring.boot.rsocket.broker.security.AuthenticationService) TextArea(com.vaadin.flow.component.textfield.TextArea) NAV(com.alibaba.rsocket.broker.web.ui.JwtGeneratorView.NAV) H1(com.vaadin.flow.component.html.H1) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) UUID(java.util.UUID) TextField(com.vaadin.flow.component.textfield.TextField) Route(com.vaadin.flow.router.Route) TextArea(com.vaadin.flow.component.textfield.TextArea) Button(com.vaadin.flow.component.button.Button) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) TextField(com.vaadin.flow.component.textfield.TextField) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 47 with TextArea

use of com.vaadin.flow.component.textfield.TextArea in project alibaba-rsocket-broker by alibaba.

the class ServiceTestingView method makeServiceCallForm.

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;
}
Also used : TextArea(com.vaadin.flow.component.textfield.TextArea) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) Autowired(org.springframework.beans.factory.annotation.Autowired) RSocketBrokerHandlerRegistry(com.alibaba.spring.boot.rsocket.broker.responder.RSocketBrokerHandlerRegistry) Route(com.vaadin.flow.router.Route) Unpooled(io.netty.buffer.Unpooled) MessageMimeTypeMetadata(com.alibaba.rsocket.metadata.MessageMimeTypeMetadata) ByteBuf(io.netty.buffer.ByteBuf) RSocketBrokerResponderHandler(com.alibaba.spring.boot.rsocket.broker.responder.RSocketBrokerResponderHandler) TextField(com.vaadin.flow.component.textfield.TextField) ByteBufPayload(io.rsocket.util.ByteBufPayload) RSocketMimeType(com.alibaba.rsocket.metadata.RSocketMimeType) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) H3(com.vaadin.flow.component.html.H3) ServiceRoutingSelector(com.alibaba.spring.boot.rsocket.broker.route.ServiceRoutingSelector) H4(com.vaadin.flow.component.html.H4) RSocketCompositeMetadata(com.alibaba.rsocket.metadata.RSocketCompositeMetadata) StandardCharsets(java.nio.charset.StandardCharsets) GSVRoutingMetadata(com.alibaba.rsocket.metadata.GSVRoutingMetadata) Nullable(org.jetbrains.annotations.Nullable) Button(com.vaadin.flow.component.button.Button) Payload(io.rsocket.Payload) NAV(com.alibaba.rsocket.broker.web.ui.ServiceTestingView.NAV) Pre(com.vaadin.flow.component.html.Pre) ServiceLocator(com.alibaba.rsocket.ServiceLocator) Pre(com.vaadin.flow.component.html.Pre) TextArea(com.vaadin.flow.component.textfield.TextArea) Button(com.vaadin.flow.component.button.Button) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) TextField(com.vaadin.flow.component.textfield.TextField) H3(com.vaadin.flow.component.html.H3) H4(com.vaadin.flow.component.html.H4) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 48 with TextArea

use of com.vaadin.flow.component.textfield.TextArea in project flow-components by vaadin.

the class HasLabelTest method textArea.

@Test
public void textArea() {
    TextArea c = new TextArea();
    Assert.assertTrue(c instanceof HasLabel);
}
Also used : HasLabel(com.vaadin.flow.component.HasLabel) TextArea(com.vaadin.flow.component.textfield.TextArea) Test(org.junit.Test)

Example 49 with TextArea

use of com.vaadin.flow.component.textfield.TextArea in project flow-components by vaadin.

the class TextAreaTest method patternPropertyValue.

@Test
public void patternPropertyValue() {
    String testPattern = "TEST";
    TextArea textArea = new TextArea();
    textArea.setPattern(testPattern);
    assertEquals(testPattern, textArea.getPattern());
    assertEquals(testPattern, textArea.getElement().getProperty("pattern", ""));
}
Also used : TextArea(com.vaadin.flow.component.textfield.TextArea) Test(org.junit.Test)

Example 50 with TextArea

use of com.vaadin.flow.component.textfield.TextArea in project flow-components by vaadin.

the class TextAreaTest method clearButtonVisiblePropertyValue.

@Test
public void clearButtonVisiblePropertyValue() {
    TextArea textArea = new TextArea();
    assertClearButtonPropertyValueEquals(textArea, true);
    assertClearButtonPropertyValueEquals(textArea, false);
}
Also used : TextArea(com.vaadin.flow.component.textfield.TextArea) Test(org.junit.Test)

Aggregations

TextArea (com.vaadin.flow.component.textfield.TextArea)52 TextField (com.vaadin.flow.component.textfield.TextField)14 Test (org.junit.jupiter.api.Test)13 Div (com.vaadin.flow.component.html.Div)8 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)6 Test (org.junit.Test)6 Button (com.vaadin.flow.component.button.Button)5 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)5 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)4 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)4 H3 (com.vaadin.flow.component.html.H3)3 EmailField (com.vaadin.flow.component.textfield.EmailField)3 NumberField (com.vaadin.flow.component.textfield.NumberField)3 ValueChangeEvent (com.vaadin.flow.component.HasValue.ValueChangeEvent)2 ResponsiveStep (com.vaadin.flow.component.formlayout.FormLayout.ResponsiveStep)2 H2 (com.vaadin.flow.component.html.H2)2 NativeButton (com.vaadin.flow.component.html.NativeButton)2 StringLengthValidator (com.vaadin.flow.data.validator.StringLengthValidator)2 Route (com.vaadin.flow.router.Route)2 EFieldTypeDefinition (ch.akros.marketplace.administration.constants.EFieldTypeDefinition)1