From 3585b2a39821e4622ff8c504305ce4b8639745ba Mon Sep 17 00:00:00 2001 From: patschuh <46817726+patschuh@users.noreply.github.com> Date: Fri, 15 Mar 2024 17:33:10 +0100 Subject: [PATCH] change checkCompatibility to use verbose mode Added very basic dialog to display messages retuned by verbose check prevent exceptions from opening very large alert windows --- .../SchemaCompatibilityCheckController.java | 11 +++-- .../kafka/alerts/IncompatibleSchemaAlert.java | 41 +++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 src/main/java/at/esque/kafka/alerts/IncompatibleSchemaAlert.java diff --git a/src/main/java/at/esque/kafka/SchemaCompatibilityCheckController.java b/src/main/java/at/esque/kafka/SchemaCompatibilityCheckController.java index e6e0e44..201fcab 100644 --- a/src/main/java/at/esque/kafka/SchemaCompatibilityCheckController.java +++ b/src/main/java/at/esque/kafka/SchemaCompatibilityCheckController.java @@ -1,6 +1,7 @@ package at.esque.kafka; import at.esque.kafka.alerts.ErrorAlert; +import at.esque.kafka.alerts.IncompatibleSchemaAlert; import at.esque.kafka.controls.KafkaEsqueCodeArea; import io.confluent.kafka.schemaregistry.client.rest.RestService; import io.confluent.kafka.schemaregistry.client.rest.entities.Schema; @@ -12,6 +13,8 @@ import javafx.stage.FileChooser; import javafx.stage.Stage; import javafx.stage.Window; +import org.kordamp.ikonli.fontawesome.FontAwesome; +import org.kordamp.ikonli.javafx.FontIcon; import java.io.File; import java.io.IOException; @@ -21,7 +24,6 @@ public class SchemaCompatibilityCheckController { - @FXML private TextField subjectTextField; @@ -42,7 +44,7 @@ public void addSchema(ActionEvent actionEvent) { try { Schema schema = restService.getVersion(subjectTextField.getText(), Integer.parseInt(versionTextField.getText())); - List compatibility = restService.testCompatibility(schemaTextArea.getText(), schema.getSchemaType(), null, subjectTextField.getText(), versionTextField.getText(), false); + List compatibility = restService.testCompatibility(schemaTextArea.getText(), schema.getSchemaType(), null, subjectTextField.getText(), versionTextField.getText(), true); if (compatibility.isEmpty()) { resultLabel.setTextFill(Color.web("#3d7a3d")); @@ -50,9 +52,12 @@ public void addSchema(ActionEvent actionEvent) { } else { resultLabel.setTextFill(Color.web("#bd362f")); resultLabel.setText("Schema is incompatible"); + resultLabel.setGraphic(FontIcon.of(FontAwesome.QUESTION_CIRCLE, Color.CADETBLUE)); + resultLabel.setOnMouseClicked(event -> IncompatibleSchemaAlert.show(compatibility, getWindow())); + IncompatibleSchemaAlert.show(compatibility, getWindow()); } } catch (Exception e) { - ErrorAlert.show(e, getWindow()); + ErrorAlert.show("Exception when requesting compatibility check", "Could not check compatibility", e.getClass().getName(), e, getWindow(), true); } } diff --git a/src/main/java/at/esque/kafka/alerts/IncompatibleSchemaAlert.java b/src/main/java/at/esque/kafka/alerts/IncompatibleSchemaAlert.java new file mode 100644 index 0000000..b2646cf --- /dev/null +++ b/src/main/java/at/esque/kafka/alerts/IncompatibleSchemaAlert.java @@ -0,0 +1,41 @@ +package at.esque.kafka.alerts; + +import at.esque.kafka.Main; +import at.esque.kafka.controls.FilterableListView; +import javafx.scene.control.Alert; +import javafx.scene.control.Label; +import javafx.scene.layout.BorderPane; +import javafx.stage.Window; + +import java.util.List; + +public class IncompatibleSchemaAlert { + public static void show(List messages, Window owner) { + Alert alert = new Alert(Alert.AlertType.WARNING); + alert.setTitle("Schema Incompatible"); + alert.setHeaderText("Incompatibility Information"); + alert.setResizable(true); + Main.applyIcon(alert); + Main.applyStylesheet(alert.getDialogPane().getScene()); + FilterableListView messageView = new FilterableListView<>(); + messageView.setAddButtonVisible(false); + messageView.setRefreshButtonVisible(false); + messageView.setItems(messages); + + BorderPane borderPane = new BorderPane(); + borderPane.setCenter(messageView); + borderPane.setTop(new Label("Messages")); + borderPane.setMaxWidth(Double.MAX_VALUE); + borderPane.setMaxHeight(Double.MAX_VALUE); + borderPane.setPrefSize(800, 600); + + + alert.getDialogPane().setContent(borderPane); + + if (owner != null) { + alert.initOwner(owner); + } + + alert.show(); + } +}