Newer
Older
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.*;
@FXML
BorderPane myBorderPane;
@FXML
VBox leftSideButtons;
@FXML
TextArea employees;
@FXML
private TextField addFirstName;
@FXML
private TextField addLastName;
@FXML
private TextField removeID;
@FXML
Button addShiftSubmitButton;
@FXML
DatePicker addShiftDatePicker;
@FXML
TextField addShiftStartTime;
@FXML
TextField addShiftEndTime;
@FXML
ComboBox addShiftEmployeeBox;
@FXML
HBox addShiftEmployeeHBox;
@FXML
ComboBox addShiftStartTimeBox;
@FXML
ComboBox addShiftEndTimeBox;
@FXML
TextField editEmployeeFirstName;
@FXML
TextField editEmployeeLastName;
@FXML
TextField editEmployeeEmail;
@FXML
TextField editEmployeeWage;
@FXML
TextField editEmployeePhoneNumber;
@FXML
TextField editEmployeeAddress;
@FXML
ComboBox editEmployeeBox;
@FXML
CheckBox editEmployeeManager;
ArktikHunter
committed
DailyView dailyView;
WeeklyView weeklyView;
BorderPane root;
Parent header;
Parent sidePanel;
Parent bottomPanel;
public void scheduleButtonClicked() throws IOException {
System.out.println("schedule button clicked");
dailyScheduleButtonClicked();
leftSideButtons.setVisible(true);
}
public void paystubButtonClicked() throws IOException {
System.out.println("paystub button clicked");
FXMLLoader fxmlLoader = new FXMLLoader(ScheduleApp.class.getResource("paystubView.fxml"));
myBorderPane.setCenter(fxmlLoader.load());
leftSideButtons.setVisible(false);
}
public void availabilityButtonClicked() {
System.out.println("availability button clicked");
}
public void timeoffButtonClicked () {
System.out.println("timeoff button clicked");
}
public void dailyScheduleButtonClicked() throws IOException {
System.out.println("daily schedule button clicked");
ArktikHunter
committed
root.setTop(header);
root.setLeft(sidePanel);
root.setBottom(bottomPanel);
root.setCenter(dailyView);
public void weeklyScheduleButtonClicked() throws Exception {
System.out.println("weekly schedule button clicked");
ArktikHunter
committed
root.setTop(header);
root.setLeft(sidePanel);
root.setBottom(bottomPanel);
root.setCenter(weeklyView);
}
public void pickupsButtonClicked () {
System.out.println("pickups button clicked");
}
public void prevButtonClicked (MouseEvent event) throws Exception {
System.out.println("prev button clicked");
ArktikHunter
committed
model.datePrev();
public void jumpButtonClicked (MouseEvent event) throws Exception {
System.out.println("jump button clicked");
ArktikHunter
committed
//model.dateJump();
public void nextButtonClicked (MouseEvent event) throws Exception {
System.out.println("next button clicked");
ArktikHunter
committed
model.dateNext();
public void addShiftClicked() throws IOException {
FXMLLoader popupLoader = new FXMLLoader(this.getClass().getResource("addShiftPopup.fxml"));
popupLoader.setController(this);
popupScene = new Scene(popupLoader.load(),500,500);
popupStage = new Stage();
popupStage.setScene(popupScene);
popupStage.show();
public void populateEmployeeBox(MouseEvent event) {
ObservableList<String> list = FXCollections.observableArrayList();
ComboBox test = (ComboBox) event.getSource();
test.setItems(list);
System.out.println("submit clicked");
int index = addShiftEmployeeBox.getSelectionModel().getSelectedIndex();
String startTime = (String) addShiftStartTimeBox.getValue();
String endTime = (String) addShiftEndTimeBox.getValue();
model.addShift(model.getIDbyIndex(index),date.toString(),Integer.parseInt(startTime),Integer.parseInt(endTime));
System.out.println(model.getIDbyIndex(index) + "20210101" + Integer.parseInt(startTime) + Integer.parseInt(endTime));
//System.out.println(employee + startTime + endTime + date);
public void managerScheduleClicked(MouseEvent event) throws IOException {
System.out.println("manager schedule clicked");
managerLoginClicked(event);
}
public void managerDailyScheduleClicked(MouseEvent mouseEvent) throws IOException{
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
headerLoader.setController(this);
header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("schedSidePanel.fxml"));
sideLoader.setController(this);
sidePanel = sideLoader.load();
FXMLLoader bottomLoader = new FXMLLoader(this.getClass().getResource("schedBottomPanelManager.fxml"));
bottomLoader.setController(this);
bottomPanel = bottomLoader.load();
root.setTop(header);;
root.setLeft(sidePanel);
root.setBottom(bottomPanel);
root.setCenter(dailyView);
HBox box = (HBox) bottomPanel.getChildrenUnmodifiable().get(1);
Label currentDateText = (Label) box.getChildren().get(1);
currentDateText.setText("Current Date: " + model.date);
System.out.println(isDaily);
public void addShiftTimeBoxClicked(MouseEvent event){
System.out.println("add shift time box clicked");
ArrayList<String> times = new ArrayList<>();
for (int i = 8; i < 24; i++){
String j = i + "00";
String k = i + "30";
if (i < 10) {
j = "0" + j;
k = "0" + k;
}
times.add(j);
times.add(k);
}
ComboBox box = (ComboBox) event.getSource();
ObservableList<String> list = FXCollections.observableArrayList(times);
System.out.println(list);
box.setItems(list);
public void updateCurrentDate(MouseEvent event) throws Exception {
if(currentDateText == null){
currentDateText = new Label();
}
currentDateText.setText("Current Date: " + model.date.toString());
System.out.println(isDaily);
updateScheduleViews(event);
}
public void updateScheduleViews(MouseEvent event) throws Exception {
if(isDaily){
managerDailyScheduleClicked(event);
}
else{
managerScheduleClicked(event);
}
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
public void employeeDailyClicked(){
System.out.println("employee daily clicked");
root.setCenter(dailyView);
root.setLeft(sidePanel);
root.setBottom(bottomPanel);
}
public void employeeWeeklyClicked(){
System.out.println("employee weekly clicked");
root.setCenter(weeklyView);
root.setLeft(sidePanel);
root.setBottom(bottomPanel);
}
public void employeePickupClicked() throws IOException {
System.out.println("employee pickup clicked");
FXMLLoader pickupLoader = new FXMLLoader(getClass().getResource("employeePickup.fxml"));
pickupLoader.setController(this);
root.setCenter(pickupLoader.load());
root.setBottom(null);
}
public void employeeScheduleClicked(){
System.out.println("employee schedule clicked");
employeeWeeklyClicked();
}
public void employeeAvailabilityClicked() throws IOException {
System.out.println("employee availability clicked");
FXMLLoader availabilityLoader = new FXMLLoader(getClass().getResource("employeeAvailability.fxml"));
availabilityLoader.setController(this);
FXMLLoader availabilityFooterLoader = new FXMLLoader(getClass().getResource("employeeAvailabilityFooter.fxml"));
availabilityFooterLoader.setController(this);
root.setCenter(availabilityLoader.load());
root.setLeft(null);
root.setBottom(availabilityFooterLoader.load());
}
public void employeePaystubClicked() throws IOException {
System.out.println("employee paystub clicked");
FXMLLoader paystubLoader = new FXMLLoader(getClass().getResource("employeePaystub.fxml"));
paystubLoader.setController(this);
root.setCenter(paystubLoader.load());
root.setLeft(null);
root.setBottom(bottomPanel);
}
public void employeeNextButtonClicked(){
System.out.println("employee next clicked");
}
public void employeePrevButtonClicked(){
System.out.println("employee prev clicked");
}
public void employeeJumpButtonClicked(){
System.out.println("employee jump clicked");
public void managerLoginClicked(MouseEvent mouseEvent) throws IOException {
ArktikHunter
committed
root = new BorderPane();
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
headerLoader.setController(this);
ArktikHunter
committed
header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("schedSidePanel.fxml"));
sideLoader.setController(this);
ArktikHunter
committed
sidePanel = sideLoader.load();
FXMLLoader bottomLoader = new FXMLLoader(this.getClass().getResource("schedBottomPanelManager.fxml"));
bottomLoader.setController(this);
ArktikHunter
committed
bottomPanel = bottomLoader.load();
model = new Model("localhost", 8989);
model.setIsManager(true);
model.setThisEmployee(Integer.parseInt(loginField.getText())); //todo:need guard to allow only #
ArktikHunter
committed
dailyView = new DailyView();
ArktikHunter
committed
weeklyView = new WeeklyView();
root.setTop(header);
root.setLeft(sidePanel);
root.setBottom(bottomPanel);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
HBox box = (HBox) bottomPanel.getChildrenUnmodifiable().get(1);
Label currentDateText = (Label) box.getChildren().get(1);
currentDateText.setText("Current Date: " + model.date);
public void employeeLoginClicked(MouseEvent mouseEvent) throws IOException {
model = new Model("localhost", 8989);
model.setIsManager(true);
model.setThisEmployee(Integer.parseInt(loginField.getText())); //todo:need guard to allow only #
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("employeeHeader.fxml"));
headerLoader.setController(this);
header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("employeeSchedSidePanel.fxml"));
sideLoader.setController(this);
sidePanel = sideLoader.load();
FXMLLoader bottomLoader = new FXMLLoader(this.getClass().getResource("employeeSchedBottomPanel.fxml"));
bottomLoader.setController(this);
bottomPanel = bottomLoader.load();
root = new BorderPane();
root.setTop(header);
root.setLeft(sidePanel);
root.setBottom(bottomPanel);
ArktikHunter
committed
dailyView = new DailyView();
dailyView.setModel(model);
weeklyView = new WeeklyView();
weeklyView.setModel(model);
ArktikHunter
committed
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
public void mangerLogoutClicked(MouseEvent mouseEvent) throws IOException {
FXMLLoader loginLoader = new FXMLLoader(this.getClass().getResource("login.fxml"));
loginLoader.setController(this);
Parent root = loginLoader.load();
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
// Staff Section
// Switch to Staff Page
public void staffManagerClicked(MouseEvent mouseEvent) throws IOException {
BorderPane root = new BorderPane();
FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("addEmployee.fxml"));
gridLoader.setController(this);
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
headerLoader.setController(this);
Parent header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("staffManagerSidePanel.fxml"));
sideLoader.setController(this);
Parent sidePanel = sideLoader.load();
root.setTop(header);
root.setLeft(sidePanel);
root.setCenter(grid);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
// Side Panel
// Switch to Edit Employee
public void editStaffSidePanelClicked(MouseEvent mouseEvent) throws IOException {
BorderPane root = new BorderPane();
FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("editEmployee.fxml"));
gridLoader.setController(this);
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
headerLoader.setController(this);
Parent header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("staffManagerSidePanel.fxml"));
sideLoader.setController(this);
Parent sidePanel = sideLoader.load();
root.setTop(header);
root.setLeft(sidePanel);
root.setCenter(grid);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
}
// Switch to Remove Employee
public void removeStaffSidePanelClicked(MouseEvent mouseEvent) throws IOException {
FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("removeEmployee.fxml"));
gridLoader.setController(this);
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
headerLoader.setController(this);
Parent header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("staffManagerSidePanel.fxml"));
sideLoader.setController(this);
Parent sidePanel = sideLoader.load();
root.setTop(header);
root.setLeft(sidePanel);
root.setCenter(grid);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
}
// Switch to View Employees
public void viewStaffSidePanelClicked(MouseEvent mouseEvent) throws IOException {
BorderPane root = new BorderPane();
FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("viewEmployees.fxml"));
gridLoader.setController(this);
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
headerLoader.setController(this);
Parent header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("staffManagerSidePanel.fxml"));
sideLoader.setController(this);
Parent sidePanel = sideLoader.load();
root.setTop(header);
root.setLeft(sidePanel);
root.setCenter(grid);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
}
// Add, Edit, Remove Functions
// Add Employee
public void addEmployeeClicked(MouseEvent mouseEvent) {
String firstName = addFirstName.getText();
String lastName = addLastName.getText();
model.addEmployee(firstName, lastName);
System.out.println("Employee " + firstName + " " + lastName + " added to Staff. Welcome "
+ firstName + "!");
}
public void editEmployeeClicked(MouseEvent mouseEvent) {
int id = model.getIDbyIndex(editEmployeeBox.getSelectionModel().getSelectedIndex());
String newFirstName = editEmployeeFirstName.getText();
String newLastName = editEmployeeLastName.getText();
String newEmail = editEmployeeEmail.getText();
Float newWage = Float.parseFloat(editEmployeeWage.getText());
String newPhoneNumber = editEmployeePhoneNumber.getText();
boolean newIsManager = editEmployeeManager.isSelected();
model.editEmployee(id,newFirstName,newLastName,newIsManager,newEmail,newPhoneNumber,newWage);
System.out.println("edit employee submit clicked");
public void removeEmployeeClicked(MouseEvent mouseEvent) {
int index = removeEmployeeBox.getSelectionModel().getSelectedIndex();
String id = String.valueOf(model.getIDbyIndex(index));
model.removeEmployee(id);
removeEmployeeBox.getSelectionModel().clearSelection();