diff --git a/src/main/kotlin/application/App.kt b/src/main/kotlin/application/App.kt index c27eacb..6caffa3 100644 --- a/src/main/kotlin/application/App.kt +++ b/src/main/kotlin/application/App.kt @@ -13,6 +13,7 @@ import jfxtras.styles.jmetro.JMetro import jfxtras.styles.jmetro.Style import kotlin.system.exitProcess + class App : Application() { var style: Style = Style.LIGHT @@ -29,7 +30,6 @@ class App : Application() { } private fun closeApplication() { - Platform.exit() exitProcess(0) } diff --git a/src/main/kotlin/application/controller/DataPanelController.kt b/src/main/kotlin/application/controller/DataPanelController.kt index 1ee21d4..adb52e7 100644 --- a/src/main/kotlin/application/controller/DataPanelController.kt +++ b/src/main/kotlin/application/controller/DataPanelController.kt @@ -86,7 +86,6 @@ class DataPanelController : Initializable, SelectedVesselListener { dataViewer.updatePlot(plotData) initDataList() - } private fun plot() { @@ -97,8 +96,6 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - - private fun plot(data: String?) { if (data == null) { plotData.allTraces.clear() @@ -332,7 +329,7 @@ class DataPanelController : Initializable, SelectedVesselListener { timeData = populateTime(vessel) if (dataListView.selectionModel.selectedItem == null) return -//NOTE: Ajouter les nouvelles donnée à la fin + when (dataListView.selectionModel.selectedItem) { "Latitude" -> { latitude.clear() diff --git a/src/main/kotlin/application/controller/VesselListPanelController.kt b/src/main/kotlin/application/controller/VesselListPanelController.kt index bbab756..f8fda76 100644 --- a/src/main/kotlin/application/controller/VesselListPanelController.kt +++ b/src/main/kotlin/application/controller/VesselListPanelController.kt @@ -6,27 +6,32 @@ import application.model.observableSelectedVessel import application.model.observableVessel import javafx.collections.FXCollections import javafx.collections.ObservableList +import javafx.collections.transformation.FilteredList import javafx.fxml.FXML import javafx.fxml.Initializable -import javafx.scene.control.ListCell -import javafx.scene.control.ListView -import javafx.scene.control.MultipleSelectionModel -import javafx.scene.control.SelectionMode +import javafx.scene.control.* import javafx.scene.input.MouseEvent import java.net.URL import java.util.* class VesselListPanelController : Initializable, MessageListener { + @FXML var shipListView: ListView = ListView() + @FXML + var filterInput: TextField = TextField() + private var shipList: ObservableList = FXCollections.observableArrayList() + private val filterMMSI = FilteredList(shipList) + override fun initialize(location: URL?, resources: ResourceBundle?) { - shipListView.items = shipList + shipListView.items = filterMMSI + observableVessel.listeners.add(this) shipListView.selectionModel.selectedItemProperty().addListener { _, _, newValue -> if (newValue == null) { @@ -35,7 +40,10 @@ class VesselListPanelController : Initializable, MessageListener { observableSelectedVessel.value = observableVessel.vessels[newValue]!! } } + + setCellFactory() + setFilterTextListener() } override fun onValueChanged(newValue: MutableMap) { @@ -43,6 +51,17 @@ class VesselListPanelController : Initializable, MessageListener { shipList.addAll(newValue.keys) } + private fun setFilterTextListener() { + filterInput.textProperty().addListener { _ -> + val filter: String = filterInput.text + if (filter.isEmpty()) { + filterMMSI.setPredicate { true } + } else { + filterMMSI.setPredicate { s: String? -> s!!.contains(filter) } + } + } + } + private fun setCellFactory() { val selectionModel: MultipleSelectionModel? = shipListView.selectionModel selectionModel?.selectionMode = SelectionMode.SINGLE diff --git a/src/main/resources/gui/mapPanel.fxml b/src/main/resources/gui/mapPanel.fxml index 98b7f56..f120a28 100644 --- a/src/main/resources/gui/mapPanel.fxml +++ b/src/main/resources/gui/mapPanel.fxml @@ -2,7 +2,7 @@ - + diff --git a/src/main/resources/gui/menuBar.fxml b/src/main/resources/gui/menuBar.fxml index 7c8e4fd..ddc43d3 100644 --- a/src/main/resources/gui/menuBar.fxml +++ b/src/main/resources/gui/menuBar.fxml @@ -2,7 +2,7 @@ - + diff --git a/src/main/resources/gui/timePanel.fxml b/src/main/resources/gui/timePanel.fxml index d4eb991..6b175b9 100644 --- a/src/main/resources/gui/timePanel.fxml +++ b/src/main/resources/gui/timePanel.fxml @@ -4,7 +4,7 @@ - + diff --git a/src/main/resources/gui/vesselListPanel.fxml b/src/main/resources/gui/vesselListPanel.fxml index e2f9cdb..9f8155a 100644 --- a/src/main/resources/gui/vesselListPanel.fxml +++ b/src/main/resources/gui/vesselListPanel.fxml @@ -1,25 +1,13 @@ - -
- - - - - - - - - - - +
diff --git a/src/main/resources/gui/windows.fxml b/src/main/resources/gui/windows.fxml index f10236b..1c16265 100644 --- a/src/main/resources/gui/windows.fxml +++ b/src/main/resources/gui/windows.fxml @@ -4,7 +4,7 @@ - +