forked from j62/ctbrec
1
0
Fork 0

Restart update service in callbacks

This commit is contained in:
0xb00bface 2021-09-11 14:06:16 +02:00
parent baf8a8ae1e
commit d663ca1160
1 changed files with 18 additions and 9 deletions

View File

@ -42,6 +42,7 @@ import ctbrec.ui.controls.autocomplete.AutoFillTextField;
import ctbrec.ui.controls.autocomplete.ObservableListSuggester; import ctbrec.ui.controls.autocomplete.ObservableListSuggester;
import ctbrec.ui.menu.ModelMenuContributor; import ctbrec.ui.menu.ModelMenuContributor;
import ctbrec.ui.tabs.TabSelectionListener; import ctbrec.ui.tabs.TabSelectionListener;
import javafx.application.Platform;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringPropertyBase; import javafx.beans.property.StringPropertyBase;
@ -51,7 +52,6 @@ import javafx.event.ActionEvent;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Point2D; import javafx.geometry.Point2D;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.CheckMenuItem; import javafx.scene.control.CheckMenuItem;
@ -330,18 +330,23 @@ public abstract class AbstractRecordedModelsTab extends Tab implements TabSelect
ContextMenu menu = new CustomMouseBehaviorContextMenu(); ContextMenu menu = new CustomMouseBehaviorContextMenu();
ModelMenuContributor.newContributor(getTabPane(), Config.getInstance(), recorder) // ModelMenuContributor.newContributor(getTabPane(), Config.getInstance(), recorder) //
.withStartStopCallback(m -> getTabPane().setCursor(Cursor.DEFAULT)) // .withStartStopCallback(m -> Platform.runLater(this::reload)) //
.removeModelAfterIgnore(true) // .removeModelAfterIgnore(true) //
.withPortraitCallback(m -> { .withPortraitCallback(m -> Platform.runLater(() -> {
portraitCache.invalidate(m); portraitCache.invalidate(m);
table.refresh(); table.refresh();
}) }))
.afterwards(table::refresh) // .afterwards(() -> Platform.runLater(this::reload))
.contributeToMenu(selectedModels, menu); .contributeToMenu(selectedModels, menu);
return menu; return menu;
} }
protected void reload() {
deselected();
selected();
}
protected void addModel(ActionEvent e) { protected void addModel(ActionEvent e) {
String input = modelInputField.getText().trim(); String input = modelInputField.getText().trim();
if (StringUtil.isBlank(input)) { if (StringUtil.isBlank(input)) {
@ -360,9 +365,11 @@ public abstract class AbstractRecordedModelsTab extends Tab implements TabSelect
var newModel = site.createModelFromUrl(url); var newModel = site.createModelFromUrl(url);
if (newModel != null) { if (newModel != null) {
if (getMarkModelsForLaterRecording()) { if (getMarkModelsForLaterRecording()) {
new MarkForLaterRecordingAction(getTabPane(), List.of(newModel), true, recorder).execute(); new MarkForLaterRecordingAction(modelInputField, List.of(newModel), true, recorder).execute(m -> Platform.runLater(this::reload));
} else { } else {
new StartRecordingAction(getTabPane(), List.of(newModel), recorder).execute(); new StartRecordingAction(modelInputField, List.of(newModel), recorder)
.execute()
.whenComplete((r, ex) -> Platform.runLater(this::reload));
} }
return; return;
} }
@ -387,9 +394,11 @@ public abstract class AbstractRecordedModelsTab extends Tab implements TabSelect
if (Objects.equals(siteName.toLowerCase(), site.getClass().getSimpleName().toLowerCase())) { if (Objects.equals(siteName.toLowerCase(), site.getClass().getSimpleName().toLowerCase())) {
var newModel = site.createModel(modelName); var newModel = site.createModel(modelName);
if (getMarkModelsForLaterRecording()) { if (getMarkModelsForLaterRecording()) {
new MarkForLaterRecordingAction(getTabPane(), List.of(newModel), true, recorder).execute(); new MarkForLaterRecordingAction(modelInputField, List.of(newModel), true, recorder).execute(m -> Platform.runLater(this::reload));
} else { } else {
new StartRecordingAction(getTabPane(), List.of(newModel), recorder).execute(); new StartRecordingAction(modelInputField, List.of(newModel), recorder)
.execute()
.whenComplete((r, ex) -> Platform.runLater(this::reload));
} }
return; return;
} }