Browse Source

JavaDoc, Refactoring

master
Johannes 10 years ago
parent
commit
5e74290ec4
4 changed files with 161 additions and 63 deletions
  1. +47
    -9
      src/main/java/de/uniluebeck/mi/projmi6/controller/DiagnoseController.java
  2. +112
    -51
      src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java
  3. +1
    -1
      src/main/resources/diagnose.fxml
  4. +1
    -2
      src/main/resources/stationshistorie.fxml

+ 47
- 9
src/main/java/de/uniluebeck/mi/projmi6/controller/DiagnoseController.java View File

@@ -1,6 +1,7 @@
package de.uniluebeck.mi.projmi6.controller;


import com.sun.prism.shader.Solid_Color_AlphaTest_Loader;
import de.uniluebeck.mi.projmi6.db.DBHandler;
import de.uniluebeck.mi.projmi6.model.DiagArt;
import de.uniluebeck.mi.projmi6.model.Diagnose;
@@ -26,6 +27,16 @@ public class DiagnoseController {

private SimpleObjectProperty<ObservableList<Diagnose>> diagnosen = new SimpleObjectProperty<>();

/**
* Controller state definitions
*/
public enum State {
CREATE, EDIT, VIEW
}

/**
* Current controllers state
*/
private final SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW);

@FXML
@@ -65,6 +76,7 @@ public class DiagnoseController {
return diagnosen.get();
}


/**
* Setter for the {@link #diagnosenProperty()}.
* @param diagnosen A observable list of diagnosis to be set.
@@ -118,6 +130,7 @@ public class DiagnoseController {
fields.disableProperty().bind(state.isEqualTo(State.VIEW));

diagnoseList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
diagnoseList.disableProperty().bind(state.isNotEqualTo(State.VIEW));
diagnoseList.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == null) {
clearFields();
@@ -126,6 +139,24 @@ public class DiagnoseController {
}
});

state.addListener((observable, oldValue, newValue) -> {
if(newValue == State.VIEW){
mainController.unlockFromEdit();
Diagnose diagnose = diagnoseList.getSelectionModel().getSelectedItem();
if (diagnose == null) {
clearFields();
} else {
copyDiagnoseDataIntoFields(diagnose);
}
}else{
mainController.lockForEdit(MainController.TabName.DIAGNOSE);
if(newValue==State.CREATE){
clearFields();
diagDiagnoseArzt.setValue(mainController.getCurrentMitarbeiter());
}
}
});


}

@@ -163,12 +194,6 @@ public class DiagnoseController {
@FXML
private void clickedAbort() {
state.set(State.VIEW);
Diagnose diagnose = diagnoseList.getSelectionModel().getSelectedItem();
if (diagnose == null) {
clearFields();
} else {
copyDiagnoseDataIntoFields(diagnose);
}
}

/**
@@ -187,6 +212,9 @@ public class DiagnoseController {

}

/**
* EventHandler method for {@link #btnDiagSave}
*/
@FXML
void clickedDiagSave() {
if (state.get() == State.CREATE) {
@@ -203,8 +231,13 @@ public class DiagnoseController {

}
mainController.refreshCaseData();
state.set(State.VIEW);
}

/**
* Copy the object data into the fields.
* @param diagnose The object with the data.
*/
private void copyDiagnoseDataIntoFields(Diagnose diagnose) {
diagDiagnoseArzt.setValue(diagnose.getArzt());

@@ -219,6 +252,10 @@ public class DiagnoseController {
diagChangeTime.setText(diagnose.getBearbeitetDatumZeit().toString());
}

/**
* Copy the data from the ComboBoxes into data model object
* @param diagnose The object to copy the data into
*/
private void copyFieldDataIntoDiagnose(Diagnose diagnose) {
diagnose.setIcd10code(diagDiagnose.getValue());
diagnose.setArzt(diagDiagnoseArzt.getValue());
@@ -230,6 +267,10 @@ public class DiagnoseController {
diagnose.setBearbeiter(mainController.getCurrentMitarbeiter().getMitarbID());
}

/**
* Clear the fields in case no diagnosis is selcted, or
* creating a new one is started.
*/
private void clearFields() {
diagDiagnoseArzt.setValue(mainController.getCurrentMitarbeiter());
diagDiagnose.setValue(null);
@@ -242,7 +283,4 @@ public class DiagnoseController {
diagChangeTime.setText("");
}

public enum State {
CREATE, EDIT, VIEW
}
}

+ 112
- 51
src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java View File

@@ -26,29 +26,19 @@ import java.util.stream.Collectors;

/**
* The controller class for the hospital ward history.
* <p>
* @author Johannes
* Created by Johannes on 12.11.15.
*/
public class StationsHistorieController {

private final SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW);
@FXML
private Button btnStatHistAbort;
private MainController mainController;

@FXML
private GridPane fields;
@FXML
private Button btnStatHistEdit;
@FXML
private Button btnStatHistDelete;
/**
* The station history that is shown in the edit window, or null if a new station history should be created.
*/
private StationsHistorie stationsHistorieSelected = null;
private MainController mainController;
@FXML
private TableView<StationsHistorie> tblStationsHistorie;
@FXML
private Button btnStatHistCancel, btnStatHistSave;
private Button btnStatHistSave, btnStatHistCreate, btnStatHistEdit, btnStatHistDelete, btnStatHistAbort;
@FXML
private Label statHistCreator, statHistCreateTime, statHistEditor, statHistEditTime;
@FXML
@@ -63,26 +53,56 @@ public class StationsHistorieController {
private ComboBox<String> cmbAbteilung;
private SimpleObjectProperty<ObservableList<StationsHistorie>> stationsHistorie =
new SimpleObjectProperty<>();
@FXML
private Button btnStatHistCreate;


/**
* Definition of the controllers states.
*/
public enum State {
CREATE, EDIT, VIEW;
}

/**
* The current state of the controller.
*/
private final SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW);

/**
* Constructor
* @param mainController
*/
public StationsHistorieController(MainController mainController) {
this.mainController = mainController;
}


/**
* EventHandler for the {@link #btnStatHistEdit}
*/
@FXML
private void clickedEdit() {
this.state.set(State.EDIT);
}

/**
* Getter for the {@link #stateProperty()}
* @return The stateProperty's value.
*/
public State getState() {
return state.get();
}


/**
* @return Property of the controllers state
*/
public ReadOnlyObjectProperty<State> stateProperty() {
return state;
}

/**
* initialize()-method of the controller.
*/
@FXML
private void initialize() {
initColumns();
@@ -106,12 +126,16 @@ public class StationsHistorieController {
});


tblStationsHistorie.disableProperty().bind(state.isNotEqualTo(State.VIEW));
tblStationsHistorie.itemsProperty().bind(stationsHistorie);
tblStationsHistorie.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
setStationsHistorieSelected(newValue);
});
}

