Browse Source

DiagnoseControler arbeiten

testBranch
Johannes 10 years ago
parent
commit
2cb53917e4
3 changed files with 81 additions and 18 deletions
  1. +75
    -16
      src/main/java/de/uniluebeck/mi/projmi6/controller/DiagnoseController.java
  2. +3
    -1
      src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java
  3. +3
    -1
      src/main/resources/diagnose.fxml

+ 75
- 16
src/main/java/de/uniluebeck/mi/projmi6/controller/DiagnoseController.java View File

@@ -4,7 +4,9 @@ package de.uniluebeck.mi.projmi6.controller;
* Created by 631806 on 12.11.15. * Created by 631806 on 12.11.15.
*/ */


import de.uniluebeck.mi.projmi6.db.DBHandler;
import de.uniluebeck.mi.projmi6.model.*; import de.uniluebeck.mi.projmi6.model.*;
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.collections.ObservableList; import javafx.collections.ObservableList;
@@ -12,6 +14,7 @@ import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.scene.layout.GridPane;


public class DiagnoseController { 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 @FXML
private ListView<Diagnose> diagnoseList; private ListView<Diagnose> diagnoseList;


@@ -48,14 +66,63 @@ public class DiagnoseController {
diagDiagnoseArzt.itemsProperty().bind(mainController.getStammdaten().mitarbeiterProperty()); diagDiagnoseArzt.itemsProperty().bind(mainController.getStammdaten().mitarbeiterProperty());
diagnoseList.itemsProperty().bind(diagnosen); diagnoseList.itemsProperty().bind(diagnosen);


initButtons();

fields.disableProperty().bind(state.isEqualTo(State.VIEW));

diagnoseList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); diagnoseList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
diagnoseList.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { 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 @FXML
private ComboBox<Mitarbeiter> diagDiagnoseArzt; private ComboBox<Mitarbeiter> diagDiagnoseArzt;
@@ -92,7 +159,7 @@ public class DiagnoseController {


@FXML @FXML
void clickedDiagCreate(ActionEvent event) { void clickedDiagCreate(ActionEvent event) {
this.state.set(State.CREATE);
} }


@FXML @FXML
@@ -102,24 +169,16 @@ public class DiagnoseController {


@FXML @FXML
void clickedDiagSave(ActionEvent event) { 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){ private void copyDiagnoseDataIntoFields(Diagnose diagnose){
diagDiagnoseArzt.setValue(diagnose.getArzt()); diagDiagnoseArzt.setValue(diagnose.getArzt());


+ 3
- 1
src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java View File

@@ -117,7 +117,8 @@ public class StationsHistorieController {
btnStatHistAbort.visibleProperty().bind(state.isEqualTo(State.VIEW).not()); btnStatHistAbort.visibleProperty().bind(state.isEqualTo(State.VIEW).not());
btnStatHistAbort.managedProperty().bind(btnStatHistAbort.visibleProperty()); btnStatHistAbort.managedProperty().bind(btnStatHistAbort.visibleProperty());


btnStatHistEdit.visibleProperty().bind(state.isEqualTo(State.VIEW));
btnStatHistEdit.visibleProperty().bind(state.isEqualTo(State.VIEW)
.and(tblStationsHistorie.getSelectionModel().selectedItemProperty().isNotNull()));
btnStatHistEdit.managedProperty().bind(btnStatHistEdit.visibleProperty()); btnStatHistEdit.managedProperty().bind(btnStatHistEdit.visibleProperty());
} }


@@ -174,6 +175,7 @@ public class StationsHistorieController {
} }
mainController.refreshCaseData(); mainController.refreshCaseData();
} }
state.set(State.VIEW);
} }


@FXML @FXML


+ 3
- 1
src/main/resources/diagnose.fxml View File

@@ -22,7 +22,7 @@
</VBox> </VBox>
<VBox> <VBox>
<children> <children>
<GridPane vgap="5.0">
<GridPane vgap="5.0" fx:id="fields">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
@@ -47,6 +47,8 @@
<HBox alignment="TOP_RIGHT" spacing="5.0" VBox.vgrow="ALWAYS"> <HBox alignment="TOP_RIGHT" spacing="5.0" VBox.vgrow="ALWAYS">
<children> <children>
<Button fx:id="btnDiagCancel" mnemonicParsing="false" onAction="#clickedDiagCancel" text="Storno" /> <Button fx:id="btnDiagCancel" mnemonicParsing="false" onAction="#clickedDiagCancel" text="Storno" />
<Button fx:id="btnDiagAbort" mnemonicParsing="false" onAction="#clickedAbort" text="Abbrechen" />
<Button fx:id="btnDiagEdit" mnemonicParsing="false" onAction="#clickedEdit" text="Bearbeiten" />
<Button fx:id="btnDiagSave" mnemonicParsing="false" onAction="#clickedDiagSave" text="Speichern" /> <Button fx:id="btnDiagSave" mnemonicParsing="false" onAction="#clickedDiagSave" text="Speichern" />
</children> </children>
<VBox.margin> <VBox.margin>


Loading…
Cancel
Save