Commit 862dc9b51b4527952e42d2f5cfc456af3c9a6dfd

Authored by lsagona
1 parent 6b2760a458
Exists in master and in 1 other branch dev

rename an element of the menu

Showing 2 changed files with 4 additions and 4 deletions Inline Diff

src/main/kotlin/application/controller/MenuBarController.kt View file @ 862dc9b
package application.controller 1 1 package application.controller
2 2
import application.model.MapState.* 3 3 import application.model.MapState.*
import application.model.createVesselCollection 4 4 import application.model.createVesselCollection
import application.model.observableIsReplayState 5 5 import application.model.observableIsReplayState
import application.model.observableMapState 6 6 import application.model.observableMapState
import application.model.observableVessel 7 7 import application.model.observableVessel
import javafx.event.EventHandler 8 8 import javafx.event.EventHandler
import javafx.fxml.FXML 9 9 import javafx.fxml.FXML
import javafx.fxml.Initializable 10 10 import javafx.fxml.Initializable
import javafx.scene.control.* 11 11 import javafx.scene.control.*
import javafx.stage.FileChooser 12 12 import javafx.stage.FileChooser
import java.io.* 13 13 import java.io.*
import java.net.URL 14 14 import java.net.URL
import java.util.* 15 15 import java.util.*
16 16
17 17
class MenuBarController : Initializable { 18 18 class MenuBarController : Initializable {
19 19
@FXML 20 20 @FXML
var menuBar: MenuBar = MenuBar() 21 21 var menuBar: MenuBar = MenuBar()
22 22
@FXML 23 23 @FXML
var import: MenuItem = MenuItem() 24 24 var import: MenuItem = MenuItem()
25 25
@FXML 26 26 @FXML
var allMessages: CheckMenuItem = CheckMenuItem() 27 27 var allMessages: CheckMenuItem = CheckMenuItem()
28 28
@FXML 29 29 @FXML
var clusteredMessage: CheckMenuItem = CheckMenuItem() 30 30 var clusteredMessage: CheckMenuItem = CheckMenuItem()
31 31
@FXML 32 32 @FXML
var heatMap: CheckMenuItem = CheckMenuItem() 33 33 var heatMap: CheckMenuItem = CheckMenuItem()
34 34
@FXML 35 35 @FXML
var activateReplayButton: RadioMenuItem = RadioMenuItem() 36 36 var activateTimeSliderButton: RadioMenuItem = RadioMenuItem()
37 37
override fun initialize(location: URL?, resources: ResourceBundle?) { 38 38 override fun initialize(location: URL?, resources: ResourceBundle?) {
39 39
setOnActionImportButton() 40 40 setOnActionImportButton()
41 41
setOnActionAllMessageButton() 42 42 setOnActionAllMessageButton()
setOnActionClusteredMessageButton() 43 43 setOnActionClusteredMessageButton()
setOnActionHeatMapButton() 44 44 setOnActionHeatMapButton()
setOnActionActivateReplayButton() 45 45 setOnActionActivateReplayButton()
observableMapState.state = CLUSTERED_MESSAGES 46 46 observableMapState.state = CLUSTERED_MESSAGES
allMessages.isSelected = false 47 47 allMessages.isSelected = false
clusteredMessage.isSelected = true 48 48 clusteredMessage.isSelected = true
heatMap.isSelected = false 49 49 heatMap.isSelected = false
50 50
} 51 51 }
52 52
private fun setOnActionActivateReplayButton() { 53 53 private fun setOnActionActivateReplayButton() {
activateReplayButton.onAction = EventHandler { 54 54 activateTimeSliderButton.onAction = EventHandler {
observableIsReplayState.value = activateReplayButton.isSelected 55 55 observableIsReplayState.value = activateTimeSliderButton.isSelected
} 56 56 }
} 57 57 }
58 58
private fun setOnActionImportButton() { 59 59 private fun setOnActionImportButton() {
import.onAction = EventHandler { 60 60 import.onAction = EventHandler {
val fileChooser = FileChooser() 61 61 val fileChooser = FileChooser()
fileChooser.title = "Choose a file to import" 62 62 fileChooser.title = "Choose a file to import"
val window = menuBar.scene.window 63 63 val window = menuBar.scene.window
val file = fileChooser.showOpenDialog(window) 64 64 val file = fileChooser.showOpenDialog(window)
65 65
try { 66 66 try {
if (file.extension != "csv") { 67 67 if (file.extension != "csv") {
val alert = Alert(Alert.AlertType.WARNING) 68 68 val alert = Alert(Alert.AlertType.WARNING)
alert.title = "Warning Alert" 69 69 alert.title = "Warning Alert"
alert.headerText = "Wrong file format." 70 70 alert.headerText = "Wrong file format."
alert.contentText = "Please choose à .csv file." 71 71 alert.contentText = "Please choose à .csv file."
alert.showAndWait() 72 72 alert.showAndWait()
} 73 73 }
observableVessel.vessels.clear() 74 74 observableVessel.vessels.clear()
if(toMuchVessel(file)){ 75 75 if(toMuchVessel(file)){
observableVessel.vessels = mutableMapOf() 76 76 observableVessel.vessels = mutableMapOf()
}else { 77 77 }else {
val vessels = createVesselCollection(file) 78 78 val vessels = createVesselCollection(file)
observableVessel.vessels = vessels 79 79 observableVessel.vessels = vessels
} 80 80 }
} catch (ignore: IllegalStateException) { 81 81 } catch (ignore: IllegalStateException) {
82 82
} 83 83 }
} 84 84 }
} 85 85 }
86 86
private fun toMuchVessel(file: File): Boolean { 87 87 private fun toMuchVessel(file: File): Boolean {
val nbLine = file.readLines().size 88 88 val nbLine = file.readLines().size
if (nbLine > 50000) { 89 89 if (nbLine > 50000) {
val alert = Alert(Alert.AlertType.CONFIRMATION) 90 90 val alert = Alert(Alert.AlertType.CONFIRMATION)
alert.title = "Warning!!" 91 91 alert.title = "Warning!!"
alert.headerText = "Warning: This file contain a lot of messages." 92 92 alert.headerText = "Warning: This file contain a lot of messages."
alert.contentText = "Are you sure you want to continue." 93 93 alert.contentText = "Are you sure you want to continue."
val buttonTypeYes = ButtonType("Yes") 94 94 val buttonTypeYes = ButtonType("Yes")
val buttonTypeNo = ButtonType("No ") 95 95 val buttonTypeNo = ButtonType("No ")
alert.buttonTypes.setAll(buttonTypeYes, buttonTypeNo) 96 96 alert.buttonTypes.setAll(buttonTypeYes, buttonTypeNo)
val result = alert.showAndWait() 97 97 val result = alert.showAndWait()
98 98
return result.get() != buttonTypeYes 99 99 return result.get() != buttonTypeYes
} 100 100 }
return false 101 101 return false
} 102 102 }
103 103
private fun setOnActionAllMessageButton() { 104 104 private fun setOnActionAllMessageButton() {
allMessages.onAction = EventHandler { 105 105 allMessages.onAction = EventHandler {
observableMapState.state = ALL_MESSAGES 106 106 observableMapState.state = ALL_MESSAGES
allMessages.isSelected = true 107 107 allMessages.isSelected = true
clusteredMessage.isSelected = false 108 108 clusteredMessage.isSelected = false
heatMap.isSelected = false 109 109 heatMap.isSelected = false
} 110 110 }
} 111 111 }
src/main/resources/gui/menuBar.fxml View file @ 862dc9b
<?xml version="1.0" encoding="UTF-8"?> 1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2
<?import javafx.scene.control.*?> 3 3 <?import javafx.scene.control.*?>
4 4
<MenuBar fx:id="menuBar" prefHeight="25.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.241" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.controller.MenuBarController"> 5 5 <MenuBar fx:id="menuBar" prefHeight="25.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.241" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.controller.MenuBarController">
<menus> 6 6 <menus>
<Menu mnemonicParsing="false" text="File"> 7 7 <Menu mnemonicParsing="false" text="File">
<items> 8 8 <items>
<MenuItem fx:id="import" mnemonicParsing="false" text="Import" /> 9 9 <MenuItem fx:id="import" mnemonicParsing="false" text="Import" />
</items> 10 10 </items>
</Menu> 11 11 </Menu>
<Menu mnemonicParsing="false" text="Settings"> 12 12 <Menu mnemonicParsing="false" text="Settings">
<items> 13 13 <items>
<Menu mnemonicParsing="false" text="Map selected"> 14 14 <Menu mnemonicParsing="false" text="Map selected">
<items> 15 15 <items>
<CheckMenuItem fx:id="allMessages" mnemonicParsing="false" text="All messages" /> 16 16 <CheckMenuItem fx:id="allMessages" mnemonicParsing="false" text="All messages" />
<CheckMenuItem fx:id="clusteredMessage" mnemonicParsing="false" text="Clustered messages" /> 17 17 <CheckMenuItem fx:id="clusteredMessage" mnemonicParsing="false" text="Clustered messages" />
<CheckMenuItem fx:id="heatMap" mnemonicParsing="false" text="Heat map" /> 18 18 <CheckMenuItem fx:id="heatMap" mnemonicParsing="false" text="Heat map" />
</items> 19 19 </items>
</Menu> 20 20 </Menu>
<RadioMenuItem fx:id="activateReplayButton" mnemonicParsing="false" text="Unspecified Action" /> 21 21 <RadioMenuItem fx:id="activateTimeSliderButton" mnemonicParsing="false" text="Time Slider" />
</items> 22 22 </items>
</Menu> 23 23 </Menu>
<Menu mnemonicParsing="false" text="Help"> 24 24 <Menu mnemonicParsing="false" text="Help">
<items> 25 25 <items>
<MenuItem mnemonicParsing="false" text="About" /> 26 26 <MenuItem mnemonicParsing="false" text="About" />
</items> 27 27 </items>
</Menu> 28 28 </Menu>
</menus> 29 29 </menus>