/**
* Show/hide/disable buttons depending on the controller state
*/
private void initButtons() {
// btnStatHistCancel.visibleProperty().bind(state.isEqualTo(State.VIEW).and(tblStationsHistorie.getSelectionModel().selectedItemProperty().isNotNull()));
// btnStatHistCancel.managedProperty().bind(btnStatHistCancel.visibleProperty());
@@ -130,22 +154,25 @@ public class StationsHistorieController {
btnStatHistDelete.managedProperty().bind(btnStatHistDelete.visibleProperty());
}


/**
* Init the comboboxes for the wards
*/
private void initStationsFilter() {
final String any = "beliebig";

//Finde die Abteilungen und setzte in die ComboBox
List<String> abteilungen = mainController.getStammdaten().getStationen().stream()
.map(stat -> stat.getAbteilung()).distinct().collect(Collectors.toList());
Collections.sort(abteilungen);
.map(stat -> stat.getAbteilung()).distinct().sorted().collect(Collectors.toList());
cmbAbteilung.setItems(FXCollections.observableArrayList(abteilungen));
cmbAbteilung.getItems().add(0, any);
cmbAbteilung.getSelectionModel().select(0);

new SelectKeyComboBoxListener(cmbAbteilung);

tblStationsHistorie.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
setStationsHistorieSelected(newValue);
});

//Filtere die Stationscombobox nach ausgewaehlter Abteilung
FilteredList<Station> stationenFiltered = new FilteredList<Station>(mainController.getStammdaten().getStationen());

stationenFiltered.predicateProperty().bind(Bindings.createObjectBinding(() -> {
@@ -155,20 +182,16 @@ public class StationsHistorieController {
return p -> p.getAbteilung().equals(cmbAbteilung.getValue());
}, cmbAbteilung.valueProperty()));


cmbStation.setItems(stationenFiltered);
new SelectKeyComboBoxListener(cmbStation);
}

@FXML
private void clickedCancel() {
// this.state.set(State.VIEW);
}

