diff --git a/src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java b/src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java index 12b7b03..8f78f14 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java @@ -113,17 +113,17 @@ public class FallController { fallFallart.setItems(FXCollections.observableArrayList(FallArt.values())); fallKasse.setItems(mainController.getStammdaten().getKassen()); - btnFallEnableEdit.visibleProperty().bind( + btnFallEnableEdit.managedProperty().bind( state.isEqualTo(State.VIEW).and(fallProperty.isNotNull()) ); - btnFallAbort.visibleProperty().bind( + btnFallAbort.managedProperty().bind( state.isNotEqualTo(State.VIEW) ); - btnFallSave.visibleProperty().bind( + btnFallSave.managedProperty().bind( state.isNotEqualTo(State.VIEW) ); - btnFallCancel.visibleProperty().bind( + btnFallCancel.managedProperty().bind( state.isEqualTo(State.VIEW).and(fallProperty.isNotNull()) ); @@ -159,8 +159,7 @@ public class FallController { @FXML void clickedFallCancel(ActionEvent event) { - this.state.set(State.VIEW); - copyFallDataIntoField(fallProperty.get()); + //Fall Stornieren... } @FXML diff --git a/src/main/java/de/uniluebeck/mi/projmi6/controller/MainController.java b/src/main/java/de/uniluebeck/mi/projmi6/controller/MainController.java index 5187607..bc0d277 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/MainController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/MainController.java @@ -215,15 +215,18 @@ public class MainController { fallController.fallPropertyProperty().bind(lvFall.getSelectionModel().selectedItemProperty()); - lvFall.getSelectionModel().selectedItemProperty().addListener(onCaseChanged); + lvFall.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) ->{ + refreshCaseData(newValue); + }); } private Task loadCaseData = null; - private ChangeListener onCaseChanged = (observable, oldValue, newValue) -> { + + private void refreshCaseData(Fall fall){ if (loadCaseData != null && loadCaseData.isRunning()) { loadCaseData.cancel(); } @@ -233,14 +236,14 @@ public class MainController { tabFallStationsHistorie.setDisable(true); tabFallUntersuchungen.setDisable(true); - if (newValue == null) { + if (fall == null) { tabPaneFall.setDisable(true); System.out.println("TODO: Clear tables cuz fall = null!"); //fallController.c return; } - if (newValue == null) { // If no patient is selected + if (fall == null) { // If no patient is selected //lvFallPlaceholder.setText("Kein Patient ausgew\u00e4hlt!"); return; } @@ -253,9 +256,9 @@ public class MainController { @Override protected Void call() throws Exception { - untersuchungList = DBHandler.getUntersuchungByFall(newValue); - diagnoseList = DBHandler.getDiagnosenByFall(newValue); - stationsHistorieList = DBHandler.getStationsHistorieByFall(newValue); + untersuchungList = DBHandler.getUntersuchungByFall(fall); + diagnoseList = DBHandler.getDiagnosenByFall(fall); + stationsHistorieList = DBHandler.getStationsHistorieByFall(fall); return null; } @@ -297,9 +300,13 @@ public class MainController { thread.setDaemon(true); thread.start(); increaseParallelTaskCount(); - }; + } + public void refreshCaseData(){ + refreshCaseData(lvFall.getSelectionModel().getSelectedItem()); + } + @FXML private void clickedCreateFall() { // tabFallDiagnose.setDisable(true); @@ -351,6 +358,8 @@ public enum TabName { tabFallDiagnose.setDisable(false); tabFallUntersuchungen.setDisable(false); tabFallStationsHistorie.setDisable(false); + + tabFallOverview.setDisable(false); patientTablesController.getPatientOverviewTabPane().setDisable(false); lvFall.setDisable(false); btnFallCreate.setDisable(false); diff --git a/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java b/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java index d9662ba..8feb0b6 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java @@ -16,6 +16,7 @@ import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.GridPane; +import java.sql.SQLException; import java.time.LocalDate; import java.util.List; import java.util.stream.Collectors; @@ -104,7 +105,11 @@ public class StationsHistorieController { fields.disableProperty().bind(stateProperty().isEqualTo(State.VIEW)); state.addListener((observable, oldValue, newValue) -> { - + if(newValue == State.CREATE || newValue == State.EDIT){ + mainController.lockForEdit(MainController.TabName.STATIONSHISTORIE); + }else{ + mainController.unlockFromEdit(); + } }); @@ -162,7 +167,16 @@ public class StationsHistorieController { @FXML private void clickedSave(){ - //TODO + if(getState()==State.CREATE){ + StationsHistorie stationsHistorie = new StationsHistorie(); + copyFieldDataIntoStationsHistorie(stationsHistorie); + try { + DBHandler.setStationsHistorie(stationsHistorie,false); + } catch (SQLException e) { + e.printStackTrace(); + } + mainController.refreshCaseData(); + } } @FXML diff --git a/src/main/resources/fall.fxml b/src/main/resources/fall.fxml index 957660e..a76114f 100644 --- a/src/main/resources/fall.fxml +++ b/src/main/resources/fall.fxml @@ -14,30 +14,16 @@