/*
CloudTrail Viewer, is a Java desktop application for reading AWS CloudTrail logs
files.
Copyright (C) 2017 Mark P. Haskins
This program is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.haskins.java.cloudtrailviewer.controller.menu;
import io.haskins.java.cloudtrailviewer.CloudTrailViewer;
import io.haskins.java.cloudtrailviewer.controller.dialog.preferences.PreferencesDialogController;
import io.haskins.java.cloudtrailviewer.service.AccountService;
import io.haskins.java.cloudtrailviewer.service.DatabaseService;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
/**
* Controller that handles the File menu
*
* Created by markhaskins on 06/01/2017.
*/
@Component
public class FileMenuController {
private final DatabaseService databaseService;
private final AccountService accountDao;
@Autowired
public FileMenuController(DatabaseService databaseService, AccountService accountDao) {
this.databaseService = databaseService;
this.accountDao = accountDao;
}
@FXML
private void quit() {
System.exit(0);
}
@FXML
private void showPreferences() {
try {
String fxmlFile = "/fxml/dialog/preferences/PreferencesDialog.fxml";
FXMLLoader loader = new FXMLLoader();
loader.setLocation(CloudTrailViewer.class.getResource(fxmlFile));
Pane page = loader.load();
Scene scene = new Scene(page);
Stage dialogStage = new Stage();
dialogStage.initModality(Modality.APPLICATION_MODAL);
dialogStage.setScene(scene);
PreferencesDialogController controller = loader.getController();
controller.init(dialogStage, accountDao, databaseService);
dialogStage.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
}
}