-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainApp.java
More file actions
156 lines (124 loc) · 3.92 KB
/
MainApp.java
File metadata and controls
156 lines (124 loc) · 3.92 KB
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
package gui;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import domain.*;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import logic.*;
public class MainApp extends Application {
private Stage primaryStage;
private BorderPane rootLayout;
private IESController IES_CI = new IESControllerImpl();
private ObservableList<Medarbejder> personData = FXCollections.observableArrayList();
private ObservableList<Kompetence> kompetenceData = FXCollections.observableArrayList();
@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("Ipsos Employee System");
initRootLayout();
showPersonOverview();
}
public void initRootLayout() {
try {
// Load root layout from fxml file.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("RootLayout.fxml"));
rootLayout = (BorderPane) loader.load();
// Show the scene containing the root layout.
Scene scene = new Scene(rootLayout);
primaryStage.setScene(scene);
primaryStage.show();
} catch (IOException e) {
throw new RuntimeException("MainApp initRootLayout : fejl", e);
}
}
public void showPersonOverview() {
try {
// Load person overview.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("ShowEmployee.fxml"));
AnchorPane personOverview = (AnchorPane) loader.load();
// Set person overview into the center of root layout.
rootLayout.setCenter(personOverview);
ShowEmployeeController controller = loader.getController();
controller.setMainApp(this);
} catch (IOException e) {
throw new RuntimeException("MainApp showPersonOverview : fejl", e);
}
}
public void showSkillSearch() {
try {
// Load skill search.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("SkillSearch.fxml"));
AnchorPane personOverview = (AnchorPane) loader.load();
// Set person overview into the center of root layout.
rootLayout.setCenter(personOverview);
SkillSearchController controller = loader.getController();
controller.setMainApp(this);
} catch (IOException e) {
throw new RuntimeException("MainApp showSkillSearch : fejl", e);
}
}
public MainApp() {
List<Medarbejder> medarbejdere = new ArrayList<>();
List<Kompetence> kompetencer = new ArrayList<>();
try {
medarbejdere = IES_CI.præsenterMedarbejderKompetenceListe();
for (Medarbejder m : medarbejdere) {
personData.add(m);
}
} catch (Exception e) {
throw new RuntimeException("MainApp constructor : fejl", e);
}
try {
kompetencer = IES_CI.præsenterKompetenceListe();
for (Kompetence k : kompetencer) {
kompetenceData.add(k);
}
} catch (Exception e) {
throw new RuntimeException("MainApp constructor : fejl", e);
}
}
public ObservableList<Medarbejder> getPersonData() {
return personData;
}
public ObservableList<Kompetence> getKompetenceData() {
return kompetenceData;
}
public Stage getPrimaryStage() {
return primaryStage;
}
public static void main(String[] args) {
launch(args);
}
public void refresh() {
List<Medarbejder> medarbejdere = new ArrayList<>();
try {
personData.clear();
medarbejdere = IES_CI.præsenterMedarbejderKompetenceListe();
for (Medarbejder M : medarbejdere) {
personData.add(M);
}
} catch (Exception e) {
throw new RuntimeException("MainApp constructor : fejl", e);
}
}
public void refreshFromSkillSearch(List<Medarbejder> medarbejdere) {
try {
personData.clear();
for (Medarbejder M : medarbejdere) {
personData.add(M);
}
} catch (Exception e) {
throw new RuntimeException("MainApp constructor : fejl", e);
}
}
}