package com.marvinelsen.willow.ui.controllers

import com.marvinelsen.willow.Model
import javafx.application.Platform
import javafx.beans.binding.Bindings
import javafx.fxml.FXML
import javafx.scene.control.MenuItem

@Suppress("UnusedPrivateMember")
class MenuController(private val model: Model) {
    @FXML
    private lateinit var menuItemCopyHeadword: MenuItem

    @FXML
    private lateinit var menuItemCopyPronunciation: MenuItem

    @FXML
    private fun initialize() {
        menuItemCopyPronunciation.disableProperty().bind(Bindings.isNull(model.selectedEntry))
        menuItemCopyHeadword.disableProperty().bind(Bindings.isNull(model.selectedEntry))
    }

    @FXML
    private fun onMenuItemQuitAction() {
        Platform.exit()
    }

    @FXML
    private fun onMenuItemCopyPronunciationAction() {
        model.copyPronunciationOfSelectedEntry()
    }

    @FXML
    private fun onMenuItemCopyHeadwordAction() {
        model.copyHeadwordOfSelectedEntry()
    }
}
