Skip to content

Commit

Permalink
CarOps - GUI Completed.
Browse files Browse the repository at this point in the history
  • Loading branch information
billtsol committed Jun 29, 2023
1 parent 6ad9807 commit 1d0cd41
Show file tree
Hide file tree
Showing 24 changed files with 926 additions and 304 deletions.
Binary file added CarOps_final.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ _A full functional Information System_

# Graphical User Interface

<img src="img/gui1.png#gh-dark-mode-only" alt= “” width="50%" height="50%">
<img src="img/gui2.png#gh-dark-mode-only" alt= “” width="50%" height="50%">
<img src="img/gui3.png#gh-dark-mode-only" alt= “” width="50%" height="50%">

# Print output sample

## Catalog print data
Expand Down
Binary file added img/gui1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/gui2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/gui3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
134 changes: 134 additions & 0 deletions src/main/java/com/AddSparePartsScreenView.java
Original file line number Diff line number Diff line change
@@ -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<TempJobObject> sparePartTable;
@FXML
private TableColumn<TempJobObject, String> TableSparePartName, price,amount;
@FXML
private TableColumn<TempJobObject, CheckBox> partCheckBox;
private ObservableList<TempJobObject> sparePartModel;
private ArrayList<TempJobObject> 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<SparePart, Integer> 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();
}
}
57 changes: 57 additions & 0 deletions src/main/java/com/AssignmentObject.java
Original file line number Diff line number Diff line change
@@ -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;
}


}
9 changes: 9 additions & 0 deletions src/main/java/com/CreateAssignmentsScreen.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com;

import com.carops.Assignment;
import com.carops.Engineer;
import com.carops.Job;
import com.carops.Repairfile;
Expand Down Expand Up @@ -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.");
Expand Down
105 changes: 105 additions & 0 deletions src/main/java/com/EngineerScreenController.java
Original file line number Diff line number Diff line change
@@ -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<AssignmentObject> assignmentTable;
@FXML
private TableColumn<AssignmentObject, String> assignmentId, jobName,plateNumber,assignmentStatus,cost;
private ObservableList<AssignmentObject> assignmentModel;

private ArrayList<AssignmentObject> 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();

}
}
8 changes: 0 additions & 8 deletions src/main/java/com/OwnerScreenController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 0 additions & 6 deletions src/main/java/com/StartScreenController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,14 @@
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;
import javafx.scene.Parent;
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;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/SupervisorScreenController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}
}
Loading

0 comments on commit 1d0cd41

Please sign in to comment.