/**
* EventHandler for {@link #btnStatHistSave}.
*/
@FXML
private void clickedSave() {


if (getState() == State.CREATE) {
StationsHistorie stationsHistorie = new StationsHistorie();
copyFieldDataIntoStationsHistorie(stationsHistorie);
@@ -182,6 +205,7 @@ public class StationsHistorieController {
}
mainController.refreshCaseData();
} else {
StationsHistorie stationsHistorieSelected = tblStationsHistorie.getSelectionModel().getSelectedItem();
copyFieldDataIntoStationsHistorie(stationsHistorieSelected);
if (!validateData(stationsHistorieSelected)) {
return;
@@ -196,18 +220,31 @@ public class StationsHistorieController {
state.set(State.VIEW);
}


/**
* EventHandler for {@link #btnStatHistAbort}.
*/
@FXML
private void clickedAbort() {
state.set(State.VIEW);
copyStationsHistorieDataIntoFields();
StationsHistorie stationsHistorieSelected = tblStationsHistorie.getSelectionModel().getSelectedItem();
copyStationsHistorieDataIntoFields(stationsHistorieSelected);
}


/**
* EventHandler for {@link #btnStatHistCreate}.
*/
@FXML
private void clickedCreateAufenthalt() {
this.state.set(State.CREATE);
setStationsHistorieSelected(null);
}


/**
* EventHandler for the {@link #btnStatHistDelete} button.
*/
@FXML
private void clickedDelete() {
StationsHistorie selectedItem = tblStationsHistorie.getSelectionModel().getSelectedItem();
@@ -217,7 +254,7 @@ public class StationsHistorieController {
alert.setTitle("Stationsaufenthalt kann nicht entfernt werden!");
alert.setHeaderText(null);
alert.setContentText("Der Aufenthalt muss in der Zukunft liegen, um gel\u00f6scht werden zu k\u00f6nnen!");
alert.initOwner(btnStatHistCancel.getScene().getWindow());
alert.initOwner(btnStatHistDelete.getScene().getWindow());
alert.initModality(Modality.APPLICATION_MODAL);
alert.showAndWait();
return;
@@ -230,30 +267,39 @@ public class StationsHistorieController {
}

mainController.refreshCaseData();


}

/**
* A getter for {@link #stationsHistorieProperty()}
* @return The value of that property.
*/
public ObservableList<StationsHistorie> getStationsHistorie() {
return stationsHistorie.get();
}

/**
* Setter for the {@link #stationsHistorieProperty()}
* @param stationsHistorie The value to be set.
*/
public void setStationsHistorie(ObservableList<StationsHistorie> stationsHistorie) {
this.stationsHistorie.set(stationsHistorie);
}

/**
* The list that will be shown in the TableView.
* @return A property to that list.
*/
public SimpleObjectProperty<ObservableList<StationsHistorie>> stationsHistorieProperty() {
return stationsHistorie;
}

public void setStationsHistorieSelected(StationsHistorie stationsHistorie) {
this.stationsHistorieSelected = stationsHistorie;
if (stationsHistorie == null) {
clearFields();
} else {
copyStationsHistorieDataIntoFields();
copyStationsHistorieDataIntoFields(stationsHistorie);
}
tblStationsHistorie.getSelectionModel().select(stationsHistorie);
}

private void initColumns() {
@@ -262,16 +308,19 @@ public class StationsHistorieController {
colStatHistEntlassungsDatum.setCellValueFactory(new PropertyValueFactory<StationsHistorie, LocalDate>("entlassungsDatum"));
}

private void copyStationsHistorieDataIntoFields() {

if (stationsHistorieSelected == null) {
/**
* Copies the data from the given StationsHistorie into the fields in the GUI.
*/
private void copyStationsHistorieDataIntoFields(StationsHistorie stationsHistorie) {
if (stationsHistorie == null) {
clearFields();
return;
}

//Setze Station im Dropdownfeld
for (Station station : cmbStation.getItems()) {
if (station.getStation().equals(stationsHistorieSelected.getStationKey())) {
if (station.getStation().equals(stationsHistorie.getStationKey())) {
cmbStation.getSelectionModel().select(station);
cmbAbteilung.getSelectionModel().select(station.getAbteilung());
break;
@@ -279,19 +328,23 @@ public class StationsHistorieController {
}


dtTmAufnahme.setDateTime(stationsHistorieSelected.getAufnahmeDatum());
dtTmEntlassung.setDateTime(stationsHistorieSelected.getEntlassungsDatum());
dtTmAufnahme.setDateTime(stationsHistorie.getAufnahmeDatum());
dtTmEntlassung.setDateTime(stationsHistorie.getEntlassungsDatum());

statHistCreator.setText(Integer.toString(stationsHistorieSelected.getErsteller()));
if (stationsHistorieSelected.getErstellDatumZeit() != null) {
statHistCreateTime.setText(stationsHistorieSelected.getErstellDatumZeit().toString());
statHistCreator.setText(Integer.toString(stationsHistorie.getErsteller()));
if (stationsHistorie.getErstellDatumZeit() != null) {
statHistCreateTime.setText(stationsHistorie.getErstellDatumZeit().toString());
}
statHistEditor.setText(Integer.toString(stationsHistorieSelected.getBearbeiter()));
if (stationsHistorieSelected.getBearbeitetDatumZeit() != null) {
statHistEditTime.setText(stationsHistorieSelected.getBearbeitetDatumZeit().toString());
statHistEditor.setText(Integer.toString(stationsHistorie.getBearbeiter()));
if (stationsHistorie.getBearbeitetDatumZeit() != null) {
statHistEditTime.setText(stationsHistorie.getBearbeitetDatumZeit().toString());
}
}

/**
* Copies the data entered in the fields into {@link de.uniluebeck.mi.projmi6.model.StationsHistorie} objects.
* @param stationsHistorie The object in which the data will be copied
*/
private void copyFieldDataIntoStationsHistorie(StationsHistorie stationsHistorie) {
stationsHistorie.setAufnahmeDatum(dtTmAufnahme.getDateTime());
stationsHistorie.setEntlassungsDatum(dtTmEntlassung.getDateTime());
@@ -306,7 +359,11 @@ public class StationsHistorieController {
stationsHistorie.setBearbeiter(mainController.getCurrentMitarbeiter().getMitarbID());
}


/**
* Helper method for {@link #validateData(StationsHistorie)}. Opens a error window.
* @param title The Alerts header text
* @param message The Alerts contents text
*/
private void showMessage(String title, String message) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Ung\u00fcltige Daten!");
@@ -317,6 +374,11 @@ public class StationsHistorieController {
}


/**
* Checks the StationsHistorie and makes error alerts if necessary.
* @param stationsHistorie The StationsHistorie that should be validated,
* @return true if data is valid, false otherwise.
*/
private boolean validateData(StationsHistorie stationsHistorie) {
if (stationsHistorie.getStationKey() == null) {
showMessage("Keine Station ausgew\00e4hlt!", "Bitte Station und nicht nur Abteilung ausw\00e4hlen!");
@@ -336,8 +398,10 @@ public class StationsHistorieController {
return true;
}

/**
* Clears TextFields in the view
*/
private void clearFields() {

statHistCreateTime.setText("");
statHistCreator.setText("");
statHistEditTime.setText("");
@@ -351,7 +415,4 @@ public class StationsHistorieController {
dtTmEntlassung.setDateTime(null);
}

public enum State {
CREATE, EDIT, VIEW
}
}

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

@@ -42,7 +42,7 @@
<ComboBox fx:id="diagDiagnoseArt" maxWidth="1.7976931348623157E308" GridPane.columnIndex="1"
GridPane.rowIndex="1"/>
<ComboBox fx:id="diagDiagnoseArzt" maxHeight="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" promptText="CurrentUser is Default"
maxWidth="1.7976931348623157E308" promptText=""
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<TextArea fx:id="diagFreitext" maxWidth="1.7976931348623157E308" GridPane.columnIndex="1"
GridPane.rowIndex="3"/>


+ 1
- 2
src/main/resources/stationshistorie.fxml View File

@@ -48,7 +48,7 @@
<ComboBox prefWidth="150.0" GridPane.columnIndex="1" fx:id="cmbAbteilung"/>

<Label text="Station:" GridPane.rowIndex="1"/>
<ComboBox prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="1" fx:id="cmbStation"/>
<ComboBox GridPane.columnIndex="1" GridPane.rowIndex="1" fx:id="cmbStation"/>

<Label text="Aufnahmedatum / -Zeit:" GridPane.rowIndex="2"/>
<DateTimePicker GridPane.columnIndex="1" GridPane.rowIndex="2" fx:id="dtTmAufnahme"/>
@@ -67,7 +67,6 @@
fx:id="btnStatHistSave"/>
<Button mnemonicParsing="false" text="Entfernen" onAction="#clickedDelete"
fx:id="btnStatHistDelete"/>
<!-- <Button disable="true" mnemonicParsing="false" text="Eintrag entfernen" fx:id="btnStatHistCancel" onAction="#clickedCancel"/> -->
</children>
</HBox>
<GridPane>


Loading…
Cancel
Save