From 07bf03cd80598b25566ae0f71c157a3232cabae9 Mon Sep 17 00:00:00 2001 From: lsagona Date: Tue, 18 Aug 2020 10:02:30 +0200 Subject: [PATCH] add alert message when a non csv file is selected --- src/main/kotlin/application/controller/MenuBarController.kt | 10 +++++++++- src/main/kotlin/map/MapDisplayer.kt | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/application/controller/MenuBarController.kt b/src/main/kotlin/application/controller/MenuBarController.kt index 84dfe7d..6d94861 100644 --- a/src/main/kotlin/application/controller/MenuBarController.kt +++ b/src/main/kotlin/application/controller/MenuBarController.kt @@ -7,6 +7,7 @@ import application.model.observableVessel import javafx.event.EventHandler import javafx.fxml.FXML import javafx.fxml.Initializable +import javafx.scene.control.Alert import javafx.scene.control.CheckMenuItem import javafx.scene.control.MenuBar import javafx.scene.control.MenuItem @@ -52,10 +53,17 @@ class MenuBarController : Initializable { val window = menuBar.scene.window val file = fileChooser.showOpenDialog(window) try { + if (file.extension != "csv") { + val alert = Alert(Alert.AlertType.WARNING) + alert.title = "Warning Alert" + alert.headerText = "Wrong file format." + alert.contentText = "Please choose à .csv file." + alert.showAndWait() + } val vessels = createVesselCollection(file) observableVessel.vessels.clear() observableVessel.vessels = vessels - } catch (ignore: IllegalStateException){ + } catch (ignore: IllegalStateException) { } } diff --git a/src/main/kotlin/map/MapDisplayer.kt b/src/main/kotlin/map/MapDisplayer.kt index 859acc9..e1be20b 100644 --- a/src/main/kotlin/map/MapDisplayer.kt +++ b/src/main/kotlin/map/MapDisplayer.kt @@ -88,7 +88,6 @@ fun displayHeatMapOnMap(map: LeafletMapView) { map.execScript("heatLayer.addLatLng([${message.latitude}, ${message.longitude}]);") } } - } fun displayHeatMapOnMap(map: LeafletMapView, selectedMMSI: Int) { -- 1.7.10.4