-Zustandsverwaltung in FallController überarbeitet -Bug mit dem StationÜbersichts-asynchron-laden gefixttestBranch
| @@ -7,6 +7,7 @@ package de.uniluebeck.mi.projmi6.controller; | |||||
| import de.uniluebeck.mi.projmi6.db.DBHandler; | import de.uniluebeck.mi.projmi6.db.DBHandler; | ||||
| import de.uniluebeck.mi.projmi6.model.*; | import de.uniluebeck.mi.projmi6.model.*; | ||||
| import de.uniluebeck.mi.projmi6.view.DateTimePicker; | import de.uniluebeck.mi.projmi6.view.DateTimePicker; | ||||
| import javafx.beans.property.ReadOnlyObjectProperty; | |||||
| import javafx.beans.property.SimpleObjectProperty; | import javafx.beans.property.SimpleObjectProperty; | ||||
| import javafx.collections.FXCollections; | import javafx.collections.FXCollections; | ||||
| import javafx.event.ActionEvent; | import javafx.event.ActionEvent; | ||||
| @@ -93,6 +94,16 @@ public class FallController { | |||||
| CREATE, EDIT, VIEW | CREATE, EDIT, VIEW | ||||
| } | } | ||||
| public State getState() { | |||||
| return state.get(); | |||||
| } | |||||
| public ReadOnlyObjectProperty<State> stateProperty() { | |||||
| return state; | |||||
| } | |||||
| SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW); | SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW); | ||||
| @@ -123,6 +134,15 @@ public class FallController { | |||||
| copyFallDataIntoField(fallProperty.get()); | copyFallDataIntoField(fallProperty.get()); | ||||
| } | } | ||||
| })); | })); | ||||
| state.addListener((observable, oldValue, newValue) -> { | |||||
| if(newValue==State.EDIT || newValue == State.CREATE){ | |||||
| mainController.lockForEdit(MainController.TabName.OVERVIEW); | |||||
| }else{ | |||||
| mainController.unlockFromEdit(); | |||||
| } | |||||
| }); | |||||
| } | } | ||||
| @@ -147,7 +167,6 @@ public class FallController { | |||||
| void clickedFallAbort(ActionEvent event) { | void clickedFallAbort(ActionEvent event) { | ||||
| this.state.set(State.VIEW); | this.state.set(State.VIEW); | ||||
| copyFallDataIntoField(fallProperty.get()); | copyFallDataIntoField(fallProperty.get()); | ||||
| mainController.fallCreationComplete(); | |||||
| } | } | ||||
| @FXML | @FXML | ||||
| @@ -157,21 +176,20 @@ public class FallController { | |||||
| copyFieldDataIntoFall(fall); | copyFieldDataIntoFall(fall); | ||||
| try { | try { | ||||
| DBHandler.setFall(fall, mainController.getCurrentMitarbeiter().getMitarbID()); | DBHandler.setFall(fall, mainController.getCurrentMitarbeiter().getMitarbID()); | ||||
| //TODO Reload Faelle for Patient im MainController | |||||
| } catch (SQLException e) { | } catch (SQLException e) { | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| } | } | ||||
| } else { | } else { | ||||
| try { | try { | ||||
| DBHandler.setFall(fallProperty.get(), mainController.getCurrentMitarbeiter().getMitarbID(), true); | DBHandler.setFall(fallProperty.get(), mainController.getCurrentMitarbeiter().getMitarbID(), true); | ||||
| } catch (SQLException e) { | } catch (SQLException e) { | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| } | } | ||||
| } | } | ||||
| mainController.fallCreationComplete(); | |||||
| this.state.set(State.VIEW); | this.state.set(State.VIEW); | ||||
| //TODO Update/create in db | |||||
| mainController.refreshCasesFromDb(mainController.getPatientTablesController().getSelectedPatient()); | |||||
| } | } | ||||
| public void createNewFall() { | public void createNewFall() { | ||||
| @@ -188,10 +206,6 @@ public class FallController { | |||||
| } | } | ||||
| } | } | ||||
| fallVersichertennummer.setText(patient.getVersichertennummer()); | fallVersichertennummer.setText(patient.getVersichertennummer()); | ||||
| // TODO: Jojo: Kannst Du das wieder heile machen? :D | |||||
| // fallProperty.unbind(); | |||||
| // fallProperty.set(new Fall()); | |||||
| } | } | ||||
| @@ -208,10 +222,10 @@ public class FallController { | |||||
| fallPatID.setText(""); //TODO | fallPatID.setText(""); //TODO | ||||
| fallCreateTime.setText("<auto>"); | |||||
| fallCreator.setText("<auto>"); | |||||
| fallEditTime.setText("<auto>"); | |||||
| fallEditor.setText("<auto>"); | |||||
| fallCreateTime.setText(""); | |||||
| fallCreator.setText(""); | |||||
| fallEditTime.setText(""); | |||||
| fallEditor.setText(""); | |||||
| fallEinweisenderArzt.setText(""); | fallEinweisenderArzt.setText(""); | ||||
| fallSelbsteinweisung.setSelected(false); | fallSelbsteinweisung.setSelected(false); | ||||
| @@ -234,7 +248,7 @@ public class FallController { | |||||
| fall.setSelbsteinweisung(true); | fall.setSelbsteinweisung(true); | ||||
| fall.setEinweisenderArzt(null); | fall.setEinweisenderArzt(null); | ||||
| }else{ | }else{ | ||||
| // fall.setEinweisenderArzt(fallEinweisenderArzt.getText()); TODO | |||||
| //fall.setEinweisenderArzt(fallEinweisenderArzt.getText()); TODO | |||||
| fall.setSelbsteinweisung(false); | fall.setSelbsteinweisung(false); | ||||
| } | } | ||||
| fall.setVersichertenNummer(fallVersichertennummer.getText()); | fall.setVersichertenNummer(fallVersichertennummer.getText()); | ||||
| @@ -29,9 +29,6 @@ public class MainController { | |||||
| private UntersuchungenController untersuchungenController; | private UntersuchungenController untersuchungenController; | ||||
| private int parallelTaskCount = 0; | private int parallelTaskCount = 0; | ||||
| @FXML | @FXML | ||||
| @@ -53,35 +50,35 @@ public class MainController { | |||||
| private TabPane tabPaneFall; | private TabPane tabPaneFall; | ||||
| @FXML | @FXML | ||||
| private Tab tabFallOverview, tabFallUntersuchungen, tabFallDiagnose, tabFallStationsHistorie ; | |||||
| private Tab tabFallOverview, tabFallUntersuchungen, tabFallDiagnose, tabFallStationsHistorie; | |||||
| private Stammdaten stammdaten = new Stammdaten(); | private Stammdaten stammdaten = new Stammdaten(); | ||||
| private Callback<Class<?>, Object> controllerFactory = clazz -> { | private Callback<Class<?>, Object> controllerFactory = clazz -> { | ||||
| if(clazz.equals(MainController.class)) { | |||||
| if (clazz.equals(MainController.class)) { | |||||
| return this; | return this; | ||||
| }else if(clazz.equals(FallController.class)){ | |||||
| } else if (clazz.equals(FallController.class)) { | |||||
| return fallController; | return fallController; | ||||
| }else if(clazz.equals(DiagnoseController.class)){ | |||||
| } else if (clazz.equals(DiagnoseController.class)) { | |||||
| return diagnoseController; | return diagnoseController; | ||||
| }else if(clazz.equals(PatientTablesController.class)){ | |||||
| } else if (clazz.equals(PatientTablesController.class)) { | |||||
| return patientTablesController; | return patientTablesController; | ||||
| }else if(clazz.equals(SettingsController.class)){ | |||||
| return settingsController; | |||||
| } else if(clazz.equals(UntersuchungenController.class)) { | |||||
| } else if (clazz.equals(SettingsController.class)) { | |||||
| return settingsController; | |||||
| } else if (clazz.equals(UntersuchungenController.class)) { | |||||
| return untersuchungenController; | return untersuchungenController; | ||||
| }else if(clazz.equals(StationsHistorieController.class)){ | |||||
| } else if (clazz.equals(StationsHistorieController.class)) { | |||||
| return stationsHistorieController; | return stationsHistorieController; | ||||
| }else { | |||||
| System.err.println("Keine Controller-Klasse des Typs "+clazz+" gefunden!!!"); | |||||
| } else { | |||||
| System.err.println("Keine Controller-Klasse des Typs " + clazz + " gefunden!!!"); | |||||
| return null; | return null; | ||||
| } | } | ||||
| }; | }; | ||||
| public MainController(){ | |||||
| public MainController() { | |||||
| fallController = new FallController(this); | fallController = new FallController(this); | ||||
| diagnoseController = new DiagnoseController(this); | diagnoseController = new DiagnoseController(this); | ||||
| patientTablesController = new PatientTablesController(this); | patientTablesController = new PatientTablesController(this); | ||||
| @@ -91,47 +88,45 @@ public class MainController { | |||||
| } | } | ||||
| public Stammdaten getStammdaten(){ | |||||
| return stammdaten; | |||||
| public Stammdaten getStammdaten() { | |||||
| return stammdaten; | |||||
| } | } | ||||
| public Callback<Class<?>, Object> getControllerFactory(){ | |||||
| public Callback<Class<?>, Object> getControllerFactory() { | |||||
| return controllerFactory; | return controllerFactory; | ||||
| } | } | ||||
| public FallController getFallController(){ | |||||
| public FallController getFallController() { | |||||
| return fallController; | return fallController; | ||||
| } | } | ||||
| public DiagnoseController getDiagnoseController(){ | |||||
| public DiagnoseController getDiagnoseController() { | |||||
| return diagnoseController; | return diagnoseController; | ||||
| } | } | ||||
| public PatientTablesController getPatientTablesController(){ | |||||
| return patientTablesController; | |||||
| public PatientTablesController getPatientTablesController() { | |||||
| return patientTablesController; | |||||
| } | } | ||||
| public SettingsController getSettingsController(){ | |||||
| public SettingsController getSettingsController() { | |||||
| return settingsController; | return settingsController; | ||||
| } | } | ||||
| public UntersuchungenController getUntersuchungenController(){ | |||||
| return untersuchungenController; | |||||
| public UntersuchungenController getUntersuchungenController() { | |||||
| return untersuchungenController; | |||||
| } | } | ||||
| public void increaseParallelTaskCount(){ | |||||
| public void increaseParallelTaskCount() { | |||||
| parallelTaskCount++; | parallelTaskCount++; | ||||
| if(parallelTaskCount>0 && progressIndicator!=null){ | |||||
| if (parallelTaskCount > 0 && progressIndicator != null) { | |||||
| progressIndicator.setVisible(true); | progressIndicator.setVisible(true); | ||||
| } | } | ||||
| } | } | ||||
| public void decreaseParallelTaskCount(){ | |||||
| public void decreaseParallelTaskCount() { | |||||
| parallelTaskCount--; | parallelTaskCount--; | ||||
| if(parallelTaskCount<=0 && progressIndicator!=null){ | |||||
| if (parallelTaskCount <= 0 && progressIndicator != null) { | |||||
| parallelTaskCount = 0; | parallelTaskCount = 0; | ||||
| progressIndicator.setVisible(false); | progressIndicator.setVisible(false); | ||||
| } | } | ||||
| @@ -142,36 +137,32 @@ public class MainController { | |||||
| private Label lvFallPlaceholder; | private Label lvFallPlaceholder; | ||||
| private Task<List<Fall>> loadFallTask = null; | private Task<List<Fall>> loadFallTask = null; | ||||
| private ChangeListener<Patient> onPatientChanged = (observableValue,oldValue,newValue)-> { | |||||
| public void refreshCasesFromDb(Patient patient) { | |||||
| lvFall.setItems(null); //clear list | lvFall.setItems(null); //clear list | ||||
| if(newValue==null){ // If no patient is selected | |||||
| if (patient == null) { // If no patient is selected | |||||
| lvFallPlaceholder.setText("Kein Patient ausgew\u00e4hlt!"); | lvFallPlaceholder.setText("Kein Patient ausgew\u00e4hlt!"); | ||||
| return; | return; | ||||
| } | } | ||||
| if(loadFallTask!=null && loadFallTask.isRunning()){ | |||||
| if (loadFallTask != null && loadFallTask.isRunning()) { | |||||
| loadFallTask.cancel(); | loadFallTask.cancel(); | ||||
| } | } | ||||
| loadFallTask = new Task<List<Fall>>() { | loadFallTask = new Task<List<Fall>>() { | ||||
| @Override | @Override | ||||
| protected List<Fall> call() throws Exception { | protected List<Fall> call() throws Exception { | ||||
| return DBHandler.getFaelleByPatID(newValue.getPatID()); | |||||
| return DBHandler.getFaelleByPatID(patient.getPatID()); | |||||
| } | } | ||||
| @Override | @Override | ||||
| protected void succeeded() { | protected void succeeded() { | ||||
| super.succeeded(); | super.succeeded(); | ||||
| if(isCancelled()){ | |||||
| System.out.println("Task wurde gecancelt"); | |||||
| if (isCancelled()) { | |||||
| return; | return; | ||||
| } | } | ||||
| lvFallPlaceholder.setText("Keine F\u00e4lle vorhanden!"); | lvFallPlaceholder.setText("Keine F\u00e4lle vorhanden!"); | ||||
| @@ -199,20 +190,24 @@ public class MainController { | |||||
| Thread thread = new Thread(loadFallTask); | Thread thread = new Thread(loadFallTask); | ||||
| thread.setDaemon(true); | thread.setDaemon(true); | ||||
| thread.start(); | thread.start(); | ||||
| }; | |||||
| } | |||||
| @FXML | @FXML | ||||
| private void initialize(){ | |||||
| private void initialize() { | |||||
| //Init user data. | //Init user data. | ||||
| cmbUserChoose.itemsProperty().bind(this.getStammdaten().mitarbeiterProperty()); | cmbUserChoose.itemsProperty().bind(this.getStammdaten().mitarbeiterProperty()); | ||||
| cmbUserChoose.getSelectionModel().select(0); // TODO: Bessere Loesung finden. | cmbUserChoose.getSelectionModel().select(0); // TODO: Bessere Loesung finden. | ||||
| //Disable the right side if no case is selected. | //Disable the right side if no case is selected. | ||||
| fallOverview.disableProperty().bind(patientTablesController.selectedPatientProperty().isNull()); | |||||
| fallOverview.disableProperty().bind(patientTablesController.selectedPatientProperty().isNull() | |||||
| .and(fallController.stateProperty().isNotEqualTo(FallController.State.CREATE))); | |||||
| //Load the cases async if patient changes | //Load the cases async if patient changes | ||||
| patientTablesController.selectedPatientProperty().addListener(onPatientChanged); | |||||
| patientTablesController.selectedPatientProperty().addListener((observableValue, oldValue, newValue) -> { | |||||
| refreshCasesFromDb(newValue); | |||||
| }); | |||||
| lvFall.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); | lvFall.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); | ||||
| @@ -220,19 +215,16 @@ public class MainController { | |||||
| fallController.fallPropertyProperty().bind(lvFall.getSelectionModel().selectedItemProperty()); | fallController.fallPropertyProperty().bind(lvFall.getSelectionModel().selectedItemProperty()); | ||||
| lvFall.getSelectionModel().selectedItemProperty().addListener(onCaseChanged); | lvFall.getSelectionModel().selectedItemProperty().addListener(onCaseChanged); | ||||
| } | } | ||||
| private Task<Void> loadCaseData = null; | private Task<Void> loadCaseData = null; | ||||
| private ChangeListener<Fall> onCaseChanged = (observable, oldValue, newValue) -> { | private ChangeListener<Fall> onCaseChanged = (observable, oldValue, newValue) -> { | ||||
| if(loadCaseData!=null && loadCaseData.isRunning()){ | |||||
| if (loadCaseData != null && loadCaseData.isRunning()) { | |||||
| loadCaseData.cancel(); | loadCaseData.cancel(); | ||||
| } | } | ||||
| @@ -241,25 +233,24 @@ public class MainController { | |||||
| tabFallStationsHistorie.setDisable(true); | tabFallStationsHistorie.setDisable(true); | ||||
| tabFallUntersuchungen.setDisable(true); | tabFallUntersuchungen.setDisable(true); | ||||
| if(newValue==null) { | |||||
| if (newValue == null) { | |||||
| tabPaneFall.setDisable(true); | tabPaneFall.setDisable(true); | ||||
| System.out.println("TODO: Clear tables cuz fall = null!"); | System.out.println("TODO: Clear tables cuz fall = null!"); | ||||
| //fallController.c | //fallController.c | ||||
| return; | return; | ||||
| } | } | ||||
| if(newValue==null){ // If no patient is selected | |||||
| if (newValue == null) { // If no patient is selected | |||||
| //lvFallPlaceholder.setText("Kein Patient ausgew\u00e4hlt!"); | //lvFallPlaceholder.setText("Kein Patient ausgew\u00e4hlt!"); | ||||
| return; | return; | ||||
| } | } | ||||
| loadCaseData = new Task<Void>() { | loadCaseData = new Task<Void>() { | ||||
| List<Untersuchung> untersuchungList; | List<Untersuchung> untersuchungList; | ||||
| List<Diagnose> diagnoseList; | List<Diagnose> diagnoseList; | ||||
| List<StationsHistorie> stationsHistorieList; | List<StationsHistorie> stationsHistorieList; | ||||
| @Override | @Override | ||||
| protected Void call() throws Exception { | protected Void call() throws Exception { | ||||
| untersuchungList = DBHandler.getUntersuchungByFall(newValue); | untersuchungList = DBHandler.getUntersuchungByFall(newValue); | ||||
| @@ -271,7 +262,7 @@ public class MainController { | |||||
| @Override | @Override | ||||
| protected void succeeded() { | protected void succeeded() { | ||||
| super.succeeded(); | super.succeeded(); | ||||
| if(isCancelled()){ | |||||
| if (isCancelled()) { | |||||
| System.out.println("Task wurde gecancelt"); | System.out.println("Task wurde gecancelt"); | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -310,29 +301,67 @@ public class MainController { | |||||
| @FXML | @FXML | ||||
| private void clickedCreateFall(){ | |||||
| private void clickedCreateFall() { | |||||
| // tabFallDiagnose.setDisable(true); | |||||
| // tabFallUntersuchungen.setDisable(true); | |||||
| // tabFallStationsHistorie.setDisable(true); | |||||
| // tabPaneFall.getSelectionModel().select(tabFallOverview); | |||||
| // patientTablesController.getPatientOverviewTabPane().setDisable(true); | |||||
| // | |||||
| // | |||||
| fallController.createNewFall(); | |||||
| lockForEdit(TabName.OVERVIEW); | |||||
| } | |||||
| public enum TabName { | |||||
| OVERVIEW, DIAGNOSE, UNTERSUCHUNG, STATIONSHISTORIE; | |||||
| } | |||||
| public void lockForEdit(TabName exclude) { | |||||
| tabFallDiagnose.setDisable(true); | tabFallDiagnose.setDisable(true); | ||||
| tabFallUntersuchungen.setDisable(true); | tabFallUntersuchungen.setDisable(true); | ||||
| tabFallStationsHistorie.setDisable(true); | tabFallStationsHistorie.setDisable(true); | ||||
| tabPaneFall.getSelectionModel().select(tabFallOverview); | |||||
| tabFallOverview.setDisable(true); | |||||
| lvFall.setDisable(true); | |||||
| btnFallCreate.setDisable(true); | |||||
| patientTablesController.getPatientOverviewTabPane().setDisable(true); | patientTablesController.getPatientOverviewTabPane().setDisable(true); | ||||
| switch (exclude) { | |||||
| case OVERVIEW: | |||||
| tabFallOverview.setDisable(false); | |||||
| break; | |||||
| case DIAGNOSE: | |||||
| tabFallDiagnose.setDisable(false); | |||||
| break; | |||||
| case UNTERSUCHUNG: | |||||
| tabFallUntersuchungen.setDisable(false); | |||||
| break; | |||||
| case STATIONSHISTORIE: | |||||
| tabFallStationsHistorie.setDisable(false); | |||||
| default: | |||||
| break; | |||||
| } | |||||
| fallController.createNewFall(); | |||||
| } | } | ||||
| public void fallCreationComplete(){ | |||||
| public void unlockFromEdit() { | |||||
| tabFallDiagnose.setDisable(false); | tabFallDiagnose.setDisable(false); | ||||
| tabFallUntersuchungen.setDisable(false); | tabFallUntersuchungen.setDisable(false); | ||||
| tabFallStationsHistorie.setDisable(false); | tabFallStationsHistorie.setDisable(false); | ||||
| patientTablesController.getPatientOverviewTabPane().setDisable(false); | patientTablesController.getPatientOverviewTabPane().setDisable(false); | ||||
| lvFall.setDisable(false); | |||||
| btnFallCreate.setDisable(false); | |||||
| } | } | ||||
| public Mitarbeiter getCurrentMitarbeiter(){ | |||||
| public Mitarbeiter getCurrentMitarbeiter() { | |||||
| return cmbUserChoose.getValue(); | return cmbUserChoose.getValue(); | ||||
| } | } | ||||
| public ReadOnlyObjectProperty<Mitarbeiter> currentMitarbeiterProperty(){ | |||||
| public ReadOnlyObjectProperty<Mitarbeiter> currentMitarbeiterProperty() { | |||||
| return cmbUserChoose.valueProperty(); | return cmbUserChoose.valueProperty(); | ||||
| } | } | ||||
| @@ -146,15 +146,21 @@ public class PatientTablesController { | |||||
| return tableRow; | return tableRow; | ||||
| }); | }); | ||||
| lblTablePatientEmpty.setText("Liste ist leer."); | lblTablePatientEmpty.setText("Liste ist leer."); | ||||
| lblTableStationEmpty.setText(""); | |||||
| tblStationOverview.disableProperty().bind(cmbStationenFilter.valueProperty().isNull()); | |||||
| cmbStationenFilter.itemsProperty().bind(mainController.getStammdaten().stationenProperty()); | cmbStationenFilter.itemsProperty().bind(mainController.getStammdaten().stationenProperty()); | ||||
| patientObjectBinding = Bindings.<Patient>createObjectBinding(() -> { | patientObjectBinding = Bindings.<Patient>createObjectBinding(() -> { | ||||
| return patientOverviewTabPane.getSelectionModel().getSelectedItem().equals(patientOverviewTab) | |||||
| ? tblPatientOverview.getSelectionModel().getSelectedItem() | |||||
| : null; //(Patient)tblStationOverview.getSelectionModel().getSelectedItem(); //TODO | |||||
| if(patientOverviewTabPane.getSelectionModel().getSelectedItem().equals(patientOverviewTab)) { | |||||
| return tblPatientOverview.getSelectionModel().getSelectedItem(); | |||||
| }else if(tblStationOverview.getSelectionModel().getSelectedItem()==null){ | |||||
| return null; | |||||
| }else{ | |||||
| int selectedPatId = tblStationOverview.getSelectionModel().getSelectedItem().getPatId(); | |||||
| Patient selectedPatient = tblPatientOverview.getItems().stream().filter(p -> p.getPatID()==selectedPatId).findFirst().orElse(null); | |||||
| return selectedPatient; | |||||
| } | |||||
| }, tblPatientOverview.getSelectionModel().selectedItemProperty(), | }, tblPatientOverview.getSelectionModel().selectedItemProperty(), | ||||
| tblStationOverview.getSelectionModel().selectedItemProperty(), | tblStationOverview.getSelectionModel().selectedItemProperty(), | ||||
| patientOverviewTabPane.getSelectionModel().selectedItemProperty()); | patientOverviewTabPane.getSelectionModel().selectedItemProperty()); | ||||
| @@ -309,10 +315,10 @@ public class PatientTablesController { | |||||
| private Task loadStationsHistorieTask = null; | private Task loadStationsHistorieTask = null; | ||||
| public void updateStationsHistorieFromDb() { | public void updateStationsHistorieFromDb() { | ||||
| if (this.loadStationsHistorieTask != null && this.loadStationsHistorieTask.isRunning()) { | |||||
| if (this.loadStationsHistorieTask !=null) { | |||||
| loadStationsHistorieTask.cancel(); | loadStationsHistorieTask.cancel(); | ||||
| return; | |||||
| } | } | ||||
| lblTableStationEmpty.setText("Liste wird geladen..."); | |||||
| btnStatRefresh.setDisable(true); | btnStatRefresh.setDisable(true); | ||||
| @@ -320,7 +326,6 @@ public class PatientTablesController { | |||||
| mainController.increaseParallelTaskCount(); | mainController.increaseParallelTaskCount(); | ||||
| lblTableStationEmpty.setText("Liste wird geladen..."); | |||||
| Task<List<StationsUebersichtsItem>> loadStatHist = new Task<List<StationsUebersichtsItem>>() { | Task<List<StationsUebersichtsItem>> loadStatHist = new Task<List<StationsUebersichtsItem>>() { | ||||
| @@ -344,20 +349,18 @@ public class PatientTablesController { | |||||
| @Override | @Override | ||||
| protected void cancelled() { | protected void cancelled() { | ||||
| super.cancelled(); | super.cancelled(); | ||||
| btnStatRefresh.setDisable(false); | |||||
| mainController.decreaseParallelTaskCount(); | mainController.decreaseParallelTaskCount(); | ||||
| System.out.println("Cancelled"); | |||||
| } | } | ||||
| @Override | @Override | ||||
| protected void failed() { | protected void failed() { | ||||
| super.failed(); | super.failed(); | ||||
| if(!isCancelled()){ | if(!isCancelled()){ | ||||
| lblTablePatientEmpty.setText("Laden fehlgeschlagen!"); | |||||
| lblTableStationEmpty.setText("Laden fehlgeschlagen!"); | |||||
| getException().printStackTrace(); | getException().printStackTrace(); | ||||
| btnStatRefresh.setDisable(false); | |||||
| mainController.decreaseParallelTaskCount(); | |||||
| } | } | ||||
| mainController.decreaseParallelTaskCount(); | |||||
| btnStatRefresh.setDisable(false); | |||||
| } | } | ||||
| }; | }; | ||||
| this.loadStationsHistorieTask = loadStatHist; | this.loadStationsHistorieTask = loadStatHist; | ||||
| @@ -389,4 +392,6 @@ public class PatientTablesController { | |||||
| return selectedPatientProperty().get(); | return selectedPatientProperty().get(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -71,30 +71,41 @@ public class StationsHistorieController { | |||||
| private void initialize() { | private void initialize() { | ||||
| initColumns(); | initColumns(); | ||||
| initStationsFilter(); | |||||
| tblStationsHistorie.itemsProperty().bind(stationsHistorie); | |||||
| tblStationsHistorie.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { | |||||
| setStationsHistorieSelected(newValue); | |||||
| }); | |||||
| } | |||||
| private void initStationsFilter(){ | |||||
| final String any = "beliebig"; | |||||
| List<String> abteilungen = mainController.getStammdaten().getStationen().stream() | List<String> abteilungen = mainController.getStammdaten().getStationen().stream() | ||||
| .map(stat->stat.getAbteilung()).distinct().collect(Collectors.toList()); | |||||
| .map(stat->stat.getAbteilung()).distinct().collect(Collectors.toList()); | |||||
| cmbAbteilung.setItems(FXCollections.observableArrayList(abteilungen)); | cmbAbteilung.setItems(FXCollections.observableArrayList(abteilungen)); | ||||
| cmbAbteilung.getItems().add(0, any); | |||||
| cmbAbteilung.getSelectionModel().select(0); | |||||
| FilteredList<Station> stationenFiltered = new FilteredList<Station>(mainController.getStammdaten().getStationen()); | FilteredList<Station> stationenFiltered = new FilteredList<Station>(mainController.getStammdaten().getStationen()); | ||||
| stationenFiltered.predicateProperty().bind(Bindings.createObjectBinding(() -> { | stationenFiltered.predicateProperty().bind(Bindings.createObjectBinding(() -> { | ||||
| if(cmbAbteilung.getValue()==null || cmbAbteilung.getValue().equals(any)){ | |||||
| return p->true; | |||||
| } | |||||
| return p -> p.getAbteilung().equals(cmbAbteilung.getValue()); | return p -> p.getAbteilung().equals(cmbAbteilung.getValue()); | ||||
| },cmbAbteilung.valueProperty())); | },cmbAbteilung.valueProperty())); | ||||
| cmbStation.setItems(mainController.getStammdaten().getStationen()); | |||||
| tblStationsHistorie.itemsProperty().bind(stationsHistorie); | |||||
| tblStationsHistorie.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { | |||||
| setStationsHistorieSelected(newValue); | |||||
| }); | |||||
| cmbStation.setItems(stationenFiltered); | |||||
| } | } | ||||
| @FXML | @FXML | ||||
| private void clickedCancel(){ | private void clickedCancel(){ | ||||
| @@ -58,8 +58,7 @@ | |||||
| <children> | <children> | ||||
| <ToolBar prefHeight="40.0" prefWidth="200.0"> | <ToolBar prefHeight="40.0" prefWidth="200.0"> | ||||
| <items> | <items> | ||||
| <Label text="Station:" /> | |||||
| <ComboBox fx:id="cmbStationenFilter" prefWidth="150.0" promptText="Stationen" /> | |||||
| <ComboBox fx:id="cmbStationenFilter" prefWidth="250.0" promptText="Station auswählen..." /> | |||||
| <ToggleButton fx:id="btnEntlassenePatientenZeigen" mnemonicParsing="false" text="Entlassene Patienten zeigen" /> | <ToggleButton fx:id="btnEntlassenePatientenZeigen" mnemonicParsing="false" text="Entlassene Patienten zeigen" /> | ||||
| <Pane HBox.hgrow="ALWAYS" /> | <Pane HBox.hgrow="ALWAYS" /> | ||||
| <Button fx:id="btnStatRefresh" text="Liste aktualisieren" onAction="#clickedRefreshStation"/> | <Button fx:id="btnStatRefresh" text="Liste aktualisieren" onAction="#clickedRefreshStation"/> | ||||
| @@ -19,12 +19,15 @@ | |||||
| <Button mnemonicParsing="false" text="Neuen Aufenthalt erstellen" onAction="#clickedCreateAufenthalt"/> | <Button mnemonicParsing="false" text="Neuen Aufenthalt erstellen" onAction="#clickedCreateAufenthalt"/> | ||||
| </items> | </items> | ||||
| </ToolBar> | </ToolBar> | ||||
| <TableView prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" fx:id="tblStationsHistorie"> | |||||
| <TableView prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" fx:id="tblStationsHistorie" > | |||||
| <columns> | <columns> | ||||
| <TableColumn prefWidth="75.0" text="Station" fx:id="colStatHistStation"/> | <TableColumn prefWidth="75.0" text="Station" fx:id="colStatHistStation"/> | ||||
| <TableColumn prefWidth="75.0" text="Aufnahme" fx:id="colStatHistAufnahmeDatum"/> | <TableColumn prefWidth="75.0" text="Aufnahme" fx:id="colStatHistAufnahmeDatum"/> | ||||
| <TableColumn prefWidth="75.0" text="Entlassung" fx:id="colStatHistEntlassungsDatum"/> | <TableColumn prefWidth="75.0" text="Entlassung" fx:id="colStatHistEntlassungsDatum"/> | ||||
| </columns> | </columns> | ||||
| <columnResizePolicy> | |||||
| <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> | |||||
| </columnResizePolicy> | |||||
| </TableView> | </TableView> | ||||
| </children> | </children> | ||||
| </VBox> | </VBox> | ||||
| @@ -43,7 +46,7 @@ | |||||
| </rowConstraints> | </rowConstraints> | ||||
| <children> | <children> | ||||
| <Label text="Abteilung:"/> | <Label text="Abteilung:"/> | ||||
| <ComboBox disable="true" prefWidth="150.0" GridPane.columnIndex="1" fx:id="cmbAbteilung"/> | |||||
| <ComboBox prefWidth="150.0" GridPane.columnIndex="1" fx:id="cmbAbteilung"/> | |||||
| <Label text="Station:" GridPane.rowIndex="1"/> | <Label text="Station:" GridPane.rowIndex="1"/> | ||||
| <ComboBox prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="1" fx:id="cmbStation"/> | <ComboBox prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="1" fx:id="cmbStation"/> | ||||