/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mytime.gui.controller;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXSpinner;
import com.jfoenix.controls.JFXTextField;
import java.io.IOException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import mytime.gui.model.ManagerModel;
import mytime.gui.model.Model;
import mytime.gui.model.VolunteerModel;
/**
*
* @author User
*/
public class LoginManagerController
{
@FXML
private JFXButton btnExit;
@FXML
private JFXTextField txtFldUsername;
@FXML
private JFXTextField txtFldPassword;
@FXML
private JFXSpinner progressIndicator;
@FXML
private JFXButton btnLogin;
@FXML
private Text lblUsername;
@FXML
private Text lblPassword;
private VolunteerModel volunteerModel;
@FXML
private void handleUserLogin(ActionEvent event)
{
String userName = txtFldUsername.getText().trim();
String passWord = txtFldPassword.getText();
progressIndicator.setVisible(true);
//blurElements(true);
Stage mainView = (Stage) btnLogin.getScene().getWindow();
if (Model.getInstance().getManagerScene() == null)
{
mainView.close();
Parent mainViewLoad = null;
FXMLLoader loader = new FXMLLoader(getClass().getResource("/mytime/gui/view/ManagerMainView.fxml"));
ManagerModel.getInstance().setBllManager(VolunteerModel.getInstance().getBllMgr());
try
{
loader.load();
} catch (IOException ex)
{
Logger.getLogger(LoginOneVolunteerController.class.getName()).log(Level.SEVERE, null, ex);
}
mainViewLoad = loader.getRoot();
Scene scene = new Scene(mainViewLoad);
Model.getInstance().setManagerScene(scene);
mainView.setScene(scene);
mainView.setResizable(true);
mainView.show();
} else
{
Scene scene = Model.getInstance().getManagerScene();
mainView.close();
mainView.setScene(scene);
mainView.setResizable(true);
mainView.show();
}
}
@FXML
private void handleClose(ActionEvent event)
{
VolunteerModel vmodel = VolunteerModel.getInstance();
Stage mainView = (Stage) btnExit.getScene().getWindow();
mainView.close();
Parent mainViewLoad = null;
try
{
ResourceBundle bundle = ResourceBundle.getBundle("mytime.gui.UIResources", vmodel.getLocale());
mainViewLoad = FXMLLoader.load(getClass().getResource("/mytime/gui/view/LoginMainView.fxml"), bundle);
} catch (IOException ex)
{
Logger.getLogger(LoginOneVolunteerController.class.getName()).log(Level.SEVERE, null, ex);
}
Scene scene = new Scene(mainViewLoad);
mainView.setScene(scene);
mainView.setResizable(true);
mainView.show();
}
/* private void blurElements(boolean b)
{
txtFldUsername.setDisable(b);
txtFldPassword.setDisable(b);
btnLogin.setDisable(b);
if (b)
{
txtFldUsername.setEffect(new GaussianBlur());
txtFldPassword.setEffect(new GaussianBlur());
btnLogin.setEffect(new GaussianBlur());
lblUsername.setEffect(new GaussianBlur());
lblPassword.setEffect(new GaussianBlur());
} else
{
txtFldUsername.setEffect(null);
txtFldPassword.setEffect(null);
btnLogin.setEffect(null);
lblUsername.setEffect(null);
lblPassword.setEffect(null);
}
}
*/
}