package com.hmsoft.common.util;

import java.util.Optional;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
import javafx.stage.Stage;

/**
 * 
 * @author zq
 *
 */
public class DialogUtil {

	public static void showAlertDialog(final Stage stage, final Alert.AlertType alterType, 
			final String title, final String msgBody) {
		final Alert alert = new Alert(alterType);
		alert.setTitle(title);
		alert.setHeaderText(msgBody);
		alert.setContentText("");
		alert.initOwner(stage);
		alert.show();
	}
	
	public static boolean confirm(final String confirmMsg, final Stage stage) {
		Alert confirm = new Alert(Alert.AlertType.CONFIRMATION,
				"", 
				new ButtonType("否", ButtonData.NO),
                new ButtonType("是", ButtonData.YES));
		confirm.setTitle("请确认");
		confirm.setHeaderText(confirmMsg);
		confirm.initOwner(stage);
		Optional<ButtonType> btnType = confirm.showAndWait();
		if (btnType.get().getButtonData().equals(ButtonData.YES)) {
			return true;
		}
		return false;
	}
}
