Blame view

src/main/kotlin/application/controller/MenuBarController.kt 2.39 KB
b350f9dfe   lsagona   import vessels an...
1
  package application.controller
9e952e84e   lsagona   add message clust...
2
3
  import application.model.State
  import application.model.State.*
b350f9dfe   lsagona   import vessels an...
4
  import application.model.createVesselCollection
9e952e84e   lsagona   add message clust...
5
  import application.model.observableState
2bbe36a1b   lsagona   addd the possibil...
6
  import application.model.observableVessel
b350f9dfe   lsagona   import vessels an...
7
8
  import javafx.event.EventHandler
  import javafx.fxml.FXML
b350f9dfe   lsagona   import vessels an...
9
  import javafx.fxml.Initializable
9e952e84e   lsagona   add message clust...
10
  import javafx.scene.control.CheckMenuItem
b350f9dfe   lsagona   import vessels an...
11
12
13
14
15
16
17
18
19
20
21
22
23
  import javafx.scene.control.MenuBar
  import javafx.scene.control.MenuItem
  import javafx.stage.FileChooser
  import java.net.URL
  import java.util.*
  
  class MenuBarController : Initializable {
  
      @FXML
      var menuBar: MenuBar = MenuBar()
  
      @FXML
      var import: MenuItem = MenuItem()
9e952e84e   lsagona   add message clust...
24
25
26
27
28
29
30
31
      @FXML
      var allMessages: CheckMenuItem = CheckMenuItem()
  
      @FXML
      var clusteredMessage: CheckMenuItem = CheckMenuItem()
  
      @FXML
      var heatMap: CheckMenuItem = CheckMenuItem()
b350f9dfe   lsagona   import vessels an...
32
      override fun initialize(location: URL?, resources: ResourceBundle?) {
9e952e84e   lsagona   add message clust...
33
34
35
36
37
38
39
40
41
42
          setOnActionImportButton()
  
          setOnActionAllMessageButton()
          setOnActionClusteredMessageButton()
          setOnActionHeatMapButton()
          clusteredMessage.isSelected = true
  
      }
  
      private fun setOnActionImportButton() {
b350f9dfe   lsagona   import vessels an...
43
44
45
46
47
48
          import.onAction = EventHandler {
              val fileChooser = FileChooser()
              fileChooser.title = "Choose a file to import"
              val window = menuBar.scene.window
              val file = fileChooser.showOpenDialog(window)
              val vessels = createVesselCollection(file)
2bbe36a1b   lsagona   addd the possibil...
49
50
              observableVessel.vessels.clear()
              observableVessel.vessels = vessels
b350f9dfe   lsagona   import vessels an...
51
52
          }
      }
9e952e84e   lsagona   add message clust...
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  
      private fun setOnActionAllMessageButton() {
          allMessages.onAction = EventHandler {
              observableState.state = ALL_MESSAGES
              allMessages.isSelected = true
              clusteredMessage.isSelected = false
              heatMap.isSelected = false
          }
      }
  
      private fun setOnActionClusteredMessageButton() {
          clusteredMessage.onAction = EventHandler {
              observableState.state = CLUSTERED_MESSAGES
              heatMap.isSelected = false
              allMessages.isSelected = false
              clusteredMessage.isSelected = true
          }
      }
  
      private fun setOnActionHeatMapButton() {
          heatMap.onAction = EventHandler {
              observableState.state = HEAT_MAP
              heatMap.isSelected = true
              clusteredMessage.isSelected = false
              allMessages.isSelected = false
          }
      }
b350f9dfe   lsagona   import vessels an...
80
  }