Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Xarczuz committed May 16, 2019
1 parent 28fa0fd commit 5dc38e0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
1 change: 1 addition & 0 deletions .~lock.test.xlsx#
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
,chjunchi,chjunchi-U45JC,16.05.2019 16:41,file:///home/chjunchi/snap/libreoffice/118/.config/libreoffice/4;
39 changes: 17 additions & 22 deletions src/main/java/hazard/HazardAnalysis/Steps/Views/ViewStep8.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
Expand Down Expand Up @@ -148,11 +146,10 @@ public void handle(MouseEvent e) {
TextInputDialog dialog = new TextInputDialog("");
dialog.setTitle("Add Severity And Probability");
dialog.setHeaderText("Enter the Severity of the Cause And the Probability of it happening.");
ObservableList<String> options = FXCollections.observableArrayList("Very-High-100%", "High-80%",
"Medium-60%", "Low-40%", "Very-Low-20%");
ObservableList<String> options = FXCollections.observableArrayList("High-75%", "Medium-50%", "Low-25%");
final ComboBox<String> comboBox = new ComboBox<String>(options);
ObservableList<String> options2 = FXCollections.observableArrayList("Very-High-100%", "High-80%",
"Medium-60%", "Low-40%", "Very-Low-20%");
ObservableList<String> options2 = FXCollections.observableArrayList("High-75%", "Medium-50%",
"Low-25%");
final ComboBox<String> comboBox2 = new ComboBox<String>(options2);
Text severity = new Text("Severity");
Text probability = new Text("Probability");
Expand All @@ -163,11 +160,9 @@ public void handle(MouseEvent e) {
gp.add(comboBox2, 1, 1);
Text riskEvaluation = new Text("Risk Evaluation:");
Text riskEvaluationNr = new Text();
riskEvaluationNr.prefWidth(15);
gp.add(riskEvaluation, 3, 1);
gp.add(riskEvaluationNr, 4, 1);
CheckBox ch = new CheckBox("Accept Risk");
ch.setPadding(new Insets(15, 15, 15, 15));
gp.add(ch, 5, 1);
comboBox.valueProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue ov, String t, String t1) {
Expand All @@ -189,10 +184,14 @@ public void changed(ObservableValue ov, String t, String t1) {
dialog.getDialogPane().setContent(gp);
Optional<String> op = dialog.showAndWait();
if (op.isPresent() && !riskEvaluationNr.getText().contentEquals("")) {
double riskev = (returnRiskValue(comboBox2.getValue()) * returnRiskValue(comboBox.getValue()));
boolean risk = true;
if (riskev > 0.125D) {
risk = false;
}
DataBaseConnection.sqlUpdate("UPDATE cause SET severity=" + returnRiskValue(comboBox.getValue())
+ ", probability=" + returnRiskValue(comboBox2.getValue()) + ", riskevaluation="
+ (returnRiskValue(comboBox2.getValue()) * returnRiskValue(comboBox.getValue())) + ", risk="
+ ch.isSelected() + " where cause.id=" + id + ";");
+ ", probability=" + returnRiskValue(comboBox2.getValue()) + ", riskevaluation=" + riskev
+ ", risk=" + risk + " where cause.id=" + id + ";");
}
updateCauseList(tbHazard, causeList);
}
Expand All @@ -201,16 +200,12 @@ public void changed(ObservableValue ov, String t, String t1) {
}

private Double returnRiskValue(String s) {
if (s.toLowerCase().contentEquals("Very-High-100%"))
return 1D;
if (s.toLowerCase().contentEquals("High-80%"))
return .8D;
if (s.toLowerCase().contentEquals("Medium-60%"))
return .60D;
if (s.toLowerCase().contentEquals("Low-40%"))
return .4D;
if (s.toLowerCase().contentEquals("Very-Low-20%"))
return .2D;
if (s.contentEquals("High-75%"))
return .75D;
if (s.contentEquals("Medium-50%"))
return .50D;
if (s.contentEquals("Low-25%"))
return .25D;
return 0D;
}

Expand Down
Binary file modified test.db
Binary file not shown.
Binary file modified test.xlsx
Binary file not shown.

0 comments on commit 5dc38e0

Please sign in to comment.