View Javadoc
1   /*
2    * Copyright (c) Patrick Magauran 2018.
3    *   Licensed under the AGPLv3. All conditions of said license apply.
4    *       This file is part of ABOS.
5    *
6    *       ABOS is free software: you can redistribute it and/or modify
7    *       it under the terms of the GNU Affero General Public License as published by
8    *       the Free Software Foundation, either version 3 of the License, or
9    *       (at your option) any later version.
10   *
11   *       ABOS is distributed in the hope that it will be useful,
12   *       but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   *       GNU Affero General Public License for more details.
15   *
16   *       You should have received a copy of the GNU Affero General Public License
17   *       along with ABOS.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  
20  package Launchers;
21  
22  import Controllers.AddUserController;
23  import Utilities.LogToFile;
24  import Utilities.Severity;
25  import javafx.fxml.FXMLLoader;
26  import javafx.scene.Scene;
27  import javafx.stage.Modality;
28  import javafx.stage.Stage;
29  import javafx.stage.Window;
30  
31  import java.io.IOException;
32  
33  /**
34   * Created by patrick on 5/28/17.
35   */
36  public class AddUser extends Window {
37      public AddUser(Window owner) {
38          Stage stage = new Stage();
39          FXMLLoader loader;
40  
41          Scene root;
42          try {
43              loader = new FXMLLoader(getClass().getResource("/UI/AddUser.fxml"));
44              root = new Scene(loader.load());
45              AddUserController addUserController = loader.getController();
46              addUserController.initAddUser(this);
47              stage.setScene(root);
48              stage.setTitle("Add User");
49              stage.initModality(Modality.APPLICATION_MODAL);
50              stage.initOwner(owner);
51              stage.showAndWait();
52          } catch (IOException e) {
53              LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers.");
54          }
55      }
56  
57      public AddUser(Window window, String userName) {
58          Stage stage = new Stage();
59          FXMLLoader loader;
60  
61          Scene root;
62          try {
63              loader = new FXMLLoader(getClass().getResource("/UI/AddUser.fxml"));
64              root = new Scene(loader.load());
65              AddUserController addUserController = loader.getController();
66              addUserController.initAddUser(userName, this);
67              stage.setScene(root);
68              stage.setTitle("Edit User - " + userName);
69              stage.initModality(Modality.APPLICATION_MODAL);
70              stage.initOwner(window);
71              stage.showAndWait();
72          } catch (IOException e) {
73              LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers.");
74          }
75  
76      }
77  }