From 2e3baff124a7b06896063143a0a2027d1952d182 Mon Sep 17 00:00:00 2001 From: Dorian Nemec Date: Tue, 21 May 2024 08:39:58 +0200 Subject: [PATCH] #24: Javadoc & Cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dominik Säume --- db/nursingHome.db | Bin 57344 -> 57344 bytes .../medication/AllMedicationController.java | 34 ++++++++++++++++++ .../DeprecatedMedicationController.java | 3 ++ .../nhplus/medication/AllMedicationView.fxml | 1 + 4 files changed, 38 insertions(+) diff --git a/db/nursingHome.db b/db/nursingHome.db index b89b1465940bb9f8aa1e08321a549d20da8681fd..9ce117804f6ced85b396bc7bf6373df784aa6d56 100644 GIT binary patch delta 1356 zcmY*XeM}Tb6yMp|-P_%}+X3M?==IsG#XpC`BMq1dF8#T43c?yuuy2cc&IL zaA2u_)QV2pl$Q8aq^Y77uQsL{A+=V~v|{|IrfQ9qk7x`UsuiiGv(2gL%)Y#R^Lz8& zZ{B~ofY>aGJ5bUMRG|0z;%=fUtUMN{w)8;hH`xadF{uQQuWprODgFRNDkUPaYJz^Ay~K)_YHaR!kPNuU*ZU-M02RHE9z?>}F$Z~n-C@WQ^LiQ<6&9>odXe`_q$>Lr* z7O=q~`XPXUY6f>1qX2`G&?UT2DvWKQpw4WufW}4t(O4<_T#CmRQZ$Ba-?pidLAz}X z!s9Y-NG$52&@dWAS5Xh@3WnD^QJqmQ1SUW;@c31)!k}NMi53tFz!A$52Yjj``;38! zF!bvtDMUsC^(LUbnjsb=@+=IQ5(DkPtvFreIj$NHsp9{x3iOL~dSHPs(-}#z7=$U* zPw4GMm=J747#FOJqrxMJ?8ak!SA?DHqP0cdVJoc7l zi1PtY#U&^jdbBJ%O^XH4C`CSP_B7GhKGzzoCt?U`foNWm39CdYxWuy)hztY*W0cyd z2+WqpqZX-AS}n=XH*rjo>LTJGNa7aB>T+3ic|5XDb@|=;SO_fKLf?rtwMvP!LNJM& zFIRdLFTuP%MOI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`L)#-v@1EpNLoH)bp{ z9e-dtxli_NPGwSB$?<{a_Ry}$-JkyhRvLRtMf?Exa%E<_#hiJe=)#sS&X+8|Zoywp zK8iaXWfx_GwSPtXF791AJobL_aF-MKX8*Rbulw%lwg(;cDtudOT+?%<-(Q>;;;-&9 zovY66Sl;yeiRv?t)MNf5o8ApK?a13(*Rr~L{*fJ+hp?ak@#U*k6_^@n%bc8>4O+B%5(sm!>~hed%PaMJrS z3$OEI69!Irlnp(Q`}QC)hxg`8wOq_EmELxU5CjvW1a`6o3kF`9`yS<`G1! columnCurrentStock; @FXML public Button buttonChangeAvailable; + @FXML + public Button buttonAdd; + @FXML + public Button buttonDelete; private final ObservableList medications = FXCollections.observableArrayList(); private MedicationDao dao; + private boolean hasEditPermissions; /** * Initialization method that is called after the binding of all the fields. */ @FXML public void initialize() { + int editPermissions = Permissions.MANAGEMENT | Permissions.OWNER; + int userPermissions = MainWindowController.getInstance().getUser().getPermissions(); + hasEditPermissions = (userPermissions & editPermissions) != 0; this.readAllAndShowInTableView(); this.columnId.setCellValueFactory(new PropertyValueFactory<>("id")); @@ -86,6 +97,12 @@ public class AllMedicationController { 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(); } + + @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}. * @@ -184,4 +217,5 @@ public class AllMedicationController { } }); } + } diff --git a/src/main/java/de/hitec/nhplus/medication/DeprecatedMedicationController.java b/src/main/java/de/hitec/nhplus/medication/DeprecatedMedicationController.java index 8d36f59..7f0bb51 100644 --- a/src/main/java/de/hitec/nhplus/medication/DeprecatedMedicationController.java +++ b/src/main/java/de/hitec/nhplus/medication/DeprecatedMedicationController.java @@ -38,6 +38,9 @@ public class DeprecatedMedicationController { private final ObservableList medications = FXCollections.observableArrayList(); private MedicationDao dao; + /** + * Initialization method that is called after the binding of all the fields. + */ public void initialize() { this.readAllAndShowInTableView(); diff --git a/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml b/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml index d9456b9..63407cc 100644 --- a/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml +++ b/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml @@ -73,6 +73,7 @@ fx:id="buttonDelete" mnemonicParsing="false" prefWidth="90.0" + onAction="#handleDelete" text="Löschen" />