diff options
Diffstat (limited to 'src/main/java/at')
3 files changed, 30 insertions, 24 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeController.java index 0ae6e91..8a6fb0c 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeController.java @@ -107,19 +107,20 @@ public class CreateNewEmployeeController {          } catch (InvalidEmployeeException e) {              LOG.debug("Validation for Employee failed"); -            showModalDialogWithOkButton(AlertType.ERROR, "Ungültige Eingabe", e.getMessage()); +            Helper.showAlertWithOkButtonAndWait( +                    AlertType.ERROR, "Ungültige Eingabe", e.getMessage());              return;          } catch (ServiceException e) {              LOG.error("ServiceException in onCreateClicked(). ", e); -            showModalDialogWithOkButton( +            Helper.showAlertWithOkButtonAndWait(                      AlertType.ERROR,                      "Speicherfehler",                      "Der Eintrag konnte nicht gespeichert werden. Bitte versuchen Sie es erneut.");              return;          } -        showModalDialogWithOkButton( +        Helper.showAlertWithOkButtonAndWait(                  AlertType.INFORMATION,                  "Erfolgreich angelegt",                  "Mitarbeiter wurde erfolgreich angelegt und gespeichert!"); @@ -129,13 +130,6 @@ public class CreateNewEmployeeController {          }      } -    private void showModalDialogWithOkButton( -            AlertType alertType, String headerText, String contentText) { -        Alert alert = new Alert(alertType, contentText, ButtonType.OK); -        alert.setHeaderText(headerText); -        alert.showAndWait(); -    } -      private EducationLevel parseEducationLevel() {          if (inputQualification.getSelectionModel().getSelectedItem() == null) {              return EducationLevel.RS; diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java index 06b4bbd..68a3548 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java @@ -153,10 +153,11 @@ public class CreateOperationController {              }          } catch (ServiceException | IOException e) {              LOG.error("Exception in updateList(). ", e); -            showAlert(AlertType.ERROR, "Fehler", e.getMessage()); +            Helper.showAlertWithOkButtonAndWait(AlertType.ERROR, "Fehler", e.getMessage());          } catch (InvalidOperationException e) {              LOG.debug("Validation error in updateList(). ", e); -            showAlert(AlertType.ERROR, "Validierungsfehler", e.getMessage()); +            Helper.showAlertWithOkButtonAndWait( +                    AlertType.ERROR, "Validierungsfehler", e.getMessage());          }          try {              lvActiveOperations.setItems( @@ -164,7 +165,7 @@ public class CreateOperationController {                              operationService.list(EnumSet.of(Status.ACTIVE))));          } catch (ServiceException e) {              LOG.error("ServiceException in updateList(). ", e); -            showAlert( +            Helper.showAlertWithOkButtonAndWait(                      AlertType.ERROR,                      "Fehler",                      "Beim Holen der aktiven Einsätze ist ein Fehler aufgetreten"); @@ -262,14 +263,15 @@ public class CreateOperationController {              operationService.add(operation);          } catch (ServiceException e) {              LOG.error("Exception in createOperationClicked(). ", e); -            showAlert(AlertType.ERROR, "Fehler", e.getMessage()); +            Helper.showAlertWithOkButtonAndWait(AlertType.ERROR, "Fehler", e.getMessage());              return;          } catch (InvalidOperationException e) {              LOG.debug("Validation error in createOperationClicked(). ", e); -            showAlert(AlertType.ERROR, "Validierungsfehler", e.getMessage()); +            Helper.showAlertWithOkButtonAndWait( +                    AlertType.ERROR, "Validierungsfehler", e.getMessage());              return;          } -        showAlert( +        Helper.showAlertWithOkButtonAndWait(                  AlertType.CONFIRMATION,                  "Erfolgreich gespeichert",                  "Der Einsatz wurde erfolgreich gespeichert."); @@ -281,14 +283,6 @@ public class CreateOperationController {          chosenVehicles = new LinkedList<>();      } -    private void showAlert(AlertType alertType, String title, String content) { -        Alert alert = new Alert(alertType); -        alert.setTitle(title); -        alert.setHeaderText(title); -        alert.setContentText(content); -        alert.showAndWait(); -    } -      @FXML      private void onRegistrationLinkClicked() {          LOG.debug("Hyperlink \"Anmeldungen\" clicked."); diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/Helper.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/Helper.java new file mode 100644 index 0000000..077c57a --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/Helper.java @@ -0,0 +1,18 @@ +package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; + +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.ButtonType; + +class Helper { + +    private Helper() {} // SonarLint insisted to create a private constructor to hide the public one + +    static void showAlertWithOkButtonAndWait( +            AlertType alertType, String headerText, String contentText) { +        Alert alert = new Alert(alertType, contentText, ButtonType.OK); +        alert.setTitle(headerText); +        alert.setHeaderText(headerText); +        alert.showAndWait(); +    } +}  | 
