package be.iminds.ilabt.jfed.experimenter_gui.dialogs;

import be.iminds.ilabt.jfed.experimenter_gui.bugreporting.BugReportComposer;
import be.iminds.ilabt.jfed.experimenter_gui.debug.LogViewer;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import javafx.scene.image.ImageView;

import javax.inject.Inject;
import javax.inject.Provider;

/**
 * User: twalcari
 * Date: 12/9/13
 * Time: 8:58 AM
 */
public class AboutDialog {
    @FXML
    private ImageView logoImageView;

    @FXML
    private TextField versionTextField;
    @FXML
    private TextField environmentTextField;
    @FXML
    private TextField credentialsTextField;
    @FXML
    private TextField emailTextField;
    @FXML
    private TextField certExpirationTextField;


    private final BugReportComposer bugReportComposer;

    private final Provider<LogViewer> logviewerProvider;

    @Inject
    public AboutDialog(BugReportComposer bugReportComposer, Provider<LogViewer> logviewerProvider) {
        this.bugReportComposer = bugReportComposer;
        this.logviewerProvider = logviewerProvider;
    }

    public void initialize() {

        versionTextField.textProperty().bind(bugReportComposer.versionProperty());
        environmentTextField.textProperty().bind(bugReportComposer.environmentProperty());
        credentialsTextField.textProperty().bind(bugReportComposer.reporterUrnProperty());
        emailTextField.textProperty().bind(bugReportComposer.emailProperty());
        certExpirationTextField.textProperty().bind(bugReportComposer.certificateExpirationProperty());

        logoImageView.setOnMouseClicked(mouseEvent -> {
            if(mouseEvent.getClickCount() == 2){
                logviewerProvider.get().show();
            }

        });

    }
}
