/*
 *  Keyframe-Based Video Summarization Designer
 *  Copyright (C) 2014 Waltenberger Andreas
 *
 *  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 2 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, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

package at.ac.tuwien.ims.ui;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 * UI element to display small notification windows for the user if an error occurs during keyframe extraction or template importing
 * @author Andreas Waltenberger
 *
 */
public class Notification extends Stage {

	private Text text;
	private Button ok;
	private Scene scene;
	private BorderPane layout;

	public Notification(String message) {
		initStyle(StageStyle.UTILITY);
		initModality(Modality.APPLICATION_MODAL);

		text = new Text(message);
		text.setFont(Font.font("Helvetica", FontWeight.NORMAL, 13));
		BorderPane.setMargin(text, new Insets(0, 0, 10, 0));

		ok = new Button("Ok");
		ok.setPrefSize(70, 20);
		ok.setDefaultButton(true);
		ok.setCancelButton(true);
		ok.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				close();
			}
		});
		BorderPane.setAlignment(ok, Pos.BOTTOM_RIGHT);

		layout = new BorderPane();
		layout.setPadding(new Insets(7));
		layout.setTop(text);
		layout.setBottom(ok);

		scene = new Scene(layout);
		setScene(scene);
		sizeToScene();
		setResizable(false);
	}
}
