| @@ -1,8 +1,5 @@ | |||||
| package de.uniluebeck.mi.projmi6.controller; | 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.db.DBHandler; | ||||
| import de.uniluebeck.mi.projmi6.model.DiagArt; | import de.uniluebeck.mi.projmi6.model.DiagArt; | ||||
| @@ -19,13 +16,24 @@ import javafx.fxml.FXML; | |||||
| import javafx.scene.control.*; | import javafx.scene.control.*; | ||||
| import javafx.scene.layout.GridPane; | import javafx.scene.layout.GridPane; | ||||
| /** | |||||
| * Controller that mantains the diagnosis assigned to a case in the UI. | |||||
| * | |||||
| * @author Johannes | |||||
| * Created by 631806 on 12.11.15. | |||||
| */ | |||||
| public class DiagnoseController { | public class DiagnoseController { | ||||
| SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW); | |||||
| @FXML | |||||
| Button btnDiagAbort, btnDiagEdit; | |||||
| private MainController mainController; | |||||
| private SimpleObjectProperty<ObservableList<Diagnose>> diagnosen = new SimpleObjectProperty<>(); | private SimpleObjectProperty<ObservableList<Diagnose>> diagnosen = new SimpleObjectProperty<>(); | ||||
| private final SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW); | |||||
| @FXML | |||||
| private Button btnDiagAbort, btnDiagEdit, btnDiagSave,btnDiagCreate, btnDiagCancel; | |||||
| @FXML | |||||
| private final MainController mainController; | |||||
| @FXML | @FXML | ||||
| private ListView<Diagnose> diagnoseList; | private ListView<Diagnose> diagnoseList; | ||||
| @FXML | @FXML | ||||
| @@ -33,52 +41,68 @@ public class DiagnoseController { | |||||
| @FXML | @FXML | ||||
| private ComboBox<Mitarbeiter> diagDiagnoseArzt; | private ComboBox<Mitarbeiter> diagDiagnoseArzt; | ||||
| @FXML | @FXML | ||||
| private Label diagCreator; | |||||
| @FXML | |||||
| private Button btnDiagCancel; | |||||
| private Label diagCreator, diagCreateTime, diagChanger, diagChangeTime; | |||||
| @FXML | @FXML | ||||
| private TextArea diagFreitext; | private TextArea diagFreitext; | ||||
| @FXML | @FXML | ||||
| private Button btnDiagSave; | |||||
| @FXML | |||||
| private Label diagCreateTime; | |||||
| @FXML | |||||
| private ComboBox<DiagArt> diagDiagnoseArt; | private ComboBox<DiagArt> diagDiagnoseArt; | ||||
| @FXML | @FXML | ||||
| private Label diagChanger; | |||||
| @FXML | |||||
| private ComboBox<Icd10Code> diagDiagnose; | private ComboBox<Icd10Code> diagDiagnose; | ||||
| @FXML | |||||
| private Label diagChangeTime; | |||||
| @FXML | |||||
| private Button btnDiagCreate; | |||||
| /** | |||||
| * Contructor. | |||||
| * @param mainController The main controller that creates this instance. | |||||
| */ | |||||
| public DiagnoseController(MainController mainController) { | public DiagnoseController(MainController mainController) { | ||||
| this.mainController = mainController; | this.mainController = mainController; | ||||
| } | } | ||||
| /** | |||||
| * Getter for the {@link #diagnosenProperty()}. | |||||
| * @return The list of diagnosis shown in the GUI. Might be null. | |||||
| */ | |||||
| public ObservableList<Diagnose> getDiagnosen() { | public ObservableList<Diagnose> getDiagnosen() { | ||||
| return diagnosen.get(); | return diagnosen.get(); | ||||
| } | } | ||||
| /** | |||||
| * Setter for the {@link #diagnosenProperty()}. | |||||
| * @param diagnosen A observable list of diagnosis to be set. | |||||
| */ | |||||
| public void setDiagnosen(ObservableList<Diagnose> diagnosen) { | public void setDiagnosen(ObservableList<Diagnose> diagnosen) { | ||||
| this.diagnosen.set(diagnosen); | this.diagnosen.set(diagnosen); | ||||
| } | } | ||||
| /** | |||||
| * The diagnosis in this controller. | |||||
| * @return A simple object property. | |||||
| */ | |||||
| public SimpleObjectProperty<ObservableList<Diagnose>> diagnosenProperty() { | public SimpleObjectProperty<ObservableList<Diagnose>> diagnosenProperty() { | ||||
| return diagnosen; | return diagnosen; | ||||
| } | } | ||||
| /** | |||||
| * Getter for the state of this controller | |||||
| * @return State.VIEW, State.EDIT or State.CREATE | |||||
| */ | |||||
| public State getState() { | public State getState() { | ||||
| return state.get(); | return state.get(); | ||||
| } | } | ||||
| /** | |||||
| * A property for the controllers state. | |||||
| * @return | |||||
| */ | |||||
| public ReadOnlyObjectProperty<State> stateProperty() { | public ReadOnlyObjectProperty<State> stateProperty() { | ||||
| return state; | return state; | ||||
| } | } | ||||
| /** | |||||
| * FXMLLoaders initialize()-method. | |||||
| * See <a href="https://docs.oracle.com/javase/8/javafx/api/javafx/fxml/doc-files/introduction_to_fxml.html#controllers">Oracle FXML Introduction</a> | |||||
| */ | |||||
| @FXML | @FXML | ||||
| public void initialize() { | |||||
| private void initialize() { | |||||
| diagDiagnose.itemsProperty().bind(mainController.getStammdaten().icd10CodesProperty()); | diagDiagnose.itemsProperty().bind(mainController.getStammdaten().icd10CodesProperty()); | ||||
| @@ -105,6 +129,9 @@ public class DiagnoseController { | |||||
| } | } | ||||
| /** | |||||
| * Bind button visibility to application state. | |||||
| */ | |||||
| private void initButtons() { | private void initButtons() { | ||||
| btnDiagCreate.disableProperty().bind(mainController.fallProperty().isNull()); | btnDiagCreate.disableProperty().bind(mainController.fallProperty().isNull()); | ||||
| @@ -122,11 +149,17 @@ public class DiagnoseController { | |||||
| } | } | ||||
| /** | |||||
| * EventHandler for {@link #btnDiagEdit}. | |||||
| */ | |||||
| @FXML | @FXML | ||||
| private void clickedEdit() { | private void clickedEdit() { | ||||
| state.set(State.EDIT); | state.set(State.EDIT); | ||||
| } | } | ||||
| /** | |||||
| * EventHandler for {@link #btnDiagAbort}. | |||||
| */ | |||||
| @FXML | @FXML | ||||
| private void clickedAbort() { | private void clickedAbort() { | ||||
| state.set(State.VIEW); | state.set(State.VIEW); | ||||
| @@ -138,18 +171,24 @@ public class DiagnoseController { | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * EventHandler for the {@link #btnDiagCreate}. | |||||
| */ | |||||
| @FXML | @FXML | ||||
| void clickedDiagCreate(ActionEvent event) { | |||||
| void clickedDiagCreate() { | |||||
| this.state.set(State.CREATE); | this.state.set(State.CREATE); | ||||
| } | } | ||||
| /** | |||||
| * EventHandler for the {@link #btnDiagCancel}. | |||||
| */ | |||||
| @FXML | @FXML | ||||
| void clickedDiagCancel(ActionEvent event) { | |||||
| void clickedDiagCancel() { | |||||
| } | } | ||||
| @FXML | @FXML | ||||
| void clickedDiagSave(ActionEvent event) { | |||||
| void clickedDiagSave() { | |||||
| if (state.get() == State.CREATE) { | if (state.get() == State.CREATE) { | ||||
| //Create new diagnosis | //Create new diagnosis | ||||
| Diagnose diagnose = new Diagnose(); | Diagnose diagnose = new Diagnose(); | ||||