diff --git a/CarOps_final.pdf b/CarOps_final.pdf new file mode 100644 index 0000000..99a722e Binary files /dev/null and b/CarOps_final.pdf differ diff --git a/README.md b/README.md index 235b3f7..6854067 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,10 @@ _A full functional Information System_ # Graphical User Interface +“” +“” +“” + # Print output sample ## Catalog print data diff --git a/img/gui1.png b/img/gui1.png new file mode 100644 index 0000000..703bd30 Binary files /dev/null and b/img/gui1.png differ diff --git a/img/gui2.png b/img/gui2.png new file mode 100644 index 0000000..311555f Binary files /dev/null and b/img/gui2.png differ diff --git a/img/gui3.png b/img/gui3.png new file mode 100644 index 0000000..d7d653d Binary files /dev/null and b/img/gui3.png differ diff --git a/src/main/java/com/AddSparePartsScreenView.java b/src/main/java/com/AddSparePartsScreenView.java new file mode 100644 index 0000000..de8bc6d --- /dev/null +++ b/src/main/java/com/AddSparePartsScreenView.java @@ -0,0 +1,134 @@ +package com; + +import com.carops.SparePart; +import com.carops.Vehicle; +import com.catalogs.*; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.control.*; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.control.cell.TextFieldTableCell; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.AnchorPane; +import javafx.scene.text.Text; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; + +public class AddSparePartsScreenView { + + @FXML + private AnchorPane background, messageBox; + @FXML + private TextField hours, jobName; + @FXML + private Text messageBoxText; + @FXML + private Button closeBtn,completedAss,goBackBtn; + + @FXML + private TableView sparePartTable; + @FXML + private TableColumn TableSparePartName, price,amount; + @FXML + private TableColumn partCheckBox; + private ObservableList sparePartModel; + private ArrayList temp = new ArrayList<>(); + + Vehicle v = null; + @FXML + void mouseClicked(MouseEvent event) throws IOException { + if (event.getSource() == goBackBtn){ + StartScreenController.sceneGenerator("EngineerScreenController-view.fxml", event, "CarOps Information System"); + }else if (event.getSource() == completedAss) { + + HashMap spareParts = new HashMap<>(); + + for (int i =0; i< temp.size(); i++){ + if(temp.get(i).getCheckBox().isSelected()){ + + spareParts.put(SparePartsCatalog.findSpareByName(temp.get(i).getName()), Integer.getInteger(temp.get(i).getAmount())); + + } + } + + if (!hours.getText().equals("")){ + messageBoxText.setText("Successfully created."); + background.setDisable(true); + messageBox.setVisible(true); + + EngineerScreenController.engineerCurrAss.setSpareParts(spareParts); + + StartScreenController.engineer.setAssignmentWorktime(EngineerScreenController.engineerCurrAss, Integer.parseInt(hours.getText())); + StartScreenController.engineer.setAssignmentStatus(EngineerScreenController.engineerCurrAss,true); + + + RepairfileCatalog.save(); + EngineerCatalog.save(); + SparePartsCatalog.save(); + + } + + if (hours.getText().equals("")){ + messageBoxText.setText("Hours cannot be empty."); + messageBox.setVisible(true); + background.setDisable(true); + + } + + }else if (event.getSource() == closeBtn){ + messageBox.setVisible(false); + background.setDisable(false); + } + } + public void loadAppointmentToTable(){ + + for (SparePart sp : SparePartsCatalog.fetchSpareParts()){ + temp.add(new TempJobObject(sp.getName(), sp.getPrice(), new CheckBox(), "0")); + } + + sparePartModel = FXCollections.observableArrayList(temp); + + TableSparePartName.setCellValueFactory(new PropertyValueFactory<>("Name")); + price.setCellValueFactory(new PropertyValueFactory<>("Price")); + partCheckBox.setCellValueFactory(new PropertyValueFactory<>("CheckBox")); + amount.setCellValueFactory(new PropertyValueFactory<>("Amount")); + + sparePartTable.setItems(sparePartModel); + + } + + private void editableCols(){ + amount.setCellFactory(TextFieldTableCell.forTableColumn()); + amount.setOnEditCommit(e->e.getTableView().getItems().get(e.getTablePosition().getRow()).setId(e.getNewValue())); + + sparePartTable.setEditable(true); + } + + @FXML + void initialize() { + assert background != null : "fx:id=\"background\" was not injected: check your FXML file 'AddSparePartsScreen-view.fxml'."; + assert messageBox != null : "fx:id=\"messageBox\" was not injected: check your FXML file 'AddSparePartsScreen-view.fxml'."; + + assert goBackBtn != null : "fx:id=\"goBackBtn\" was not injected: check your FXML file 'AddSparePartsScreen-view.fxml'."; + assert jobName != null : "fx:id=\"jobName\" was not injected: check your FXML file 'AddSparePartsScreen-view.fxml'."; + assert hours != null : "fx:id=\"hours\" was not injected: check your FXML file 'AddSparePartsScreen-view.fxml'."; + + // SparePart Table + assert sparePartTable != null : "fx:id=\"sparePartTable\" was not injected: check your FXML file 'AddSparePartsScreen-view.fxml'."; + assert TableSparePartName != null : "fx:id=\"TableSparePartName\" was not injected: check your FXML file 'AddSparePartsScreen-view.fxml'."; + assert price != null : "fx:id=\"price\" was not injected: check your FXML file 'AddSparePartsScreen-view.fxml'."; + assert partCheckBox != null : "fx:id=\"partCheckBox\" was not injected: check your FXML file 'AddSparePartsScreen-view.fxml'."; + assert amount != null : "fx:id=\"amount\" was not injected: check your FXML file 'AddSparePartsScreen-view.fxml'."; + + + assert completedAss != null : "fx:id=\"completedAss\" was not injected: check your FXML file 'AddSparePartsScreen-view.fxml'."; + + jobName.setText(EngineerScreenController.engineerCurrAss.getJob().getName().toUpperCase()); + loadAppointmentToTable(); + + editableCols(); + } +} diff --git a/src/main/java/com/AssignmentObject.java b/src/main/java/com/AssignmentObject.java new file mode 100644 index 0000000..a42001f --- /dev/null +++ b/src/main/java/com/AssignmentObject.java @@ -0,0 +1,57 @@ +package com; + +public class AssignmentObject { + private String id; + private String plateNumber; + private String jobName; + private String assignmentStatus; + private String cost; + public AssignmentObject(String id, String plateNumber, String jobName, String assignmentStatus, String cost) { + this.id = id; + this.plateNumber = plateNumber; + this.jobName = jobName; + this.assignmentStatus = assignmentStatus; + this.cost = cost; + } + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPlateNumber() { + return plateNumber; + } + + public void setPlateNumber(String plateNumber) { + this.plateNumber = plateNumber; + } + + public String getJobName() { + return jobName; + } + + public void setJobName(String jobName) { + this.jobName = jobName; + } + + public String getAssignmentStatus() { + return assignmentStatus; + } + + public void setAssignmentStatus(String assignmentStatus) { + this.assignmentStatus = assignmentStatus; + } + + public String getCost() { + return cost; + } + + public void setCost(String cost) { + this.cost = cost; + } + + +} diff --git a/src/main/java/com/CreateAssignmentsScreen.java b/src/main/java/com/CreateAssignmentsScreen.java index 19732bd..10fd035 100644 --- a/src/main/java/com/CreateAssignmentsScreen.java +++ b/src/main/java/com/CreateAssignmentsScreen.java @@ -1,5 +1,6 @@ package com; +import com.carops.Assignment; import com.carops.Engineer; import com.carops.Job; import com.carops.Repairfile; @@ -53,11 +54,19 @@ else if (event.getSource() == setAssignment) { Job job = SupervisorScreenController.r.getJobs().get(Integer.parseInt(jobNumber.getText()) - 1); Repairfile rp = SupervisorScreenController.r; + for (Engineer eng : EngineerCatalog.fetchEngineers()){ + for (Assignment ass : eng.getAssignments()){ + if (ass.getJob().getName().equals(job.getName()) && ass.getRepairfile().getVehicle().getPlateNumber().equals(rp.getVehicle().getPlateNumber())){ + jobs.put(job, true); + } + } + } if (!jobs.get(job)){ jobs.put(job, true); StartScreenController.supervisorEngineer.createAssignment(engineer,job,rp); messageBoxText.setText("Successfully added."); RepairfileCatalog.save(); + EngineerCatalog.save(); }else{ messageBoxText.setText("Assignment has been already created."); diff --git a/src/main/java/com/EngineerScreenController.java b/src/main/java/com/EngineerScreenController.java index ee2ef68..d732095 100644 --- a/src/main/java/com/EngineerScreenController.java +++ b/src/main/java/com/EngineerScreenController.java @@ -1,4 +1,109 @@ package com; +import com.carops.Assignment; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.control.*; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.input.MouseEvent; +import javafx.scene.text.Text; + +import java.io.IOException; +import java.util.ArrayList; + public class EngineerScreenController { + @FXML + private TextField assId,EngineerName; + @FXML + private Text assignmentIdErr; + + @FXML + private Button goBackBtn,editAssignmentBtn ; + + @FXML + private TableView assignmentTable; + @FXML + private TableColumn assignmentId, jobName,plateNumber,assignmentStatus,cost; + private ObservableList assignmentModel; + + private ArrayList assObj; + public static Assignment engineerCurrAss = null; + @FXML + void mouseClicked(MouseEvent event) throws IOException { + + if (event.getSource() == goBackBtn){ + StartScreenController.sceneGenerator("StartScreenController-view.fxml", event, "CarOps Information System"); + } + else if (event.getSource() == editAssignmentBtn) { + boolean flag = false; + + for (AssignmentObject ass : assObj){ + if (ass.getId().equals(assId.getText())){ + flag = true; + break; + } + } + + if (flag){ + engineerCurrAss = StartScreenController.engineer.getAssignments().get( Integer.parseInt(assId.getText()) - 1); + assignmentIdErr.setText("*"); + StartScreenController.sceneGenerator("AddSparePartsScreen-view.fxml", event, "Engineer Screen"); + + }else{ + assignmentIdErr.setText("Assignment Id does not exist."); + engineerCurrAss = null; + } + + } + } + public void loadAppointmentToTable(){ + assObj = new ArrayList<>(); + int i = 1; + for (Assignment ass : StartScreenController.engineer.getAssignments()){ + + assObj.add(new AssignmentObject(String.valueOf(i), + ass.getRepairfile().getVehicle().getPlateNumber(), + ass.getJob().getName(), + String.valueOf(ass.getStatus()), + String.valueOf(ass.getRepairfile().getTotalCost()) + ) + ); + + i++; + } + assignmentModel = FXCollections.observableArrayList(assObj); + + assignmentId.setCellValueFactory(new PropertyValueFactory<>("Id")); + plateNumber.setCellValueFactory(new PropertyValueFactory<>("PlateNumber")); + jobName.setCellValueFactory(new PropertyValueFactory<>("JobName")); + assignmentStatus.setCellValueFactory(new PropertyValueFactory<>("AssignmentStatus")); + cost.setCellValueFactory(new PropertyValueFactory<>("Cost")); + + assignmentTable.setItems(assignmentModel); + } + + @FXML + void initialize() { + assert EngineerName != null : "fx:id=\"EngineerName\" was not injected: check your FXML file 'EngineerScreenController-view.fxml'."; + + assert assId != null : "fx:id=\"assId\" was not injected: check your FXML file 'EngineerScreenController-view.fxml'."; + + // table + assert assignmentTable != null : "fx:id=\"assignmentTable\" was not injected: check your FXML file 'EngineerScreenController-view.fxml'."; + assert assignmentId != null : "fx:id=\"assignmentId\" was not injected: check your FXML file 'EngineerScreenController-view.fxml'."; + assert plateNumber != null : "fx:id=\"plateNumber\" was not injected: check your FXML file 'EngineerScreenController-view.fxml'."; + assert jobName != null : "fx:id=\"jobName\" was not injected: check your FXML file 'EngineerScreenController-view.fxml'."; + assert assignmentStatus != null : "fx:id=\"assignmentStatus\" was not injected: check your FXML file 'EngineerScreenController-view.fxml'."; + assert cost != null : "fx:id=\"cost\" was not injected: check your FXML file 'EngineerScreenController-view.fxml'."; + + assert editAssignmentBtn != null : "fx:id=\"editAssignmentBtn\" was not injected: check your FXML file 'EngineerScreenController-view.fxml'."; + assert goBackBtn != null : "fx:id=\"goBackBtn\" was not injected: check your FXML file 'EngineerScreenController-view.fxml'."; + assert assignmentIdErr != null : "fx:id=\"assignmentIdErr\" was not injected: check your FXML file 'EngineerScreenController-view.fxml'."; + + EngineerName.setText(StartScreenController.engineer.getSurname().toUpperCase()); + + loadAppointmentToTable(); + + } } diff --git a/src/main/java/com/OwnerScreenController.java b/src/main/java/com/OwnerScreenController.java index d803a0d..8f144a3 100644 --- a/src/main/java/com/OwnerScreenController.java +++ b/src/main/java/com/OwnerScreenController.java @@ -2,17 +2,9 @@ import com.carops.Engineer; import com.catalogs.EngineerCatalog; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.scene.Node; -import javafx.scene.Parent; import javafx.scene.control.*; import javafx.scene.input.MouseEvent; -import javafx.scene.layout.Background; -import javafx.scene.paint.Color; -import javafx.stage.Stage; import java.io.IOException; diff --git a/src/main/java/com/StartScreenController.java b/src/main/java/com/StartScreenController.java index 6f0447c..d9f4ab5 100644 --- a/src/main/java/com/StartScreenController.java +++ b/src/main/java/com/StartScreenController.java @@ -8,9 +8,6 @@ import com.carops.Secretary; import com.carops.SupervisorEngineer; import com.catalogs.*; - -import javafx.animation.KeyFrame; -import javafx.animation.Timeline; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Node; @@ -18,10 +15,7 @@ import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.input.MouseEvent; -import javafx.scene.layout.Background; -import javafx.scene.paint.Color; import javafx.stage.Stage; -import javafx.util.Duration; public class StartScreenController { private static Stage stage; diff --git a/src/main/java/com/SupervisorScreenController.java b/src/main/java/com/SupervisorScreenController.java index 137f263..d62df14 100644 --- a/src/main/java/com/SupervisorScreenController.java +++ b/src/main/java/com/SupervisorScreenController.java @@ -91,8 +91,8 @@ private boolean checkVehicle(){ for (Repairfile rp : RepairfileCatalog.fetchRepairfiles() ){ if (rp.getVehicle().getPlateNumber().equals(v.getPlateNumber()) && !rp.getStatus().equals("Completed")){ - System.out.println(rp.getVehicle().getPlateNumber().equals(v.getPlateNumber()) + " " + !rp.getStatus().equals("Completed")); r = rp; + moveBtn.setDisable(false); return true; } @@ -115,5 +115,6 @@ void initialize() { assert jobPrice != null : "fx:id=\"jobPrice\" was not injected: check your FXML file 'ReceptionScreenController-view.fxml'."; assert jobCheckBox != null : "fx:id=\"jobCheckBox\" was not injected: check your FXML file 'ReceptionScreenController-view.fxml'."; + moveBtn.setDisable(true); } } \ No newline at end of file diff --git a/src/main/java/com/TempJobObject.java b/src/main/java/com/TempJobObject.java index ebf25b8..3beefa7 100644 --- a/src/main/java/com/TempJobObject.java +++ b/src/main/java/com/TempJobObject.java @@ -7,6 +7,7 @@ public class TempJobObject { private String name, description; private int price; private CheckBox checkBox; + private String amount; public TempJobObject(String name, int price, String description, CheckBox ch) { this.name = name; @@ -16,6 +17,22 @@ public TempJobObject(String name, int price, String description, CheckBox ch) { this.checkBox.setAllowIndeterminate(true); } + public TempJobObject(String name, int price, CheckBox ch, String amount) { + this.name = name; + this.price = price; + this.amount = amount; + this.checkBox = ch; + this.checkBox.setAllowIndeterminate(true); + } + + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + public String getId() { return id; } diff --git a/src/main/java/com/VehicleCreationScreen.java b/src/main/java/com/VehicleCreationScreen.java index ea13649..6d561e9 100644 --- a/src/main/java/com/VehicleCreationScreen.java +++ b/src/main/java/com/VehicleCreationScreen.java @@ -1,19 +1,12 @@ package com; -import com.catalogs.CustomerCatalog; import com.catalogs.VehicleCatalog; import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.scene.Node; -import javafx.scene.Parent; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.Background; -import javafx.scene.paint.Color; import javafx.scene.text.Text; -import javafx.stage.Stage; import java.io.IOException; diff --git a/src/main/resources/com/AddSparePartsScreen-view.fxml b/src/main/resources/com/AddSparePartsScreen-view.fxml new file mode 100644 index 0000000..9e3b016 --- /dev/null +++ b/src/main/resources/com/AddSparePartsScreen-view.fxml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/CreateAssignmentsScreen-view.fxml b/src/main/resources/com/CreateAssignmentsScreen-view.fxml index 11c4bb2..87d2a63 100644 --- a/src/main/resources/com/CreateAssignmentsScreen-view.fxml +++ b/src/main/resources/com/CreateAssignmentsScreen-view.fxml @@ -6,136 +6,143 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/EditAppointmentScreen-view.fxml b/src/main/resources/com/EditAppointmentScreen-view.fxml index 5b6915f..f8e8532 100644 --- a/src/main/resources/com/EditAppointmentScreen-view.fxml +++ b/src/main/resources/com/EditAppointmentScreen-view.fxml @@ -10,7 +10,7 @@ + prefWidth="778.0" styleClass="appointmentTable" stylesheets="@../Styles/style.css"> diff --git a/src/main/resources/com/EngineerScreenController-view.fxml b/src/main/resources/com/EngineerScreenController-view.fxml index 09b6a13..ff77cbc 100644 --- a/src/main/resources/com/EngineerScreenController-view.fxml +++ b/src/main/resources/com/EngineerScreenController-view.fxml @@ -1,9 +1,69 @@ + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/VehicleCreationScreen-view.fxml b/src/main/resources/com/VehicleCreationScreen-view.fxml index d757ac4..3ad0d20 100644 --- a/src/main/resources/com/VehicleCreationScreen-view.fxml +++ b/src/main/resources/com/VehicleCreationScreen-view.fxml @@ -13,8 +13,8 @@ stylesheets="@../Styles/style.css" xmlns="http://javafx.com/javafx/19"> + + + + + + diff --git a/target/classes/com/CreateAssignmentsScreen-view.fxml b/target/classes/com/CreateAssignmentsScreen-view.fxml index 11c4bb2..87d2a63 100644 --- a/target/classes/com/CreateAssignmentsScreen-view.fxml +++ b/target/classes/com/CreateAssignmentsScreen-view.fxml @@ -6,136 +6,143 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/target/classes/com/EditAppointmentScreen-view.fxml b/target/classes/com/EditAppointmentScreen-view.fxml index 5b6915f..f8e8532 100644 --- a/target/classes/com/EditAppointmentScreen-view.fxml +++ b/target/classes/com/EditAppointmentScreen-view.fxml @@ -10,7 +10,7 @@ + prefWidth="778.0" styleClass="appointmentTable" stylesheets="@../Styles/style.css"> diff --git a/target/classes/com/EngineerScreenController-view.fxml b/target/classes/com/EngineerScreenController-view.fxml index 09b6a13..ff77cbc 100644 --- a/target/classes/com/EngineerScreenController-view.fxml +++ b/target/classes/com/EngineerScreenController-view.fxml @@ -1,9 +1,69 @@ + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/target/classes/com/VehicleCreationScreen-view.fxml b/target/classes/com/VehicleCreationScreen-view.fxml index d757ac4..3ad0d20 100644 --- a/target/classes/com/VehicleCreationScreen-view.fxml +++ b/target/classes/com/VehicleCreationScreen-view.fxml @@ -13,8 +13,8 @@ stylesheets="@../Styles/style.css" xmlns="http://javafx.com/javafx/19">