diff --git a/src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java b/src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java index 838e61a..02f501a 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java @@ -5,6 +5,7 @@ package de.uniluebeck.mi.projmi6.controller; */ import ca.uhn.hl7v2.model.v251.segment.LOC; +import com.sun.deploy.config.Platform; import com.sun.org.apache.bcel.internal.generic.LoadClass; import de.uniluebeck.mi.projmi6.db.DBHandler; import de.uniluebeck.mi.projmi6.model.Patient; 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 b474276..d9662ba 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java @@ -5,13 +5,16 @@ import de.uniluebeck.mi.projmi6.model.Station; import de.uniluebeck.mi.projmi6.model.StationsHistorie; import de.uniluebeck.mi.projmi6.view.DateTimePicker; import javafx.beans.binding.Bindings; +import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.collections.transformation.FilteredList; +import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.layout.GridPane; import java.time.LocalDate; import java.util.List; @@ -57,6 +60,28 @@ public class StationsHistorieController { this.mainController = mainController; } + @FXML + private void clickedEdit() { + this.state.set(State.EDIT); + } + + + public enum State { + CREATE, EDIT, VIEW + } + + public State getState() { + return state.get(); + } + + public ReadOnlyObjectProperty stateProperty() { + return state; + } + + + + SimpleObjectProperty state = new SimpleObjectProperty<>(State.VIEW); + public void setStationsHistorie(ObservableList stationsHistorie) { this.stationsHistorie.set(stationsHistorie); @@ -66,6 +91,8 @@ public class StationsHistorieController { new SimpleObjectProperty<>(); + @FXML + GridPane fields; @FXML private void initialize() { @@ -74,6 +101,12 @@ public class StationsHistorieController { initStationsFilter(); + fields.disableProperty().bind(stateProperty().isEqualTo(State.VIEW)); + + state.addListener((observable, oldValue, newValue) -> { + + }); + tblStationsHistorie.itemsProperty().bind(stationsHistorie); tblStationsHistorie.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { @@ -81,6 +114,9 @@ public class StationsHistorieController { }); } + @FXML + public Button btnStatHistAbort; + private void initStationsFilter(){ final String any = "beliebig"; @@ -91,6 +127,14 @@ public class StationsHistorieController { cmbAbteilung.getItems().add(0, any); cmbAbteilung.getSelectionModel().select(0); + btnStatHistCancel.visibleProperty().bind(state.isEqualTo(State.VIEW).and(tblStationsHistorie.getSelectionModel().selectedItemProperty().isNotNull())); + btnStatHistSave.visibleProperty().bind(state.isEqualTo(State.VIEW).not()); + btnStatHistAbort.visibleProperty().bind(state.isEqualTo(State.VIEW).not()); + btnStatHistEdit.visibleProperty().bind(state.isEqualTo(State.VIEW)); + + tblStationsHistorie.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { + setStationsHistorieSelected(newValue); + }); FilteredList stationenFiltered = new FilteredList(mainController.getStammdaten().getStationen()); @@ -101,24 +145,36 @@ public class StationsHistorieController { return p -> p.getAbteilung().equals(cmbAbteilung.getValue()); },cmbAbteilung.valueProperty())); + + cmbStation.setItems(stationenFiltered); } + @FXML + Button btnStatHistEdit; + @FXML private void clickedCancel(){ - + // this.state.set(State.VIEW); } @FXML private void clickedSave(){ + //TODO + } + @FXML + private void clickedAbort(){ + state.set(State.VIEW); + copyStationsHistorieDataIntoFields(); } @FXML private void clickedCreateAufenthalt(){ - + this.state.set(State.CREATE); + setStationsHistorieSelected(null); } public ObservableList getStationsHistorie() { @@ -129,13 +185,10 @@ public class StationsHistorieController { return stationsHistorie; } - public void setStationsHistorieSelected(ObservableList stationsHistorie) { - this.stationsHistorie.set(stationsHistorie); - } public void setStationsHistorieSelected(StationsHistorie stationsHistorie){ - + this.stationsHistorieSelected=stationsHistorie; if(stationsHistorie==null){ clearFields(); }else { @@ -156,6 +209,7 @@ public class StationsHistorieController { private void copyStationsHistorieDataIntoFields(){ if(stationsHistorieSelected==null){ + clearFields(); return; } @@ -165,14 +219,16 @@ public class StationsHistorieController { dtTmEntlassung.setDateTime(stationsHistorieSelected.getEntlassungsDatum()); statHistCreator.setText(Integer.toString(stationsHistorieSelected.getErsteller())); - statHistCreateTime.setText(stationsHistorieSelected.getErstellDatumZeit().toString()); + if(stationsHistorieSelected.getErstellDatumZeit()!=null){ + statHistCreateTime.setText(stationsHistorieSelected.getErstellDatumZeit().toString()); + } statHistEditor.setText(Integer.toString(stationsHistorieSelected.getBearbeiter())); - statHistEditTime.setText(stationsHistorieSelected.getBearbeitetDatumZeit().toString()); + if(stationsHistorieSelected.getBearbeitetDatumZeit()!=null){ + statHistEditTime.setText(stationsHistorieSelected.getBearbeitetDatumZeit().toString()); + } } private void copyFieldDataIntoStationsHistorie(StationsHistorie stationsHistorie){ - - //stationsHistorie.s(colStatHistAbteilun); stationsHistorie.setAufnahmeDatum(dtTmAufnahme.getDateTime()); stationsHistorie.setEntlassungsDatum(dtTmEntlassung.getDateTime()); stationsHistorie.setStation(cmbStation.getValue()); diff --git a/src/main/resources/stationshistorie.fxml b/src/main/resources/stationshistorie.fxml index c91460d..8760903 100644 --- a/src/main/resources/stationshistorie.fxml +++ b/src/main/resources/stationshistorie.fxml @@ -33,7 +33,7 @@ - + @@ -60,6 +60,8 @@ +