use of com.vaadin.flow.component.html.Pre in project sapl-demos by heutelbeck.
the class Utilities method getInfoText.
public static HorizontalLayout getInfoText(String infoText) {
Pre infoTextPre = new Pre(infoText);
infoTextPre.getStyle().set("white-space", "pre-wrap").set("margin", "auto").set("font-size", "medium").set("padding-left", "5px").set("padding-right", "5px");
Icon infoIcon = new Icon(VaadinIcon.INFO_CIRCLE);
return new HorizontalLayout(infoIcon, infoTextPre);
}
use of com.vaadin.flow.component.html.Pre in project alibaba-rsocket-broker by alibaba.
the class ServiceTestingView method callRSocketService.
public void callRSocketService(String service, String method, @Nullable String jsonData, Pre response) {
Integer handlerId = this.routingSelector.findHandler(ServiceLocator.serviceHashCode(service));
if (handlerId != null) {
RSocketBrokerResponderHandler handler = handlerRegistry.findById(handlerId);
if (handler != null) {
// composite metadata for health check
RSocketCompositeMetadata compositeMetadata = RSocketCompositeMetadata.from(new GSVRoutingMetadata(null, service, method, null), new MessageMimeTypeMetadata(RSocketMimeType.Json));
ByteBuf payLoadData;
if (jsonData == null || jsonData.isEmpty()) {
payLoadData = Unpooled.EMPTY_BUFFER;
} else {
payLoadData = Unpooled.wrappedBuffer(jsonData.getBytes(StandardCharsets.UTF_8));
}
Payload requestPayload = ByteBufPayload.create(payLoadData, compositeMetadata.getContent());
handler.getPeerRsocket().requestResponse(requestPayload).doOnError(throwable -> getUI().ifPresent(ui -> ui.access(() -> {
response.setText(throwable.getMessage());
}))).subscribe(payload -> getUI().ifPresent(ui -> ui.access(() -> {
response.setText(payload.getDataUtf8());
})));
} else {
this.serviceNameFiled.setInvalid(true);
this.serviceNameFiled.setErrorMessage("No Service Provider!");
}
} else {
this.serviceNameFiled.setInvalid(true);
this.serviceNameFiled.setErrorMessage("Service not found!");
}
}
use of com.vaadin.flow.component.html.Pre 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;
}
Aggregations