Add ignore action to model menu contributor
This commit is contained in:
parent
df91a71eb7
commit
e0a9d5ccf0
|
@ -17,6 +17,7 @@ import ctbrec.ui.AutosizeAlert;
|
||||||
import ctbrec.ui.SiteUiFactory;
|
import ctbrec.ui.SiteUiFactory;
|
||||||
import ctbrec.ui.StreamSourceSelectionDialog;
|
import ctbrec.ui.StreamSourceSelectionDialog;
|
||||||
import ctbrec.ui.action.AddToGroupAction;
|
import ctbrec.ui.action.AddToGroupAction;
|
||||||
|
import ctbrec.ui.action.IgnoreModelsAction;
|
||||||
import ctbrec.ui.action.PlayAction;
|
import ctbrec.ui.action.PlayAction;
|
||||||
import ctbrec.ui.action.SetStopDateAction;
|
import ctbrec.ui.action.SetStopDateAction;
|
||||||
import ctbrec.ui.action.StartRecordingAction;
|
import ctbrec.ui.action.StartRecordingAction;
|
||||||
|
@ -44,6 +45,8 @@ public class ModelMenuContributor {
|
||||||
private Node source;
|
private Node source;
|
||||||
private Consumer<Model> startStopCallback;
|
private Consumer<Model> startStopCallback;
|
||||||
private TriConsumer<Model, Boolean, Boolean> followCallback;
|
private TriConsumer<Model, Boolean, Boolean> followCallback;
|
||||||
|
private Consumer<Model> ignoreCallback;
|
||||||
|
private boolean removeWithIgnore = false;
|
||||||
|
|
||||||
private ModelMenuContributor(Node source, Config config, Recorder recorder) {
|
private ModelMenuContributor(Node source, Config config, Recorder recorder) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
|
@ -65,9 +68,20 @@ public class ModelMenuContributor {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ModelMenuContributor withIgnoreCallback(Consumer<Model> ignoreCallback) {
|
||||||
|
this.ignoreCallback = ignoreCallback;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModelMenuContributor removeModelAfterIgnore(boolean yes) {
|
||||||
|
this.removeWithIgnore = yes;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public void contributeToMenu(List<Model> selectedModels, ContextMenu menu) {
|
public void contributeToMenu(List<Model> selectedModels, ContextMenu menu) {
|
||||||
startStopCallback = Optional.ofNullable(startStopCallback).orElse(m -> {});
|
startStopCallback = Optional.ofNullable(startStopCallback).orElse(m -> {});
|
||||||
followCallback = Optional.ofNullable(followCallback).orElse((m, f, s) -> {});
|
followCallback = Optional.ofNullable(followCallback).orElse((m, f, s) -> {});
|
||||||
|
ignoreCallback = Optional.ofNullable(ignoreCallback).orElse(m -> {});
|
||||||
addOpenInPlayer(menu, selectedModels);
|
addOpenInPlayer(menu, selectedModels);
|
||||||
menu.getItems().add(new SeparatorMenuItem());
|
menu.getItems().add(new SeparatorMenuItem());
|
||||||
addStartOrStop(menu, selectedModels);
|
addStartOrStop(menu, selectedModels);
|
||||||
|
@ -78,6 +92,17 @@ public class ModelMenuContributor {
|
||||||
addGroupMenu(menu, selectedModels);
|
addGroupMenu(menu, selectedModels);
|
||||||
menu.getItems().add(new SeparatorMenuItem());
|
menu.getItems().add(new SeparatorMenuItem());
|
||||||
addFollowUnfollow(menu, selectedModels);
|
addFollowUnfollow(menu, selectedModels);
|
||||||
|
addIgnore(menu, selectedModels);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addIgnore(ContextMenu menu, List<Model> selectedModels) {
|
||||||
|
var ignore = new MenuItem("Ignore");
|
||||||
|
ignore.setOnAction(e -> ignore(selectedModels));
|
||||||
|
menu.getItems().add(ignore);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ignore(List<Model> selectedModels) {
|
||||||
|
new IgnoreModelsAction(source, selectedModels, recorder, removeWithIgnore).execute(ignoreCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFollowUnfollow(ContextMenu menu, List<Model> selectedModels) {
|
private void addFollowUnfollow(ContextMenu menu, List<Model> selectedModels) {
|
||||||
|
|
|
@ -4,10 +4,8 @@ import java.io.IOException;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
@ -35,7 +33,6 @@ import ctbrec.ui.AutosizeAlert;
|
||||||
import ctbrec.ui.DesktopIntegration;
|
import ctbrec.ui.DesktopIntegration;
|
||||||
import ctbrec.ui.SiteUiFactory;
|
import ctbrec.ui.SiteUiFactory;
|
||||||
import ctbrec.ui.TokenLabel;
|
import ctbrec.ui.TokenLabel;
|
||||||
import ctbrec.ui.action.IgnoreModelsAction;
|
|
||||||
import ctbrec.ui.action.OpenRecordingsDir;
|
import ctbrec.ui.action.OpenRecordingsDir;
|
||||||
import ctbrec.ui.action.TipAction;
|
import ctbrec.ui.action.TipAction;
|
||||||
import ctbrec.ui.controls.CustomMouseBehaviorContextMenu;
|
import ctbrec.ui.controls.CustomMouseBehaviorContextMenu;
|
||||||
|
@ -461,9 +458,6 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
var model = cell.getModel();
|
var model = cell.getModel();
|
||||||
var selectedModels = getSelectedThumbCells(cell).stream().map(ThumbCell::getModel).collect(Collectors.toList());
|
var selectedModels = getSelectedThumbCells(cell).stream().map(ThumbCell::getModel).collect(Collectors.toList());
|
||||||
|
|
||||||
var ignore = new MenuItem("Ignore");
|
|
||||||
ignore.setOnAction(e -> ignore(getSelectedThumbCells(cell)));
|
|
||||||
|
|
||||||
var refresh = new MenuItem("Refresh Overview");
|
var refresh = new MenuItem("Refresh Overview");
|
||||||
refresh.setOnAction(e -> refresh());
|
refresh.setOnAction(e -> refresh());
|
||||||
|
|
||||||
|
@ -494,12 +488,16 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
selectedThumbCells.clear();
|
selectedThumbCells.clear();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.withIgnoreCallback(m -> getThumbCell(m).ifPresent(thumbCell -> {
|
||||||
|
grid.getChildren().remove(thumbCell);
|
||||||
|
selectedThumbCells.remove(thumbCell);
|
||||||
|
}))
|
||||||
.contributeToMenu(selectedModels, contextMenu);
|
.contributeToMenu(selectedModels, contextMenu);
|
||||||
|
|
||||||
if (site.supportsTips()) {
|
if (site.supportsTips()) {
|
||||||
contextMenu.getItems().add(sendTip);
|
contextMenu.getItems().add(sendTip);
|
||||||
}
|
}
|
||||||
contextMenu.getItems().addAll(copyUrl, openInBrowser, ignore, refresh, openRecDir);
|
contextMenu.getItems().addAll(copyUrl, openInBrowser, refresh, openRecDir);
|
||||||
if (model instanceof MyFreeCamsModel && Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
if (model instanceof MyFreeCamsModel && Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
||||||
var debug = new MenuItem("debug");
|
var debug = new MenuItem("debug");
|
||||||
debug.setOnAction(e -> MyFreeCamsClient.getInstance().getSessionState(model));
|
debug.setOnAction(e -> MyFreeCamsClient.getInstance().getSessionState(model));
|
||||||
|
@ -589,19 +587,6 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ignore(List<ThumbCell> selection) {
|
|
||||||
Map<Model, ThumbCell> thumbcells = new HashMap<>();
|
|
||||||
List<Model> selectedModels = selection.stream().map(tc -> {
|
|
||||||
thumbcells.put(tc.getModel(), tc);
|
|
||||||
return tc;
|
|
||||||
}).map(ThumbCell::getModel).collect(Collectors.toList());
|
|
||||||
new IgnoreModelsAction(grid, selectedModels, recorder, false).execute(m -> {
|
|
||||||
var thumbCell = thumbcells.get(m);
|
|
||||||
grid.getChildren().remove(thumbCell);
|
|
||||||
selectedThumbCells.remove(thumbCell);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showAddToFollowedAnimation(ThumbCell thumbCell) {
|
private void showAddToFollowedAnimation(ThumbCell thumbCell) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
var tx = thumbCell.getLocalToParentTransform();
|
var tx = thumbCell.getLocalToParentTransform();
|
||||||
|
|
Loading…
Reference in New Issue