Blame view

src/main/kotlin/application/controller/MenuBarController.kt 983 Bytes
b350f9dfe   lsagona   import vessels an...
1
  package application.controller
b350f9dfe   lsagona   import vessels an...
2
  import application.model.createVesselCollection
2bbe36a1b   lsagona   addd the possibil...
3
  import application.model.observableVessel
b350f9dfe   lsagona   import vessels an...
4
5
  import javafx.event.EventHandler
  import javafx.fxml.FXML
b350f9dfe   lsagona   import vessels an...
6
  import javafx.fxml.Initializable
b350f9dfe   lsagona   import vessels an...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  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()
  
      override fun initialize(location: URL?, resources: ResourceBundle?) {
  
          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...
29
30
              observableVessel.vessels.clear()
              observableVessel.vessels = vessels
b350f9dfe   lsagona   import vessels an...
31
32
33
          }
      }
  }