-
Notifications
You must be signed in to change notification settings - Fork 17
/
SchemaRegistryBrowserController.java
53 lines (46 loc) · 2 KB
/
SchemaRegistryBrowserController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package at.esque.kafka;
import at.esque.kafka.alerts.ErrorAlert;
import io.confluent.kafka.schemaregistry.client.rest.RestService;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ListView;
import javafx.scene.control.TextArea;
public class SchemaRegistryBrowserController {
private RestService schemaRegistryRestService;
@FXML
private ListView<String> subjectListView;
@FXML
private TextArea schemaTextArea;
@FXML
private ComboBox<Integer> versionComboBox;
public void setup(String schemaregistryUrl) {
schemaRegistryRestService = new RestService(schemaregistryUrl);
try {
versionComboBox.getSelectionModel().selectedItemProperty().addListener(((observable1, oldValue1, newValue1) -> {
if(newValue1 == null){
schemaTextArea.setText(null);
return;
}
try {
schemaTextArea.setText(schemaRegistryRestService.getVersion(subjectListView.getSelectionModel().getSelectedItem(), newValue1).getSchema());
} catch (Exception e) {
ErrorAlert.show(e);
}
}));
subjectListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
try {
versionComboBox.setItems(FXCollections.observableArrayList(schemaRegistryRestService.getAllVersions(newValue)));
if (versionComboBox.getItems().size() > 0) {
versionComboBox.getSelectionModel().select(versionComboBox.getItems().size() - 1);
}
} catch (Exception e) {
ErrorAlert.show(e);
}
});
subjectListView.setItems(FXCollections.observableArrayList(schemaRegistryRestService.getAllSubjects()));
} catch (Exception e) {
ErrorAlert.show(e);
}
}
}