From 7c78ed84cde75adeaa8864e5b046904364de80fc Mon Sep 17 00:00:00 2001 From: tobias <tobias@thecodedev.de> Date: Sun, 15 Sep 2019 20:51:13 +0200 Subject: [PATCH] Improve PlayoutLog session name validation; Fixed PlayoutLog Session deletion --- .../PlayoutLogViewController.java | 24 ++++++++++++++----- .../resources/lang/playoutlog_de.properties | 4 +++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/PlayWallPlugins/PlayWallPluginPlayoutLog/src/main/java/de/tobias/playpad/plugin/playout/viewcontroller/PlayoutLogViewController.java b/PlayWallPlugins/PlayWallPluginPlayoutLog/src/main/java/de/tobias/playpad/plugin/playout/viewcontroller/PlayoutLogViewController.java index dfc47800..479c4e5f 100644 --- a/PlayWallPlugins/PlayWallPluginPlayoutLog/src/main/java/de/tobias/playpad/plugin/playout/viewcontroller/PlayoutLogViewController.java +++ b/PlayWallPlugins/PlayWallPluginPlayoutLog/src/main/java/de/tobias/playpad/plugin/playout/viewcontroller/PlayoutLogViewController.java @@ -65,7 +65,7 @@ public class PlayoutLogViewController extends NVC { @Override public void init() { - logList.getItems().setAll(LogSeasons.getAllLogSeasonsLazy()); + updateListView(); if (LogSeasons.getCurrentSession() != null) { // Running startButton.setText(Localization.getString(Strings.PLAYOUT_LOG_DIALOG_BUTTON_STOP)); @@ -82,6 +82,8 @@ public class PlayoutLogViewController extends NVC { autoStartCheckbox.selectedProperty().addListener((observable, oldValue, newValue) -> SettingsProxy.getSettings(PlayoutLogSettings.class).autoStartLogging(newValue)); + startButton.disableProperty().bind(nameTextField.textProperty().isEmpty()); + exportButton.setDisable(true); exportCsvButton.setDisable(true); logList.getSelectionModel().getSelectedItems().addListener((InvalidationListener) observable -> { @@ -91,6 +93,10 @@ public class PlayoutLogViewController extends NVC { deleteButton.disableProperty().bind(logList.getSelectionModel().selectedItemProperty().isNull()); } + private void updateListView() { + logList.getItems().setAll(LogSeasons.getAllLogSeasonsLazy()); + } + @Override public void initStage(Stage stage) { stage.getIcons().add(PlayPadPlugin.getInstance().getIcon()); @@ -111,6 +117,11 @@ public class PlayoutLogViewController extends NVC { return; } + if (LogSeasons.getAllLogSeasonsLazy().stream().anyMatch(item -> item.getName().equals(nameTextField.getText()))) { + showErrorMessage(Localization.getString("PlayoutLogDialog.Error.NameExists")); + return; + } + final Project currentProject = PlayPadPlugin.getInstance().getCurrentProject(); final ProjectSettings settings = currentProject.getSettings(); @@ -119,10 +130,13 @@ public class PlayoutLogViewController extends NVC { startButton.setText(Localization.getString(Strings.PLAYOUT_LOG_DIALOG_BUTTON_STOP)); nameTextField.setDisable(false); + + updateListView(); } else { // Stop LogSeasons.stop(); startButton.setText(Localization.getString(Strings.PLAYOUT_LOG_DIALOG_BUTTON_START)); nameTextField.setDisable(false); + nameTextField.setText(""); } } @@ -169,7 +183,7 @@ public class PlayoutLogViewController extends NVC { mapper.configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true); CsvSchema schema = CsvSchema.builder() - .addColumn("Name") + .addColumn("Name") .addColumn("Zaehler") .addColumn("Sessions") .addColumn("Erstes Datum") @@ -188,10 +202,8 @@ public class PlayoutLogViewController extends NVC { @FXML private void deleteButtonHandler(ActionEvent event) { - logList.getSelectionModel().getSelectedItems().forEach(season -> { - LogSeasons.deleteSession(season.getId()); - logList.getItems().remove(season); - }); + logList.getSelectionModel().getSelectedItems().forEach(season -> LogSeasons.deleteSession(season.getId())); + updateListView(); } @FXML diff --git a/PlayWallPlugins/PlayWallPluginPlayoutLog/src/main/resources/lang/playoutlog_de.properties b/PlayWallPlugins/PlayWallPluginPlayoutLog/src/main/resources/lang/playoutlog_de.properties index b40da3c9..6808e923 100644 --- a/PlayWallPlugins/PlayWallPluginPlayoutLog/src/main/resources/lang/playoutlog_de.properties +++ b/PlayWallPlugins/PlayWallPluginPlayoutLog/src/main/resources/lang/playoutlog_de.properties @@ -7,4 +7,6 @@ PlayoutLogDialog.Button.Start=Starten PlayoutLogDialog.Button.Stop=Stoppen PlayoutLogDialog.Button.Export=PDF Exportieren... PlayoutLogDialog.Button.ExportAll=CSV Exportieren... -PlayoutLogDialog.Button.Delete=L\u00F6schen... \ No newline at end of file +PlayoutLogDialog.Button.Delete=L\u00F6schen... + +PlayoutLogDialog.Error.NameExists=Dieser Name ist bereits verwendet. W\u00E4hlen Sie bitte einen anderen Namen. \ No newline at end of file -- GitLab