-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
926 additions
and
304 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.