forked from j62/ctbrec
Make use of new actions
This commit is contained in:
parent
a68341de82
commit
60da66139e
|
@ -8,13 +8,10 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -30,11 +27,10 @@ import ctbrec.recorder.Recorder;
|
|||
import ctbrec.sites.Site;
|
||||
import ctbrec.ui.action.FollowAction;
|
||||
import ctbrec.ui.action.PauseAction;
|
||||
import ctbrec.ui.action.PlayAction;
|
||||
import ctbrec.ui.action.ResumeAction;
|
||||
import ctbrec.ui.action.StopRecordingAction;
|
||||
import ctbrec.ui.controls.AutoFillTextField;
|
||||
import ctbrec.ui.controls.Toast;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
@ -42,7 +38,6 @@ import javafx.concurrent.ScheduledService;
|
|||
import javafx.concurrent.Task;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ContextMenu;
|
||||
|
@ -72,9 +67,6 @@ import javafx.util.Duration;
|
|||
public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(RecordedModelsTab.class);
|
||||
|
||||
static BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
|
||||
static ExecutorService threadPool = new ThreadPoolExecutor(2, 2, 10, TimeUnit.MINUTES, queue);
|
||||
|
||||
private ScheduledService<List<JavaFxModel>> updateService;
|
||||
private Recorder recorder;
|
||||
private List<Site> sites;
|
||||
|
@ -445,16 +437,7 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
|||
}
|
||||
|
||||
private void openInPlayer(JavaFxModel selectedModel) {
|
||||
table.setCursor(Cursor.WAIT);
|
||||
new Thread(() -> {
|
||||
boolean started = Player.play(selectedModel);
|
||||
Platform.runLater(() -> {
|
||||
if (started && Config.getInstance().getSettings().showPlayerStarting) {
|
||||
Toast.makeText(getTabPane().getScene(), "Starting Player", 2000, 500, 500);
|
||||
}
|
||||
table.setCursor(Cursor.DEFAULT);
|
||||
});
|
||||
}).start();
|
||||
new PlayAction(getTabPane(), selectedModel).execute();
|
||||
}
|
||||
|
||||
private void switchStreamSource(JavaFxModel fxModel) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import ctbrec.Config;
|
|||
import ctbrec.Model;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.ui.controls.Toast;
|
||||
import ctbrec.ui.action.PlayAction;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.FillTransition;
|
||||
import javafx.animation.ParallelTransition;
|
||||
|
@ -341,16 +341,7 @@ public class ThumbCell extends StackPane {
|
|||
}
|
||||
|
||||
void startPlayer() {
|
||||
setCursor(Cursor.WAIT);
|
||||
new Thread(() -> {
|
||||
boolean started = Player.play(model);
|
||||
Platform.runLater(() -> {
|
||||
setCursor(Cursor.DEFAULT);
|
||||
if (started && Config.getInstance().getSettings().showPlayerStarting) {
|
||||
Toast.makeText(getScene(), "Starting Player", 2000, 500, 500);
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
new PlayAction(this, model).execute();
|
||||
}
|
||||
|
||||
private void setRecording(boolean recording) {
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package ctbrec.ui.action;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.ui.Player;
|
||||
import ctbrec.ui.controls.Toast;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.Node;
|
||||
|
||||
public class PlayAction {
|
||||
|
||||
private Model selectedModel;
|
||||
private Node source;
|
||||
|
||||
public PlayAction(Node source, Model selectedModel) {
|
||||
this.source = source;
|
||||
this.selectedModel = selectedModel;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
source.setCursor(Cursor.WAIT);
|
||||
new Thread(() -> {
|
||||
boolean started = Player.play(selectedModel);
|
||||
Platform.runLater(() -> {
|
||||
if (started && Config.getInstance().getSettings().showPlayerStarting) {
|
||||
Toast.makeText(source.getScene(), "Starting Player", 2000, 500, 500);
|
||||
}
|
||||
source.setCursor(Cursor.DEFAULT);
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
}
|
|
@ -38,10 +38,9 @@ import java.util.Optional;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.ui.Player;
|
||||
import ctbrec.ui.action.PlayAction;
|
||||
import javafx.application.Platform;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.event.EventHandler;
|
||||
|
@ -83,16 +82,7 @@ public class SearchPopoverTreeList extends PopoverTreeList<Model> implements Pop
|
|||
return;
|
||||
}
|
||||
|
||||
setCursor(Cursor.WAIT);
|
||||
new Thread(() -> {
|
||||
Platform.runLater(() -> {
|
||||
boolean started = Player.play(model);
|
||||
if(started && Config.getInstance().getSettings().showPlayerStarting) {
|
||||
Toast.makeText(getScene(), "Starting Player", 2000, 500, 500);
|
||||
}
|
||||
setCursor(Cursor.DEFAULT);
|
||||
});
|
||||
}).start();
|
||||
new PlayAction(this, model).execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,13 +22,11 @@ import ctbrec.sites.mfc.MyFreeCams;
|
|||
import ctbrec.sites.mfc.MyFreeCamsModel;
|
||||
import ctbrec.sites.mfc.SessionState;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.Player;
|
||||
import ctbrec.ui.TabSelectionListener;
|
||||
import ctbrec.ui.action.FollowAction;
|
||||
import ctbrec.ui.action.PlayAction;
|
||||
import ctbrec.ui.action.StartRecordingAction;
|
||||
import ctbrec.ui.controls.SearchBox;
|
||||
import ctbrec.ui.controls.Toast;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
@ -42,7 +40,6 @@ import javafx.event.ActionEvent;
|
|||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckMenuItem;
|
||||
import javafx.scene.control.ContextMenu;
|
||||
|
@ -291,16 +288,7 @@ public class MyFreeCamsTableTab extends Tab implements TabSelectionListener {
|
|||
}
|
||||
|
||||
private void openInPlayer(Model selectedModel) {
|
||||
table.setCursor(Cursor.WAIT);
|
||||
new Thread(() -> {
|
||||
boolean started = Player.play(selectedModel);
|
||||
Platform.runLater(() -> {
|
||||
if (started && Config.getInstance().getSettings().showPlayerStarting) {
|
||||
Toast.makeText(getTabPane().getScene(), "Starting Player", 2000, 500, 500);
|
||||
}
|
||||
table.setCursor(Cursor.DEFAULT);
|
||||
});
|
||||
}).start();
|
||||
new PlayAction(getTabPane(), selectedModel).execute();
|
||||
}
|
||||
|
||||
private void addTableColumnIfEnabled(TableColumn<ModelTableRow, ?> tc) {
|
||||
|
|
Loading…
Reference in New Issue