summaryrefslogtreecommitdiffstats
path: root/src/de/fhswf/in/inf/se/projektthemenvergabe/Main.java
blob: 53bcd7f9eeaca8562b799b1441a7e490fac36337 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/**
 * 
 */
package de.fhswf.in.inf.se.projektthemenvergabe;

import de.fhswf.in.inf.se.projektthemenvergabe.model.Ansprechpartner;
import de.fhswf.in.inf.se.projektthemenvergabe.model.Organisation;
import de.fhswf.in.inf.se.projektthemenvergabe.model.Projekt;
import de.fhswf.in.inf.se.projektthemenvergabe.model.Student;
import de.fhswf.in.inf.se.projektthemenvergabe.view.AnsprechpartnerListeController;
import de.fhswf.in.inf.se.projektthemenvergabe.view.ProjektHinzufuegenController;
import de.fhswf.in.inf.se.projektthemenvergabe.view.ProjektthemenverwaltungsController;
import de.fhswf.in.inf.se.projektthemenvergabe.view.StudentenverwaltungsController;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Modality;
import javafx.stage.Stage;

/**
 * Handles the stages and the data.
 *
 * @author Dina-Marie Hanxleden & Stefan Suhren
 * @version 1.0
 */
public class Main extends Application
{
   private ObservableList<Ansprechpartner> ansprechpartner = FXCollections
         .observableArrayList(Ansprechpartner.extractor());

   private ObservableList<Organisation> organisation = FXCollections
         .observableArrayList(Organisation.extractor());

   private ObservableList<Projekt> projekte = FXCollections
         .observableArrayList(Projekt.extractor());

   private ObservableList<Student> studenten = FXCollections
         .observableArrayList(Student.extractor());

   private Stage primaryStage;

   private Stage studentenverwaltungsStage;

   private Stage ansprechpartnerverwaltungsStage;

   private Stage projekthinzufuegenStage;

   /*
    * (non-Javadoc)
    * 
    * @see javafx.application.Application#start(javafx.stage.Stage)
    */
   @Override
   public void start(Stage primaryStage) throws Exception
   {
      this.primaryStage = primaryStage;

      try
      {
         FXMLLoader loader = new FXMLLoader(
               getClass().getResource("view/Projektthemenverwaltung.fxml"));
         BorderPane root = (BorderPane) loader.load();

         Scene scene = new Scene(root);
         primaryStage.setScene(scene);
         primaryStage.setTitle("Projektthemenverwaltung");

         ProjektthemenverwaltungsController controller = loader
               .getController();
         controller.setMain(this);

         primaryStage.show();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }

   /**
    * Show the Studentenverwaltung stage with the corresponding FXML.
    *
    */
   public void showStudentenverwaltung()
   {
      try
      {
         FXMLLoader loader = new FXMLLoader(
               getClass().getResource("view/Studentenverwaltung.fxml"));
         BorderPane root = (BorderPane) loader.load();

         Scene scene = new Scene(root);
         Stage stage = new Stage();

         studentenverwaltungsStage = stage;

         stage.setScene(scene);
         stage.setTitle("Studentenverwaltung");
         stage.initOwner(primaryStage);
         stage.initModality(Modality.WINDOW_MODAL);

         StudentenverwaltungsController controller = loader.getController();
         controller.setMain(this);

         stage.showAndWait();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }

   /**
    * Show the Ansprechpartnerverwaltung stage with the corresponding FXML.
    *
    */
   public void showAnsprechpartnerverwaltungsStage()
   {
      try
      {
         FXMLLoader loader = new FXMLLoader(
               getClass().getResource("view/AnsprechpartnerListe.fxml"));
         BorderPane root = (BorderPane) loader.load();

         Scene scene = new Scene(root);
         Stage stage = new Stage();

         ansprechpartnerverwaltungsStage = stage;

         stage.setScene(scene);
         stage.setTitle("Ansprechpartnerverwaltung");
         stage.initOwner(primaryStage);
         stage.initModality(Modality.WINDOW_MODAL);

         AnsprechpartnerListeController controller = loader.getController();
         controller.setMain(this);

         stage.showAndWait();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }

   /**
    * Show the Projekthinzufuegen stage with the corresponding FXML.
    *
    */
   public Projekt showProjekthinzufuegenStage(Projekt projekt)
   {
      try
      {
         FXMLLoader loader = new FXMLLoader(
               getClass().getResource("view/ProjektHinzufuegen.fxml"));
         BorderPane root = (BorderPane) loader.load();

         Scene scene = new Scene(root);
         Stage stage = new Stage();

         projekthinzufuegenStage = stage;

         stage.setScene(scene);
         stage.setTitle("Projekt");
         stage.initOwner(primaryStage);
         stage.initModality(Modality.WINDOW_MODAL);

         ProjektHinzufuegenController controller = loader.getController();
         controller.setMain(this, projekt);

         stage.showAndWait();

         return controller.getProjekt();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
      return null;
   }

   /**
    * Get the primary {@link Stage} for this application. Can for example be
    * used to set modal.
    *
    * @return The primary stage of the application.
    */
   public Stage getPrimaryStage()
   {
      return primaryStage;
   }

   /**
    * Getter for the StudentenverwaltungsStage.
    *
    * @return studentenverwaltungsStage
    */
   public Stage getStudentenverwaltungsStage()
   {
      return studentenverwaltungsStage;
   }

   /**
    * Getter for the AnsprechpartnerverwaltungsStage.
    *
    * @return ansprechpartnerverwaltungsStage
    */
   public Stage getAnsprechpartnerverwaltungsStage()
   {
      return ansprechpartnerverwaltungsStage;
   }

   /**
    * Getter for the ProjekthinzufuegenStage.
    *
    * @return projekthinzufuegenStage
    */
   public Stage getProjekthinzufuegenStage()
   {
      return projekthinzufuegenStage;
   }

   /**
    * Getter for property ansprechpartner.
    * 
    * @return Returns the ansprechpartner.
    */
   public ObservableList<Ansprechpartner> getAnsprechpartner()
   {
      return ansprechpartner;
   }

   /**
    * Getter for property organisation.
    * 
    * @return Returns the organisation.
    */
   public ObservableList<Organisation> getOrganisation()
   {
      return organisation;
   }

   /**
    * Getter for property projekte.
    * 
    * @return Returns the projekte.
    */
   public ObservableList<Projekt> getProjekte()
   {
      return projekte;
   }

   /**
    * Getter for property studenten.
    * 
    * @return Returns the studenten.
    */
   public ObservableList<Student> getStudenten()
   {
      return studenten;
   }

   /**
    * Launches the JavaFX application.
    *
    * @param args
    *           Command line arguments.
    */
   public static void main(String[] args)
   {
      launch(args);
   }
}