#24: Javadoc & Cleanup
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
parent
02232cd27f
commit
2e3baff124
4 changed files with 38 additions and 0 deletions
Binary file not shown.
|
@ -7,6 +7,8 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import de.hitec.nhplus.Main;
|
import de.hitec.nhplus.Main;
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
|
import de.hitec.nhplus.login.Permissions;
|
||||||
|
import de.hitec.nhplus.main.MainWindowController;
|
||||||
import de.hitec.nhplus.medication.database.MedicationDao;
|
import de.hitec.nhplus.medication.database.MedicationDao;
|
||||||
import de.hitec.nhplus.nurse.Nurse;
|
import de.hitec.nhplus.nurse.Nurse;
|
||||||
import de.hitec.nhplus.patient.Patient;
|
import de.hitec.nhplus.patient.Patient;
|
||||||
|
@ -15,6 +17,7 @@ import de.hitec.nhplus.treatment.TreatmentModalController;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
@ -51,15 +54,23 @@ public class AllMedicationController {
|
||||||
private TableColumn<Medication, Integer> columnCurrentStock;
|
private TableColumn<Medication, Integer> columnCurrentStock;
|
||||||
@FXML
|
@FXML
|
||||||
public Button buttonChangeAvailable;
|
public Button buttonChangeAvailable;
|
||||||
|
@FXML
|
||||||
|
public Button buttonAdd;
|
||||||
|
@FXML
|
||||||
|
public Button buttonDelete;
|
||||||
|
|
||||||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||||
private MedicationDao dao;
|
private MedicationDao dao;
|
||||||
|
private boolean hasEditPermissions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization method that is called after the binding of all the fields.
|
* Initialization method that is called after the binding of all the fields.
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
int editPermissions = Permissions.MANAGEMENT | Permissions.OWNER;
|
||||||
|
int userPermissions = MainWindowController.getInstance().getUser().getPermissions();
|
||||||
|
hasEditPermissions = (userPermissions & editPermissions) != 0;
|
||||||
this.readAllAndShowInTableView();
|
this.readAllAndShowInTableView();
|
||||||
|
|
||||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||||
|
@ -86,6 +97,12 @@ public class AllMedicationController {
|
||||||
|
|
||||||
this.tableView.setItems(this.medications);
|
this.tableView.setItems(this.medications);
|
||||||
|
|
||||||
|
if (!hasEditPermissions) {
|
||||||
|
this.buttonAdd.setDisable(true);
|
||||||
|
this.buttonDelete.setDisable(true);
|
||||||
|
this.buttonChangeAvailable.setDisable(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,6 +157,22 @@ public class AllMedicationController {
|
||||||
this.readAllAndShowInTableView();
|
this.readAllAndShowInTableView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void handleDelete() {
|
||||||
|
Medication selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
|
if (selectedItem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.dao.delete(selectedItem.getId());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
this.readAllAndShowInTableView();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal method to create a {@link MedicationModalController MedicationModal}.
|
* Internal method to create a {@link MedicationModalController MedicationModal}.
|
||||||
*
|
*
|
||||||
|
@ -184,4 +217,5 @@ public class AllMedicationController {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,9 @@ public class DeprecatedMedicationController {
|
||||||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||||
private MedicationDao dao;
|
private MedicationDao dao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialization method that is called after the binding of all the fields.
|
||||||
|
*/
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
this.readAllAndShowInTableView();
|
this.readAllAndShowInTableView();
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
fx:id="buttonDelete"
|
fx:id="buttonDelete"
|
||||||
mnemonicParsing="false"
|
mnemonicParsing="false"
|
||||||
prefWidth="90.0"
|
prefWidth="90.0"
|
||||||
|
onAction="#handleDelete"
|
||||||
text="Löschen"
|
text="Löschen"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
|
|
Loading…
Reference in a new issue