|
|
|
@@ -4,7 +4,9 @@ package de.uniluebeck.mi.projmi6.controller; |
|
|
|
* Created by 631806 on 12.11.15. |
|
|
|
*/ |
|
|
|
|
|
|
|
import de.uniluebeck.mi.projmi6.db.DBHandler; |
|
|
|
import de.uniluebeck.mi.projmi6.model.*; |
|
|
|
import javafx.beans.property.ReadOnlyObjectProperty; |
|
|
|
import javafx.beans.property.SimpleObjectProperty; |
|
|
|
import javafx.collections.FXCollections; |
|
|
|
import javafx.collections.ObservableList; |
|
|
|
@@ -12,6 +14,7 @@ import javafx.event.ActionEvent; |
|
|
|
import javafx.fxml.FXML; |
|
|
|
import javafx.scene.control.*; |
|
|
|
import javafx.event.ActionEvent; |
|
|
|
import javafx.scene.layout.GridPane; |
|
|
|
|
|
|
|
public class DiagnoseController { |
|
|
|
|
|
|
|
@@ -38,6 +41,21 @@ public class DiagnoseController { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public enum State { |
|
|
|
CREATE, EDIT, VIEW |
|
|
|
} |
|
|
|
|
|
|
|
SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW); |
|
|
|
|
|
|
|
public State getState() { |
|
|
|
return state.get(); |
|
|
|
} |
|
|
|
|
|
|
|
public ReadOnlyObjectProperty<State> stateProperty() { |
|
|
|
return state; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
private ListView<Diagnose> diagnoseList; |
|
|
|
|
|
|
|
@@ -48,14 +66,63 @@ public class DiagnoseController { |
|
|
|
diagDiagnoseArzt.itemsProperty().bind(mainController.getStammdaten().mitarbeiterProperty()); |
|
|
|
diagnoseList.itemsProperty().bind(diagnosen); |
|
|
|
|
|
|
|
initButtons(); |
|
|
|
|
|
|
|
fields.disableProperty().bind(state.isEqualTo(State.VIEW)); |
|
|
|
|
|
|
|
diagnoseList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); |
|
|
|
diagnoseList.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { |
|
|
|
this.setDiagnose(newValue); |
|
|
|
if(newValue==null){ |
|
|
|
clearFields(); |
|
|
|
}else{ |
|
|
|
copyDiagnoseDataIntoFields(newValue); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initButtons(){ |
|
|
|
btnDiagCreate.disableProperty().bind(mainController.fallProperty().isNull()); |
|
|
|
|
|
|
|
btnDiagEdit.disableProperty().bind(diagnoseList.getSelectionModel().selectedItemProperty().isNull()); |
|
|
|
|
|
|
|
btnDiagEdit.managedProperty().bind(state.isEqualTo(State.VIEW)); |
|
|
|
btnDiagEdit.visibleProperty().bind(btnDiagEdit.managedProperty()); |
|
|
|
|
|
|
|
|
|
|
|
btnDiagSave.managedProperty().bind(state.isNotEqualTo(State.VIEW)); |
|
|
|
btnDiagSave.visibleProperty().bind(btnDiagSave.managedProperty()); |
|
|
|
|
|
|
|
btnDiagAbort.managedProperty().bind(btnDiagSave.managedProperty()); |
|
|
|
btnDiagAbort.visibleProperty().bind(btnDiagSave.managedProperty()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@FXML |
|
|
|
Button btnDiagAbort, btnDiagEdit; |
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
private void clickedEdit(){ |
|
|
|
state.set(State.EDIT); |
|
|
|
} |
|
|
|
|
|
|
|
@FXML |
|
|
|
private void clickedAbort(){ |
|
|
|
state.set(State.VIEW); |
|
|
|
Diagnose diagnose = diagnoseList.getSelectionModel().getSelectedItem(); |
|
|
|
if(diagnose==null){ |
|
|
|
clearFields(); |
|
|
|
}else{ |
|
|
|
copyDiagnoseDataIntoFields(diagnose); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@FXML |
|
|
|
private GridPane fields; |
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
private ComboBox<Mitarbeiter> diagDiagnoseArzt; |
|
|
|
@@ -92,7 +159,7 @@ public class DiagnoseController { |
|
|
|
|
|
|
|
@FXML |
|
|
|
void clickedDiagCreate(ActionEvent event) { |
|
|
|
|
|
|
|
this.state.set(State.CREATE); |
|
|
|
} |
|
|
|
|
|
|
|
@FXML |
|
|
|
@@ -102,24 +169,16 @@ public class DiagnoseController { |
|
|
|
|
|
|
|
@FXML |
|
|
|
void clickedDiagSave(ActionEvent event) { |
|
|
|
if(state.get() == State.CREATE){ |
|
|
|
//Create new diagnosis |
|
|
|
//DBHandler.set |
|
|
|
}else{ |
|
|
|
//Update diagnosis in db |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* The diagnose that is shown in the edit window, or null if a new diagnose should be created. |
|
|
|
*/ |
|
|
|
|
|
|
|
private Diagnose diagnose = null; |
|
|
|
|
|
|
|
public void setDiagnose(Diagnose diagnose){ |
|
|
|
this.diagnose = diagnose; |
|
|
|
if(diagnose==null){ |
|
|
|
clearFields(); |
|
|
|
}else { |
|
|
|
copyDiagnoseDataIntoFields(diagnose); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void copyDiagnoseDataIntoFields(Diagnose diagnose){ |
|
|
|
diagDiagnoseArzt.setValue(diagnose.getArzt()); |
|
|
|
|