diff options
Diffstat (limited to 'src/main/java/at')
| -rw-r--r-- | src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java | 50 | 
1 files changed, 27 insertions, 23 deletions
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 81437f5..8cebeab 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 @@ -164,14 +164,12 @@ public class CreateOperationController {                  fpVehicles.getChildren().add(controller.getRootElement());              } -        } catch (ServiceException | IOException | InvalidOperationException e) { +        } catch (ServiceException | IOException e) {              LOG.error("Exception in updateList(). ", e); - -            Alert alert = new Alert(Alert.AlertType.ERROR); -            alert.setTitle("Fehler"); -            alert.setHeaderText("Fehler!"); -            alert.setContentText(e.getMessage()); -            alert.showAndWait(); +            showAlert(AlertType.ERROR, "Fehler", e.getMessage()); +        } catch (InvalidOperationException e) { +            LOG.debug("Validation error in updateList(). ", e); +            showAlert(AlertType.ERROR, "Validierungsfehler", e.getMessage());          }          try {              lvActiveOperations.setItems( @@ -179,11 +177,10 @@ public class CreateOperationController {                              operationService.list(EnumSet.of(Status.ACTIVE))));          } catch (ServiceException e) {              LOG.error("ServiceException in updateList(). ", e); -            Alert alert = new Alert(Alert.AlertType.ERROR); -            alert.setTitle("Fehler - Einsätze"); -            alert.setHeaderText("Beim Holen der aktiven Einsätze ist ein Fehler aufgetreten."); -            alert.setContentText(e.getMessage()); -            alert.showAndWait(); +            showAlert( +                    AlertType.ERROR, +                    "Fehler", +                    "Beim Holen der aktiven Einsätze ist ein Fehler aufgetreten");          }      } @@ -276,20 +273,19 @@ public class CreateOperationController {                          .build();          try {              operationService.add(operation); -        } catch (ServiceException | InvalidOperationException e) { +        } catch (ServiceException e) {              LOG.error("Exception in createOperationClicked(). ", e); -            Alert alert = new Alert(Alert.AlertType.ERROR); -            alert.setTitle("Fehler"); -            alert.setHeaderText("Fehler!"); -            alert.setContentText(e.getMessage()); -            alert.showAndWait(); +            showAlert(AlertType.ERROR, "Fehler", e.getMessage()); +            return; +        } catch (InvalidOperationException e) { +            LOG.debug("Validation error in createOperationClicked(). ", e); +            showAlert(AlertType.ERROR, "Validierungsfehler", e.getMessage());              return;          } -        Alert alert = new Alert(AlertType.CONFIRMATION); -        alert.setTitle("Erfolg"); -        alert.setHeaderText("Erfolgreich gespeichert"); -        alert.setContentText("Der Einsatz wurde erfolgreich gespeichert."); -        alert.showAndWait(); +        showAlert( +                AlertType.CONFIRMATION, +                "Erfolgreich gespeichert", +                "Der Einsatz wurde erfolgreich gespeichert.");          updateList();          lblChosenVehicles.setText("keine ausgewählt");          txtAddress.setText(""); @@ -298,6 +294,14 @@ 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(); +    } +      public void onRegistrationLinkClicked(ActionEvent actionEvent) {          LOG.debug("Hyperlink \"Anmeldungen\" clicked.");          openRegistrationWindow();  | 
