#24: Javadoc & Cleanup
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
parent
02232cd27f
commit
db572dfa95
4 changed files with 46 additions and 1 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 {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,12 @@ import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The controller for viewing all deprecated {@link Medication}s.
|
||||||
|
*
|
||||||
|
* @author Armin Ribic
|
||||||
|
* @author Dorian Nemec
|
||||||
|
*/
|
||||||
public class DeprecatedMedicationController {
|
public class DeprecatedMedicationController {
|
||||||
@FXML
|
@FXML
|
||||||
private TableView<Medication> tableView;
|
private TableView<Medication> tableView;
|
||||||
|
@ -38,6 +44,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();
|
||||||
|
|
||||||
|
@ -79,8 +88,9 @@ public class DeprecatedMedicationController {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleChangeAvailable(){
|
public void handleChangeAvailable() {
|
||||||
Medication selectedItem = tableView.getSelectionModel().getSelectedItem();
|
Medication selectedItem = tableView.getSelectionModel().getSelectedItem();
|
||||||
if (selectedItem == null) {
|
if (selectedItem == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -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